-
Notifications
You must be signed in to change notification settings - Fork 13
266 lines (220 loc) · 7.41 KB
/
ci.yml
File metadata and controls
266 lines (220 loc) · 7.41 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
name: CI
on:
pull_request:
branches:
- main
- dev
push:
branches:
- main
- dev
paths-ignore:
- '**.md'
- '.gitignore'
- 'LICENSE'
- '.github/ISSUE_TEMPLATE/**'
- '.github/PULL_REQUEST_TEMPLATE.md'
- '.github/labeler.yml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
NODE_VERSION: '24'
GO_VERSION: '1.25.x'
jobs:
changes:
name: Detect Changes
runs-on: ubuntu-latest
outputs:
formulus: ${{ steps.filter.outputs.formulus }}
formulus-formplayer: ${{ steps.filter.outputs.formulus-formplayer }}
synkronus: ${{ steps.filter.outputs.synkronus }}
synkronus-cli: ${{ steps.filter.outputs.synkronus-cli }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed components
uses: dorny/paths-filter@v2
id: filter
with:
filters: |
formulus:
- 'formulus/**'
formulus-formplayer:
- 'formulus-formplayer/**'
synkronus:
- 'synkronus/**'
- 'Dockerfile'
synkronus-cli:
- 'synkronus-cli/**'
formulus:
name: Formulus (React Native)
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.formulus == 'true' || github.event_name == 'workflow_dispatch' }}
defaults:
run:
working-directory: ./formulus
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.33.2
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
cache-dependency-path: formulus/pnpm-lock.yaml
- name: Install and build @ode/tokens
working-directory: packages/tokens
run: |
pnpm install --frozen-lockfile
pnpm run build
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run linter
run: pnpm run lint
- name: Run tests
# Do not use `pnpm test -- --ci`: pnpm forwards args after `--` with an extra
# `--` to Jest, which then treats `--ci` as a test path pattern (0 matches).
run: pnpm run test --ci --coverage --watchAll=false
formulus-formplayer:
name: Formulus Formplayer (React Web)
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.formulus-formplayer == 'true' || github.event_name == 'workflow_dispatch' }}
defaults:
run:
working-directory: ./formulus-formplayer
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.33.2
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
cache-dependency-path: formulus-formplayer/pnpm-lock.yaml
- name: Install and build @ode/tokens
working-directory: packages/tokens
run: |
pnpm install --frozen-lockfile
pnpm run build
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run linter
run: pnpm run lint
- name: Run Prettier check
run: pnpm run format:check
- name: Run tests
# Vitest: `run` subcommand = single CI pass (Jest's --watchAll=false does not apply).
run: pnpm run test run
continue-on-error: true
- name: Build
run: pnpm run build
synkronus:
name: Synkronus (Go Backend)
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.synkronus == 'true' || github.event_name == 'workflow_dispatch' }}
defaults:
run:
working-directory: ./synkronus
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: synkronus/go.sum
- name: Verify dependencies
run: go mod verify
- name: Download dependencies
run: go mod download
- name: Run gofmt (warning)
run: |
UNFORMATTED_FILES=$(git ls-files '*.go' | xargs gofmt -s -l)
if [ -n "$UNFORMATTED_FILES" ]; then
echo "⚠️ Code is not formatted."
echo "$UNFORMATTED_FILES"
echo "$UNFORMATTED_FILES" | xargs gofmt -s -d
else
echo "✅ All Go files are formatted."
fi
- name: Run golangci-lint (if available)
run: |
if command -v golangci-lint &> /dev/null; then
golangci-lint run
else
echo "golangci-lint not installed, skipping..."
fi
continue-on-error: true
- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...
- name: Build
run: go build -v ./cmd/synkronus
synkronus-cli:
name: Synkronus CLI (Go CLI)
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.synkronus-cli == 'true' || github.event_name == 'workflow_dispatch' }}
defaults:
run:
working-directory: ./synkronus-cli
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: synkronus-cli/go.sum
- name: Verify dependencies
run: go mod verify
- name: Download dependencies
run: go mod download
- name: Run gofmt (warning)
run: |
UNFORMATTED_FILES=$(git ls-files '*.go' | xargs gofmt -s -l)
if [ -n "$UNFORMATTED_FILES" ]; then
echo "⚠️ Code is not formatted."
echo "$UNFORMATTED_FILES"
echo "$UNFORMATTED_FILES" | xargs gofmt -s -d
else
echo "✅ All Go files are formatted."
fi
- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...
- name: Build
run: go build -v ./cmd/synkronus
ci-summary:
name: CI Summary
runs-on: ubuntu-latest
needs: [formulus, formulus-formplayer, synkronus, synkronus-cli]
if: always()
steps:
- name: Check job results
run: |
echo "## CI Summary" >> $GITHUB_STEP_SUMMARY
echo "| Component | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Formulus | ${{ needs.formulus.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Formulus Formplayer | ${{ needs.formulus-formplayer.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Synkronus | ${{ needs.synkronus.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Synkronus CLI | ${{ needs.synkronus-cli.result }} |" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.formulus.result }}" == "failure" ]; then exit 1; fi
if [ "${{ needs.formulus-formplayer.result }}" == "failure" ]; then exit 1; fi
if [ "${{ needs.synkronus.result }}" == "failure" ]; then exit 1; fi
if [ "${{ needs.synkronus-cli.result }}" == "failure" ]; then exit 1; fi
echo "✅ All CI checks passed!"