ci: update CodeQL action and add PNPM installation #469
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 | |
| #on: [push, pull_request] | |
| on: | |
| # Triggers the workflow on push or pull request events but only for the master branch | |
| push: | |
| branches: [master] | |
| pull_request: | |
| branches: [master] | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| jobs: | |
| # Job to list all packages in the packages directory | |
| list-packages: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| packages: ${{ steps.set-packages.outputs.packages }} | |
| steps: | |
| - name: Check out repository code | |
| uses: actions/checkout@v3 | |
| - name: List packages | |
| id: set-packages | |
| run: | | |
| packages=($(ls -d packages/* | xargs -n 1 basename)) | |
| json="[" | |
| for package in "${packages[@]}"; do | |
| json+="\"$package\"," | |
| done | |
| json="${json%,}]" | |
| echo "::set-output name=packages::$json" | |
| shell: bash | |
| tests: | |
| strategy: | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| node: | |
| - 20 | |
| # Dynamically generate the package list by scanning the packages directory | |
| package: ${{ fromJSON(needs.list-packages.outputs.packages) }} | |
| runs-on: ${{ matrix.os }} | |
| needs: | |
| list-packages | |
| steps: | |
| - name: Use Node.js ${{ matrix.node }} | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| - name: Check out repository code | |
| uses: actions/checkout@v3 | |
| - name: Install PNPM package manager | |
| run: npm install pnpm@10 -g | |
| continue-on-error: false | |
| - name: Install dependencies | |
| run: pnpm build:ca | |
| continue-on-error: false | |
| - name: Run tests and collect code coverage | |
| run: pnpm -F ${{ matrix.package }} test | |
| if: success() | |
| - name: Navigate to package directory | |
| run: cd packages/${{ matrix.package }} | |
| if: success() | |
| - name: Upload code coverage | |
| uses: codecov/codecov-action@v2 | |
| with: | |
| name: codecov-${{ matrix.package }} | |
| flags: ${{ matrix.package }} | |
| directory: packages/${{ matrix.package }}/coverage | |
| if: success() |