ci: make Ready gate fail when required jobs fail #6481
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| permissions: | |
| contents: read | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| name: π· Build | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| version: [16, 18, 20, 22, 24] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: ${{ matrix.version }} | |
| # Skip post-install scripts here, as a malicious | |
| # script could steal NODE_AUTH_TOKEN. | |
| - name: Install dependencies | |
| run: npm ci --ignore-scripts | |
| env: | |
| CI: true | |
| NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }} | |
| - name: Building | |
| run: npm run build | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }} | |
| - name: Examples - es6 | |
| run: cd examples/es6 && npm i && npm run build | |
| - name: Examples - common | |
| run: cd examples/commonjs && npm i | |
| - name: Examples - Management CLI | |
| run: cd examples/managementCli && npm i && npm run build | |
| eslint: | |
| name: πͺ₯ ESLint | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| version: [16, 18, 20, 22, 24] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: ${{ matrix.version }} | |
| # Skip post-install scripts here, as a malicious | |
| # script could steal NODE_AUTH_TOKEN. | |
| - name: Install dependencies | |
| run: npm ci --ignore-scripts | |
| env: | |
| CI: true | |
| NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }} | |
| - run: npm run format-check | |
| - run: npm run lint | |
| gitleaks: | |
| name: π Run Git leaks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version-file: package.json | |
| # Skip post-install scripts here, as a malicious | |
| # script could steal NODE_AUTH_TOKEN. | |
| - name: Install dependencies | |
| run: npm ci --ignore-scripts | |
| env: | |
| CI: true | |
| NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }} | |
| - name: Gitleaks | |
| run: npm run leaks | |
| shell: bash | |
| pr-title-check: | |
| name: β Validate PR Title | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Validate PR title follows Semantic Commit Convention | |
| uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| types: | | |
| feat | |
| fix | |
| docs | |
| style | |
| refactor | |
| perf | |
| test | |
| build | |
| ci | |
| chore | |
| revert | |
| requireScope: false | |
| subjectPattern: ^(?![A-Z]).+$ | |
| subjectPatternError: | | |
| The subject "{subject}" found in the pull request title "{title}" | |
| didn't match the configured pattern. Please ensure that the subject | |
| doesn't start with an uppercase character. | |
| unit-test: | |
| name: π Run Unit Tests | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| version: [16, 18, 20, 22, 24] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: ${{ matrix.version }} | |
| # Skip post-install scripts here, as a malicious | |
| # script could steal NODE_AUTH_TOKEN. | |
| - name: Install dependencies and build | |
| run: npm ci --ignore-scripts && npm run build | |
| env: | |
| CI: true | |
| NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }} | |
| - name: Testing | |
| run: npm test | |
| ready: | |
| name: π Ready | |
| runs-on: ubuntu-latest | |
| needs: [build, eslint, gitleaks, pr-title-check, unit-test] | |
| # Run even when a dependency fails or is skipped, so this required | |
| # gate reports a real pass/fail instead of being auto-satisfied by | |
| # a "skipped" status when an upstream job fails. | |
| if: always() | |
| steps: | |
| - name: Verify all required jobs succeeded | |
| if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') | |
| run: | | |
| echo "One or more required jobs failed or were cancelled:" | |
| echo '${{ toJSON(needs) }}' | |
| exit 1 | |
| - name: Ready | |
| run: echo "All checks passed and the PR is ready to be merged!" |