|
| 1 | +name: Test Workflow |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +jobs: |
| 8 | + test: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v4 |
| 12 | + |
| 13 | + # Test basic npx usage in GitHub Actions - should be flagged |
| 14 | + - name: Run tests |
| 15 | + # ruleid: npx-usage-yml |
| 16 | + run: npx jest --coverage |
| 17 | + |
| 18 | + - name: Lint code |
| 19 | + # ruleid: npx-usage-yml |
| 20 | + run: npx eslint src/ |
| 21 | + |
| 22 | + - name: Format code |
| 23 | + # ruleid: npx-usage-yml |
| 24 | + run: npx prettier --write . |
| 25 | + |
| 26 | + - name: Create app |
| 27 | + # ruleid: npx-usage-yml |
| 28 | + run: npx create-react-app my-app |
| 29 | + |
| 30 | + - name: Setup tool with flag |
| 31 | + # ruleid: npx-usage-yml |
| 32 | + run: npx --yes setup-tool --config config.json |
| 33 | + |
| 34 | + - name: Run with env vars |
| 35 | + # ruleid: npx-usage-yml |
| 36 | + run: npx jest ${GITHUB_WORKSPACE} --coverage |
| 37 | + |
| 38 | + # Test scoped package with output redirection - should be flagged |
| 39 | + - name: Generate fingerprint |
| 40 | + # ruleid: npx-usage-yml |
| 41 | + run: npx @expo/fingerprint ./ > fingerprint-pr.json |
| 42 | + |
| 43 | + - name: Another scoped package |
| 44 | + # ruleid: npx-usage-yml |
| 45 | + run: npx @typescript-eslint/parser --version |
| 46 | + |
| 47 | + # Test npx in middle of command strings - should be flagged |
| 48 | + - name: Install and test |
| 49 | + # ruleid: npx-usage-yml |
| 50 | + run: yarn install && npx jest --coverage |
| 51 | + |
| 52 | + - name: Setup and lint |
| 53 | + # ruleid: npx-usage-yml |
| 54 | + run: echo "Setting up" && npx eslint src/ |
| 55 | + |
| 56 | + - name: Build and format |
| 57 | + # ruleid: npx-usage-yml |
| 58 | + run: npm run build && npx prettier --write . |
| 59 | + |
| 60 | + # Test good alternatives - should not be flagged |
| 61 | + - name: Run tests with yarn |
| 62 | + # ok: npx-usage-yml |
| 63 | + run: yarn jest --coverage |
| 64 | + |
| 65 | + - name: Lint code with yarn |
| 66 | + # ok: npx-usage-yml |
| 67 | + run: yarn eslint src/ |
| 68 | + |
| 69 | + - name: Format code with yarn |
| 70 | + # ok: npx-usage-yml |
| 71 | + run: yarn prettier --write . |
| 72 | + |
| 73 | + - name: Create app with yarn dlx |
| 74 | + # ok: npx-usage-yml |
| 75 | + run: yarn dlx create-react-app my-app |
| 76 | + |
| 77 | + - name: Build with npm script |
| 78 | + # ok: npx-usage-yml |
| 79 | + run: npm run build |
| 80 | + |
| 81 | + - name: Description mentions npx but doesn't use it |
| 82 | + # ok: npx-usage-yml |
| 83 | + run: echo "This workflow mentions npx but doesn't execute it" |
| 84 | + |
| 85 | + - name: Just npm (not npx) |
| 86 | + # ok: npx-usage-yml |
| 87 | + run: npm install |
0 commit comments