|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths-ignore: |
| 6 | + - 'docs/**' |
| 7 | + - '*.md' |
| 8 | + branches: |
| 9 | + - main |
| 10 | + - release/* |
| 11 | + - feat/* |
| 12 | + - fix/* |
| 13 | + - perf/* |
| 14 | + pull_request: |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +env: |
| 18 | + # 7 GiB by default on GitHub, setting to 6 GiB |
| 19 | + # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources |
| 20 | + NODE_OPTIONS: --max-old-space-size=6144 |
| 21 | + |
| 22 | +concurrency: |
| 23 | + group: ${{ github.workflow }}-${{ github.event.number || github.sha }} |
| 24 | + cancel-in-progress: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + lint: |
| 28 | + timeout-minutes: 10 |
| 29 | + name: 'Lint' |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Install pnpm |
| 36 | + uses: pnpm/action-setup@v3 |
| 37 | + |
| 38 | + - name: Use Node.js 20 |
| 39 | + uses: actions/setup-node@v4 |
| 40 | + with: |
| 41 | + node-version: 20 |
| 42 | + cache: 'pnpm' |
| 43 | + |
| 44 | + - name: Install deps |
| 45 | + run: pnpm install |
| 46 | + |
| 47 | + - name: Build |
| 48 | + run: pnpm run build |
| 49 | + |
| 50 | + - name: Lint |
| 51 | + run: pnpm run lint |
| 52 | + |
| 53 | + - name: TypeCheck |
| 54 | + run: pnpm run typecheck |
| 55 | + |
| 56 | + - name: CSpell |
| 57 | + uses: streetsidesoftware/cspell-action@v6 |
| 58 | + |
| 59 | + # From https://github.com/rhysd/actionlint/blob/main/docs/usage.md#use-actionlint-on-github-actions |
| 60 | + - name: Check workflow files |
| 61 | + run: | |
| 62 | + bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) |
| 63 | + ./actionlint -color -shellcheck="" |
| 64 | +
|
| 65 | + test: |
| 66 | + timeout-minutes: 20 |
| 67 | + runs-on: ${{ matrix.os }} |
| 68 | + strategy: |
| 69 | + matrix: |
| 70 | + os: [ubuntu-latest] |
| 71 | + node_version: [18, 20] |
| 72 | + include: |
| 73 | + # Active LTS + other OS |
| 74 | + - os: macos-latest |
| 75 | + node_version: 20 |
| 76 | + - os: windows-latest |
| 77 | + node_version: 20 |
| 78 | + fail-fast: false |
| 79 | + |
| 80 | + name: "Build & Test: node-${{ matrix.node_version }}, ${{ matrix.os }}" |
| 81 | + steps: |
| 82 | + - name: Checkout |
| 83 | + uses: actions/checkout@v4 |
| 84 | + with: |
| 85 | + # Assume PRs are less than 50 commits |
| 86 | + fetch-depth: 50 |
| 87 | + |
| 88 | + - name: Get changed files |
| 89 | + id: changed-files |
| 90 | + uses: tj-actions/changed-files@20576b4b9ed46d41e2d45a2256e5e2316dde6834 # v43.0.1 |
| 91 | + with: |
| 92 | + files: | |
| 93 | + docs/** |
| 94 | + .github/** |
| 95 | + !.github/workflows/ci.yml |
| 96 | + **.md |
| 97 | +
|
| 98 | + - name: Install pnpm |
| 99 | + if: steps.changed-files.outputs.only_changed != 'true' |
| 100 | + uses: pnpm/action-setup@v3 |
| 101 | + |
| 102 | + - name: Set node version to ${{ matrix.node_version }} |
| 103 | + if: steps.changed-files.outputs.only_changed != 'true' |
| 104 | + uses: actions/setup-node@v4 |
| 105 | + with: |
| 106 | + node-version: ${{ matrix.node_version }} |
| 107 | + cache: "pnpm" |
| 108 | + |
| 109 | + - name: Install deps |
| 110 | + if: steps.changed-files.outputs.only_changed != 'true' |
| 111 | + run: pnpm install |
| 112 | + |
| 113 | + - name: Build |
| 114 | + if: steps.changed-files.outputs.only_changed != 'true' |
| 115 | + run: pnpm run build |
| 116 | + |
| 117 | + - name: Test unit |
| 118 | + if: steps.changed-files.outputs.only_changed != 'true' |
| 119 | + run: pnpm run test |
0 commit comments