| 1 | name: CLI PR Checks |
| 2 | |
| 3 | on: |
| 4 | pull_request: |
| 5 | branches: [main] |
| 6 | paths: |
| 7 | - "extensions/cli/**" |
| 8 | |
| 9 | permissions: |
| 10 | contents: read |
| 11 | pull-requests: write |
| 12 | issues: write |
| 13 | |
| 14 | jobs: |
| 15 | lint: |
| 16 | runs-on: ubuntu-latest |
| 17 | steps: |
| 18 | - name: Checkout code |
| 19 | uses: actions/checkout@v4 |
| 20 | |
| 21 | - name: Setup Node.js |
| 22 | uses: actions/setup-node@v4 |
| 23 | with: |
| 24 | node-version: 20 |
| 25 | cache: "npm" |
| 26 | cache-dependency-path: extensions/cli/package-lock.json |
| 27 | |
| 28 | - name: Install dependencies |
| 29 | run: | |
| 30 | cd extensions/cli |
| 31 | npm ci |
| 32 | |
| 33 | - name: Run linting |
| 34 | run: | |
| 35 | cd extensions/cli |
| 36 | npm run lint |
| 37 | |
| 38 | test: |
| 39 | strategy: |
| 40 | matrix: |
| 41 | os: [ubuntu-latest, windows-latest, macos-latest] |
| 42 | node-version: [18, 20, 22, 24] |
| 43 | runs-on: ${{ matrix.os }} |
| 44 | |
| 45 | steps: |
| 46 | - name: Checkout code |
| 47 | uses: actions/checkout@v4 |
| 48 | |
| 49 | - name: Setup Node.js ${{ matrix.node-version }} |
| 50 | uses: actions/setup-node@v4 |
| 51 | with: |
| 52 | node-version: ${{ matrix.node-version }} |
| 53 | cache: "npm" |
| 54 | cache-dependency-path: extensions/cli/package-lock.json |
| 55 | |
| 56 | - name: Install dependencies |
| 57 | run: | |
| 58 | cd extensions/cli |
| 59 | npm ci |
| 60 | |
| 61 | - name: Build |
| 62 | run: | |
| 63 | cd extensions/cli |
| 64 | npm run build |
| 65 | |
| 66 | # e2e tests are failing on Windows specifically - likely due to stdout flush issues |
| 67 | - name: Run tests |
| 68 | if: matrix.os != 'windows-latest' |
| 69 | run: | |
| 70 | cd extensions/cli |
| 71 | npm test |
| 72 | |
| 73 | - name: Run tests (excluding e2e on Windows) |
| 74 | if: matrix.os == 'windows-latest' |
| 75 | shell: bash |
| 76 | run: | |
| 77 | cd extensions/cli |
| 78 | npm test -- --exclude='**/*.e2e.*' --exclude='**/e2e/**' |
| 79 | |
| 80 | # GitHub does not have a way of requiring that all checks pass (you must manually select each job) |
| 81 | # This action at least lets us manage the list of required tests via source control |
| 82 | # so that creators of new jobs can add them to this list |
| 83 | require-all-checks-to-pass-cli: |
| 84 | if: always() |
| 85 | runs-on: ubuntu-latest |
| 86 | needs: |
| 87 | - lint |
| 88 | - test |
| 89 | |
| 90 | steps: |
| 91 | - name: Decide whether the needed jobs succeeded or failed |
| 92 | uses: re-actors/alls-green@release/v1 |
| 93 | with: |
| 94 | jobs: ${{ toJSON(needs) }} |