| 1 | name: ✅ Pull Request Checks |
| 2 | |
| 3 | on: |
| 4 | pull_request: |
| 5 | types: [opened, synchronize, reopened] |
| 6 | |
| 7 | permissions: |
| 8 | contents: read |
| 9 | |
| 10 | jobs: |
| 11 | run-eslint: |
| 12 | name: ✅ Check ESLint on PR |
| 13 | runs-on: ubuntu-latest |
| 14 | # Only needs to run when code is changed |
| 15 | if: always() && (github.event.action == 'opened' || github.event.action == 'synchronize') |
| 16 | |
| 17 | # Override permissions, linter likely needs write access to issues |
| 18 | permissions: |
| 19 | contents: read |
| 20 | issues: write |
| 21 | pull-requests: write |
| 22 | |
| 23 | steps: |
| 24 | - name: Checkout Repository |
| 25 | # Checkout |
| 26 | # https://github.com/marketplace/actions/checkout |
| 27 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 28 | with: |
| 29 | ref: ${{ github.event.pull_request.head.sha }} |
| 30 | repository: ${{ github.event.pull_request.head.repo.full_name }} |
| 31 | |
| 32 | - name: Setup Node.js |
| 33 | # Setup Node.js environment |
| 34 | # https://github.com/marketplace/actions/setup-node-js-environment |
| 35 | uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0 |
| 36 | with: |
| 37 | node-version: 24 |
| 38 | |
| 39 | - name: Run npm install |
| 40 | run: npm ci --ignore-scripts |
| 41 | |
| 42 | - name: Run ESLint |
| 43 | # Action ESLint |
| 44 | # https://github.com/marketplace/actions/action-eslint |
| 45 | uses: sibiraj-s/action-eslint@bcf41bb9abce43cdbad51ab9b3da2eddaa17eab3 # v3.0.1 |
| 46 | with: |
| 47 | token: ${{ secrets.GITHUB_TOKEN }} # ESLint can run with the original permissions |
| 48 | eslint-args: '--ignore-path=.gitignore --quiet' |
| 49 | extensions: 'js' |
| 50 | annotations: true |
| 51 | ignore-patterns: | |
| 52 | dist/ |
| 53 | lib/ |
| 54 | |
| 55 | run-tests: |
| 56 | name: ✅ Run Unit Tests on PR |
| 57 | runs-on: ubuntu-latest |
| 58 | # Only needs to run when code is changed |
| 59 | if: always() && (github.event.action == 'opened' || github.event.action == 'synchronize') |
| 60 | |
| 61 | steps: |
| 62 | - name: Checkout Repository |
| 63 | # Checkout |
| 64 | # https://github.com/marketplace/actions/checkout |
| 65 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 66 | with: |
| 67 | ref: ${{ github.event.pull_request.head.sha }} |
| 68 | repository: ${{ github.event.pull_request.head.repo.full_name }} |
| 69 | |
| 70 | - name: Setup Node.js |
| 71 | # Setup Node.js environment |
| 72 | # https://github.com/marketplace/actions/setup-node-js-environment |
| 73 | uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0 |
| 74 | with: |
| 75 | node-version: 24 |
| 76 | |
| 77 | - name: Install root dependencies |
| 78 | run: npm ci --ignore-scripts |
| 79 | |
| 80 | - name: Install test dependencies |
| 81 | run: npm ci --ignore-scripts --prefix tests |
| 82 | |
| 83 | - name: Run unit tests |
| 84 | run: npm run test:unit --prefix tests |