Run only node 20 in PRs, 22 and 24 in trunk, better coverage report n… #2
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: JavaScript Unit Tests | ||
|
Check failure on line 1 in .github/workflows/unit-tests.yml
|
||
| on: | ||
| pull_request: | ||
| branches: [trunk] | ||
| push: | ||
| branches: [trunk] | ||
| # Allow manually triggering the workflow | ||
| workflow_dispatch: | ||
| # Cancels all previous workflow runs for pull requests that have not completed | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} | ||
| cancel-in-progress: true | ||
| # Disable permissions for all available scopes by default | ||
| permissions: {} | ||
| jobs: | ||
| unit-js: | ||
| name: JavaScript Unit Tests (Node.js ${{ matrix.node }}) | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| if: ${{ github.event_name == 'push' || matrix.node == '20' }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| node: ['20', '22', '24'] | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| show-progress: false | ||
| persist-credentials: false | ||
| - name: Setup Node.js and install dependencies | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node }} | ||
| cache: 'npm' | ||
| - name: Install dependencies | ||
| run: npm ci | ||
| - name: Run unit tests | ||
| run: npm run test:unit -- --ci --coverage | ||
| - name: Upload coverage to Codecov | ||
| if: always() | ||
| uses: codecov/codecov-action@v5 | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| files: ./coverage/unit/lcov.info | ||
| flags: javascript | ||
| slug: WordPress/secure-custom-fields | ||
| name: unit-js-node-${{ matrix.node }} | ||
| fail_ci_if_error: false | ||