foo-software / lighthouse-check-action

GitHub Action for running @GoogleChromeLabs Lighthouse audits with all the bells and whistles 🔔 Multiple audits, Slack notifications, and more!
https://github.com/marketplace/actions/lighthouse-check
MIT License
478 stars 24 forks source link

no such file or directory error when running with outputDirectory set #68

Closed gumaerc closed 2 years ago

gumaerc commented 2 years ago

Hi there. We've suddenly started encountering errors on our actions, and I was wondering if this might be an issue with the action itself. This is how our action step is configured:

  lighthouse:
    needs: build
    runs-on: ubuntu-latest
    if: ${{ github.event_name == 'pull_request' }}
    steps:
      - uses: actions/checkout@master
      - run: mkdir /tmp/artifacts

      - name: Set up node.js
        uses: actions/setup-node@v2-beta
        with:
          node-version: 14.16.1

      - name: Run Lighthouse
        uses: foo-software/lighthouse-check-action@master
        id: lighthouseCheck
        with:
          branch: ${{ github.ref }}
          outputDirectory: /tmp/artifacts
          urls: 'https://ocw-hugo-themes-pr-${{ github.event.number }}--ocw-next.netlify.app/,https://ocw-hugo-themes-pr-${{ github.event.number }}--ocw-next.netlify.app/search/'
          sha: ${{ github.sha }}
etc...

They are all erroring out with the following stack trace:

Run foo-software/lighthouse-check-action@master
/usr/bin/docker run --name e284904404c34ba8fb4ceda230fe09f595abe2_c3f803 --label e28490 --workdir /github/workspace --rm -e INPUT_BRANCH -e INPUT_OUTPUTDIRECTORY -e INPUT_URLS -e INPUT_SHA -e INPUT_ACCESSTOKEN -e INPUT_APITOKEN -e INPUT_AUTHOR -e INPUT_AWSACCESSKEYID -e INPUT_AWSBUCKET -e INPUT_AWSREGION -e INPUT_AWSSECRETACCESSKEY -e INPUT_CONFIGFILE -e INPUT_COMMENTURL -e INPUT_DEVICE -e INPUT_EMULATEDFORMFACTOR -e INPUT_EXTRAHEADERS -e INPUT_FOOAPITOKEN -e INPUT_GITAUTHOR -e INPUT_GITBRANCH -e INPUT_GITHUBACCESSTOKEN -e INPUT_LOCALE -e INPUT_MAXRETRIES -e INPUT_OVERRIDESJSONFILE -e INPUT_PRCOMMENTENABLED -e INPUT_PRCOMMENTSAVEOLD -e INPUT_SLACKWEBHOOKURL -e INPUT_TAG -e INPUT_THROTTLINGMETHOD -e INPUT_THROTTLING -e INPUT_TIMEOUT -e INPUT_URLSJSON -e INPUT_VERBOSE -e INPUT_WAIT -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/ocw-hugo-themes/ocw-hugo-themes":"/github/workspace" e28490:4404c34ba8fb4ceda230fe09f595abe2
lighthouse-check: Auditing mobile (1/2): https://ocw-hugo-themes-pr-287--ocw-next.netlify.app/
lighthouse-check:
 Error: ENOENT: no such file or directory, open '/tmp/artifacts/report-1638292972865.html'
    at Object.openSync (fs.js:497:3)
    at Object.writeFileSync (fs.js:1528:35)
    at exports.default (/node_modules/@foo-software/lighthouse-persist/dist/lighthousePersist.js:161:26)
    at async localLighthouse (/node_modules/@foo-software/lighthouse-check/dist/localLighthouse.js:81:7)
    at async getLocalLighthouseResultsWithRetries (/node_modules/@foo-software/lighthouse-check/dist/localLighthouse.js:122:29)
    at async _default (/node_modules/@foo-software/lighthouse-check/dist/localLighthouse.js:227:35)
    at async /node_modules/@foo-software/lighthouse-check/dist/lighthouseCheck.js:175:32 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/tmp/artifacts/report-1638292972865.html'
}
Error: ENOENT: no such file or directory, open '/tmp/artifacts/report-1638292972865.html'

You can see that it gets past the first step of "auditing mobile" and then the error happens.

adamhenson commented 2 years ago

Hi @gumaerc - Thanks for providing the details and I'm sorry for the trouble. We just released a major version of this GitHub Action with breaking changes. See release notes in v6.0.0.

We rarely introduce breaking changes, but I would still recommend pinning your versions so that you aren't impacted by breaking changes. Example below.

- foo-software/lighthouse-check-action@master
+ foo-software/lighthouse-check-action@v5

Or...

- foo-software/lighthouse-check-action@master
+ foo-software/lighthouse-check-action@v5.1.2

To fix this, you could do the above, or to use our newest major version, I believe you just need to do the below:

-      - run: mkdir /tmp/artifacts
+      - run: mkdir ${{ github.workspace }}/tmp/artifacts
# ...
-          outputDirectory: /tmp/artifacts
+          outputDirectory: ${{ github.workspace }}/tmp/artifacts

I hope this addresses your issue, feel free to let me know.

dlehmhus commented 2 years ago

Actually v5 seems not to be a valid tag and throws an error Unable to resolve action 'foo-software/lighthouse-check-action@v5', unable to find version 'v5'. But foo-software/lighthouse-check-action@v5.1.2 works as expected 👍

adamhenson commented 2 years ago

Thanks @dlehmhus. Well that's unfortunate. Most systems package management systems like NPM, Docker, etc are smart enough to find the latest major version using that syntax, but I guess with GitHub Actions... not so much :( Can't say I'm that surprised.

adamhenson commented 2 years ago

I'm deeming this issue closed, but please feel free to let me know if your issue is not resolved @gumaerc and we can re-open.

gumaerc commented 2 years ago

@adamhenson Thanks for the reply, I'll work on implementing the changes you mentioned!