|
| 1 | +name: CI - Node.js |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - 'main' |
| 7 | + - 'prod-**' |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - 'main' |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.workflow_run.head_branch || github.ref }} |
| 14 | + cancel-in-progress: ${{ !contains(github.ref, 'main') && !contains(github.ref, 'prod-') }} |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | +jobs: |
| 20 | + lint: |
| 21 | + name: Lint |
| 22 | + runs-on: ubuntu-22.04 |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + node-version: [22] |
| 26 | + fail-fast: false |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout |
| 30 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 31 | + |
| 32 | + - name: Check number of lockfiles |
| 33 | + run: | |
| 34 | + if [ $(find . -name 'package-lock.json' | grep -vc -e 'node_modules') -gt 0 ] |
| 35 | + then |
| 36 | + echo -e 'Error: found package-lock files in the repository.\nWe use pnpm workspaces to manage packages so all dependencies should be added via pnpm add' |
| 37 | + exit 1 |
| 38 | + fi |
| 39 | +
|
| 40 | + - name: Use Node.js ${{ matrix.node-version }} |
| 41 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 42 | + with: |
| 43 | + node-version: ${{ matrix.node-version }} |
| 44 | + |
| 45 | + - name: Install pnpm |
| 46 | + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4 |
| 47 | + id: pnpm-install |
| 48 | + with: |
| 49 | + run_install: false |
| 50 | + |
| 51 | + - name: Install dependencies |
| 52 | + run: pnpm install |
| 53 | + |
| 54 | + - name: Check formatting |
| 55 | + run: | |
| 56 | + pnpm format:check || [ $? -eq 1 ] && printf "\nTip: Run 'pnpm run format' in your terminal to fix this.\n\n" |
| 57 | +
|
| 58 | + - name: Lint |
| 59 | + run: pnpm lint |
| 60 | + |
| 61 | + type-check: |
| 62 | + name: Type Check |
| 63 | + runs-on: ubuntu-22.04 |
| 64 | + needs: lint |
| 65 | + strategy: |
| 66 | + matrix: |
| 67 | + node-version: [22] |
| 68 | + |
| 69 | + steps: |
| 70 | + - name: Checkout |
| 71 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 72 | + |
| 73 | + - name: Use Node.js ${{ matrix.node-version }} |
| 74 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 75 | + with: |
| 76 | + node-version: ${{ matrix.node-version }} |
| 77 | + |
| 78 | + - name: Install pnpm |
| 79 | + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4 |
| 80 | + id: pnpm-install |
| 81 | + with: |
| 82 | + run_install: false |
| 83 | + |
| 84 | + - name: Install dependencies |
| 85 | + run: pnpm install |
| 86 | + |
| 87 | + - name: Fetch curriculum data |
| 88 | + run: pnpm fetch-data |
| 89 | + |
| 90 | + - name: Generate GraphQL types |
| 91 | + run: pnpm codegen |
| 92 | + |
| 93 | + - name: Type check |
| 94 | + run: pnpm type-check |
| 95 | + |
| 96 | + build: |
| 97 | + name: Build |
| 98 | + runs-on: ubuntu-22.04 |
| 99 | + needs: type-check |
| 100 | + strategy: |
| 101 | + matrix: |
| 102 | + node-version: [22] |
| 103 | + |
| 104 | + steps: |
| 105 | + - name: Checkout |
| 106 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 107 | + |
| 108 | + - name: Use Node.js ${{ matrix.node-version }} |
| 109 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 110 | + with: |
| 111 | + node-version: ${{ matrix.node-version }} |
| 112 | + |
| 113 | + - name: Install pnpm |
| 114 | + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4 |
| 115 | + id: pnpm-install |
| 116 | + with: |
| 117 | + run_install: false |
| 118 | + |
| 119 | + - name: Install dependencies |
| 120 | + run: pnpm install |
| 121 | + |
| 122 | + - name: Fetch curriculum data |
| 123 | + run: pnpm fetch-data |
| 124 | + |
| 125 | + - name: Build project |
| 126 | + run: pnpm build |
| 127 | + |
| 128 | + - name: Upload build artifacts |
| 129 | + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 |
| 130 | + with: |
| 131 | + name: dist |
| 132 | + path: packages/server/dist |
| 133 | + retention-days: 7 |
| 134 | + |
| 135 | + test: |
| 136 | + name: Test |
| 137 | + runs-on: ubuntu-22.04 |
| 138 | + needs: build |
| 139 | + strategy: |
| 140 | + fail-fast: false |
| 141 | + matrix: |
| 142 | + node-version: [22] |
| 143 | + |
| 144 | + steps: |
| 145 | + - name: Checkout |
| 146 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 147 | + |
| 148 | + - name: Use Node.js ${{ matrix.node-version }} |
| 149 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 150 | + with: |
| 151 | + node-version: ${{ matrix.node-version }} |
| 152 | + |
| 153 | + - name: Install pnpm |
| 154 | + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4 |
| 155 | + id: pnpm-install |
| 156 | + with: |
| 157 | + run_install: false |
| 158 | + |
| 159 | + - name: Install dependencies |
| 160 | + run: pnpm install |
| 161 | + |
| 162 | + - name: Fetch curriculum data |
| 163 | + run: pnpm fetch-data |
| 164 | + |
| 165 | + - name: Run tests |
| 166 | + run: pnpm test |
| 167 | + |
| 168 | + test-coverage: |
| 169 | + name: Test Coverage |
| 170 | + runs-on: ubuntu-22.04 |
| 171 | + needs: test |
| 172 | + strategy: |
| 173 | + matrix: |
| 174 | + node-version: [22] |
| 175 | + |
| 176 | + steps: |
| 177 | + - name: Checkout |
| 178 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 179 | + |
| 180 | + - name: Use Node.js ${{ matrix.node-version }} |
| 181 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 182 | + with: |
| 183 | + node-version: ${{ matrix.node-version }} |
| 184 | + |
| 185 | + - name: Install pnpm |
| 186 | + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4 |
| 187 | + id: pnpm-install |
| 188 | + with: |
| 189 | + run_install: false |
| 190 | + |
| 191 | + - name: Install dependencies |
| 192 | + run: pnpm install |
| 193 | + |
| 194 | + - name: Fetch curriculum data |
| 195 | + run: pnpm fetch-data |
| 196 | + |
| 197 | + - name: Run tests with coverage |
| 198 | + run: pnpm test:coverage |
| 199 | + |
| 200 | + - name: Upload coverage reports |
| 201 | + uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5 |
| 202 | + if: always() |
| 203 | + with: |
| 204 | + files: ./coverage/coverage-final.json |
| 205 | + flags: unittests |
| 206 | + name: codecov-curriculum-db |
0 commit comments