10up / wpcs-action

GitHub Action to help you lint your PHP without additional dependencies within your codebase
MIT License
54 stars 13 forks source link

Job summary can't find resources for JSON to MD #18

Closed B-Interactive closed 1 year ago

B-Interactive commented 1 year ago

Describe your question

Using the Display the linting result in the GitHub Actions summary example, I was able to successfully set up an action that tests my repository.

However, it looks to be failing with a 404 Not Found error when trying to convert JSON to MD, at the Job Summary creation step.

Have I missed (or misunderstood) a step somewhere?

Run npx --yes github:10up/phpcs-json-to-md --path ./phpcs.json --output ./phpcs.md
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@10up%2fphpcs-json-to-md - Not found
npm ERR! 404 
npm ERR! 404  '@10up/phpcs-json-to-md@1.0.0' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2022-09-12T07_11_35_065Z-debug-0.log
Error: Process completed with exit code 1.

Code of Conduct

jeffpaul commented 1 year ago

@dinhtungdu I'm guessing this is because the 10up/phpcs-json-to-md project isn't published to npm, yeah?

dinhtungdu commented 1 year ago

@B-Interactive can you please share the configuration you're using so we can look at it further?

@jeffpaul I don't think so as in the example, we use github:10up/phpcs-json-to-md to install the package directly from GitHub.

WEBzaytsev commented 1 year ago

I use the same configuration (https://github.com/10up/wpcs-action#display-the-linting-result-in-the-github-actions-summary ) The same mistake

B-Interactive commented 1 year ago

@dinhtungdu, this is the configuration I was using, that produced the error. It is a slightly modified version of the example here:

name: WPCS check

on:
  workflow_dispatch:
  push:
    branches:
      - main
  pull_request:

jobs:
  phpcs:
      name: WPCS
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v2
        - name: WPCS check
          uses: 10up/wpcs-action@stable
          with:
            standard: 'WordPress'
            extra_args: '--report-json=./phpcs.json'
        - name: Update summary
          run: |
            npx --yes github:10up/phpcs-json-to-md --path ./phpcs.json --output ./phpcs.md
            cat phpcs.md >> $GITHUB_STEP_SUMMARY
          if: always()
dinhtungdu commented 1 year ago

@B-Interactive @WEBzaytsev thanks so much for your report, I can reproduce the issue on my local. Can you please try setting the node version to 14 to see if it fixes the issue? Look like people reported this this issue too: https://github.com/npm/cli/issues/5134

name: WPCS check

on: pull_request

jobs:
  phpcs:
      name: VIPCS
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v2
        - uses: actions/setup-node@v3
          with:
            node-version: 14
        - name: VIPCS check
          uses: 10up/wpcs-action@stable
          with:
            standard: 'WordPress-VIP-Go'
            extra_args: '--report-json=./phpcs.json'
        - name: Update summary
          run: |
            npx github:10up/phpcs-json-to-md --path ./phpcs.json --output ./phpcs.md
            cat phpcs.md >> $GITHUB_STEP_SUMMARY
          if: always()
B-Interactive commented 1 year ago

Thanks @dinhtungdu, that is working.

It did take more than 13 minutes at the Update summary step. I'm not sure if that's expected.

image

dinhtungdu commented 1 year ago

It did take more than 13 minutes at the Update summary step. I'm not sure if that's expected.

@B-Interactive It's definitely unexpected, the npx installation took so long. @jeffpaul I think we need to create a stable branch and push the built command there to speedup the installation.

jeffpaul commented 1 year ago

@iamdharmesh Tung's note above might be something worth researching in your next spin through OSS time.

iamdharmesh commented 1 year ago

Hi @jeffpaul, npx installation takes too long because of npm v6 (Node 14 comes with npm v6). I tried with Node 16 and it only takes 2s-4s to Update the summary. Using Node 16 will fix this issue.

As npx no longer works with github: in latest version of Node 16 (As mentioned by @dinhtungdu here), We can use github:10up/phpcs-json-to-md by install it (instead of using on-the-fly by npx) OR we can use specific node version(16.16.0) before this npx bug was introduced. Sample yml content is given below for both possible options.

@dinhtungdu @jeffpaul as this issue is with the old version of npm only, I think it's fine to keep 10up/phpcs-json-to-md as it is, what do think?

Thanks

jeffpaul commented 1 year ago

@iamdharmesh I think I'm in favor of the approach using github:10up/phpcs-json-to-md.

iamdharmesh commented 1 year ago

Thanks for the feedback @jeffpaul PR raised for the same.