-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (138 loc) · 4.31 KB
/
ci.yml
File metadata and controls
166 lines (138 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: CI
on:
push:
branches: [main, master]
paths-ignore:
- 'docs/**'
- '*.md'
- 'LICENSE'
pull_request:
branches: [main, master]
paths-ignore:
- 'docs/**'
- '*.md'
- 'LICENSE'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
runs-on: ubuntu-latest
outputs:
client: ${{ steps.filter.outputs.client }}
server: ${{ steps.filter.outputs.server }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
client:
- 'apps/web/**'
- '.github/workflows/ci.yml'
server:
- 'apps/api/**'
- '.github/workflows/ci.yml'
client:
needs: changes
if: ${{ needs.changes.outputs.client == 'true' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./apps/web
strategy:
matrix:
node-version: [20, 22]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: ./apps/web/package-lock.json
- name: Install client dependencies
run: npm ci
- name: Run lint
run: npm run lint
- name: Run client tests
run: npm test -- --run
- name: Build client
run: npm run build
- name: Upload coverage reports
uses: codecov/codecov-action@v4
if: matrix.node-version == 20
continue-on-error: true
with:
directory: ./apps/web/coverage
flags: client
name: client-coverage
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
server:
needs: changes
if: ${{ needs.changes.outputs.server == 'true' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./apps/api
strategy:
matrix:
node-version: [20, 22]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: ./apps/api/package-lock.json
- name: Install server dependencies
run: npm ci
- name: Run lint
run: npm run lint
- name: Run server tests
run: npm test
- name: Run server property tests
run: npm run test:property
- name: Upload coverage reports
uses: codecov/codecov-action@v4
if: matrix.node-version == 20
continue-on-error: true
with:
directory: ./apps/api/coverage
flags: server
name: server-coverage
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
status-check:
needs: [changes, client, server]
if: always()
runs-on: ubuntu-latest
steps:
- name: Check all jobs status
run: |
CLIENT_NEEDED="${{ needs.changes.outputs.client == 'true' || github.event_name == 'workflow_dispatch' }}"
SERVER_NEEDED="${{ needs.changes.outputs.server == 'true' || github.event_name == 'workflow_dispatch' }}"
CLIENT_RESULT="${{ needs.client.result }}"
SERVER_RESULT="${{ needs.server.result }}"
echo "Client needed: $CLIENT_NEEDED, result: $CLIENT_RESULT"
echo "Server needed: $SERVER_NEEDED, result: $SERVER_RESULT"
FAILED=0
if [ "$CLIENT_NEEDED" = "true" ] && [ "$CLIENT_RESULT" != "success" ]; then
echo "❌ Client job failed or was cancelled"
FAILED=1
fi
if [ "$SERVER_NEEDED" = "true" ] && [ "$SERVER_RESULT" != "success" ]; then
echo "❌ Server job failed or was cancelled"
FAILED=1
fi
if [ $FAILED -eq 1 ]; then
exit 1
fi
echo "✅ All required checks passed"