|
1 | 1 | name: CI |
| 2 | + |
2 | 3 | on: |
3 | | - pull_request: |
4 | | - types: [opened, synchronize, reopened, ready_for_review] |
5 | | - paths: |
6 | | - - "src/**" |
7 | | - - "__tests__/**" |
8 | | - - "package.json" |
9 | | - - "package-lock.json" |
10 | | - - ".github/workflows/**" |
11 | 4 | push: |
12 | | - branches: [main, develop] |
13 | | - paths: |
14 | | - - "src/**" |
15 | | - - "__tests__/**" |
16 | | - - "package.json" |
17 | | - - "package-lock.json" |
18 | | - |
19 | | -permissions: |
20 | | - contents: read |
21 | | - |
22 | | -run-name: "CI — ${{ github.ref_name }} @ ${{ github.sha }}" |
| 5 | + branches: [ main, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, develop ] |
| 8 | + workflow_dispatch: |
23 | 9 |
|
24 | 10 | concurrency: |
25 | 11 | group: ${{ github.workflow }}-${{ github.ref }} |
26 | | - cancel-in-progress: true |
| 12 | + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + actions: read |
27 | 17 |
|
28 | 18 | env: |
29 | | - NODE_VERSION: 20 |
| 19 | + NODE_VERSION: "20" |
| 20 | + FORCE_COLOR: 1 |
| 21 | + CI: true |
30 | 22 |
|
31 | 23 | jobs: |
32 | 24 | test: |
33 | | - if: github.event_name == 'push' || github.event.pull_request.draft == false |
34 | | - timeout-minutes: 15 |
| 25 | + name: Test & Lint |
35 | 26 | runs-on: ubuntu-latest |
| 27 | + timeout-minutes: 15 |
| 28 | + permissions: |
| 29 | + contents: read |
36 | 30 | steps: |
37 | 31 | - name: Harden runner |
38 | | - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 |
| 32 | + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 |
39 | 33 | with: |
40 | 34 | egress-policy: audit |
41 | 35 |
|
42 | 36 | - name: Checkout code |
43 | | - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 |
| 37 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
44 | 38 | with: |
45 | 39 | persist-credentials: false |
46 | 40 | fetch-depth: 1 |
47 | 41 |
|
48 | | - - name: 🟢 Setup Node.js |
| 42 | + - name: Setup Node.js |
49 | 43 | uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 |
50 | 44 | with: |
51 | 45 | node-version: ${{ env.NODE_VERSION }} |
52 | 46 | cache: npm |
53 | | - registry-url: https://registry.npmjs.org/ |
54 | 47 | cache-dependency-path: package-lock.json |
55 | 48 |
|
56 | | - - name: Clear npm cache |
57 | | - run: npm cache clean --force |
58 | | - shell: bash |
59 | | - |
60 | 49 | - name: Install dependencies |
61 | | - run: | |
62 | | - npm ci --no-optional --no-audit --prefer-offline |
| 50 | + run: npm ci --prefer-offline |
63 | 51 | shell: bash |
64 | 52 |
|
65 | | - - name: 🧹 Lint |
66 | | - run: npm run lint --if-present |
67 | | - |
68 | | - - name: 🔍 Type check |
69 | | - run: npm run typecheck --if-present |
70 | | - |
71 | | - - name: ✅ Test |
72 | | - run: npm test -- --ci --reporters=default --reporters=jest-junit --passWithNoTests |
| 53 | + - name: Lint |
| 54 | + run: npm run lint |
| 55 | + shell: bash |
73 | 56 |
|
74 | | - - name: Upload JUnit |
75 | | - if: always() |
76 | | - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 |
77 | | - with: |
78 | | - name: junit |
79 | | - path: junit.xml |
| 57 | + - name: Test |
| 58 | + run: npm test -- --ci --passWithNoTests --coverage |
| 59 | + shell: bash |
80 | 60 |
|
81 | 61 | - name: Upload coverage |
82 | 62 | if: always() |
83 | | - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 |
| 63 | + uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 |
84 | 64 | with: |
85 | | - name: coverage |
86 | | - path: coverage |
| 65 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 66 | + fail_ci_if_error: false |
| 67 | + continue-on-error: true |
87 | 68 |
|
88 | | - coverage: |
89 | | - needs: test |
90 | | - if: always() && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) |
91 | | - timeout-minutes: 5 |
| 69 | + build: |
| 70 | + name: Build Check |
92 | 71 | runs-on: ubuntu-latest |
93 | | - permissions: |
94 | | - contents: read |
| 72 | + timeout-minutes: 10 |
| 73 | + needs: test |
95 | 74 | steps: |
96 | 75 | - name: Harden runner |
97 | | - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 |
| 76 | + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 |
98 | 77 | with: |
99 | 78 | egress-policy: audit |
100 | 79 |
|
101 | | - - name: Download coverage |
102 | | - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 |
103 | | - with: |
104 | | - name: coverage |
105 | | - path: coverage |
106 | | - continue-on-error: true |
| 80 | + - name: Checkout code |
| 81 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
107 | 82 |
|
108 | | - - name: Upload to Codecov |
109 | | - uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 |
| 83 | + - name: Setup Node.js |
| 84 | + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 |
110 | 85 | with: |
111 | | - token: ${{ secrets.CODECOV_TOKEN }} |
112 | | - fail_ci_if_error: false |
| 86 | + node-version: ${{ env.NODE_VERSION }} |
| 87 | + cache: npm |
| 88 | + |
| 89 | + - name: Install dependencies |
| 90 | + run: npm ci --prefer-offline |
| 91 | + |
| 92 | + - name: Build |
| 93 | + run: npm run build --if-present |
0 commit comments