-
Notifications
You must be signed in to change notification settings - Fork 8
394 lines (328 loc) · 11.6 KB
/
ci.yaml
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
name: PoP CI
on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize
- reopened
merge_group:
jobs:
fe1-web:
name: Fe1-Web
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
node-version: [18.x]
include:
# Additionally also run it on node v16
# but just on ubuntu to not have too many runs
- os: ubuntu-latest
node-version: 16.x
defaults:
run:
working-directory: ./fe1-web
steps:
- name: Setup repo
uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of Sonar analysis
- name: Setup node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Setup node npm cache
uses: actions/cache@v2
env:
cache-name: cache-node-npm
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Setup node modules cache
# MacOS is excluded since caching node modules made it slower than it was without caching
if: ${{ runner.os != 'macOS'}}
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ./fe1-web/node_modules
key: ${{ runner.os }}-nodemodules-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-nodemodules-
- name: Setup expo
run: npm install -g @expo/cli
- name: Setup npm dependencies
run: npm install
- name: Check npm security issues
run: npm audit fix
continue-on-error: true
- name: Run lint
if: ${{ matrix.os == 'ubuntu-latest' && matrix.node-version == '18.x' }} # execute even if previous steps failed
run: npm run eslint
- name: Validate dependencies
if: ${{ always() }} # execute even if previous steps failed
run: npm run depcruise
- name: Run tsdoc
if: ${{ always() }} # execute even if previous steps failed
run: npm run docs
- name: Run test
if: ${{ always() }} # execute even if previous steps failed
run: npm run test -- --runInBand --ci
- name: Run SonarCloud analysis
if: ${{ matrix.os == 'ubuntu-latest' && matrix.node-version == '18.x' && !startsWith(github.head_ref, 'dependabot/') }} # execute even if previous steps failed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
run: |
npm install -g sonarqube-scanner
sonar-scanner -Dsonar.login=${{ secrets.SONAR_TOKEN_FE1 }}
- name: Verify expo project health
if: ${{ always() }} # execute even if previous steps failed
run: |
expo doctor
continue-on-error: true
- name: Build expo web project
if: ${{ matrix.node-version != '16.x' }}
run: |
npm run build-web
- name: Build expo web project (legacy, without NODE_OPTIONS=--openssl-legacy-provider)
if: ${{ matrix.node-version == '16.x' }}
run: |
npx expo export:web
be1-go:
name: Be1-Go
strategy:
matrix:
platform: [ubuntu-latest, windows-latest]
runs-on: ${{matrix.platform}}
defaults:
run:
working-directory: ./be1-go
steps:
- name: Use go >= 1.21
uses: actions/setup-go@v3
with:
go-version: ">=1.21"
- name: Setup repo
uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of Sonar analysis
- uses: actions/cache@v2
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Format
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
make check-fmt
if [ "$(gofmt -s -l ./ | wc -l)" -gt 0 ]; then exit 1; fi
- name: Run check target
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
make check
- name: Run test target
if: ${{ matrix.platform == 'windows-latest' }}
run: |
make test
- name: Build
if: ${{ always() }} # execute even if previous steps failed
run: |
make build
- name: Run SonarCloud analysis
if: ${{ matrix.platform == 'ubuntu-latest' && !startsWith(github.head_ref, 'dependabot/') }} # execute even if previous steps failed
uses: SonarSource/sonarcloud-github-action@master
with:
projectBaseDir: be1-go
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BE1 }}
fe2-android:
name: Fe2-Android
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./fe2-android
# This CI pipeline is greatly inspired by the sample given by https://github.com/ReactiveCircus/android-emulator-runner
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of Sonar analysis
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
- name: Cache Gradle
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
- name: Grant execute permission for gradlew
run: |
chmod +x ./gradlew
- name: Assemble
shell: bash
run: |
# To run the CI with debug informations, add --info
./gradlew assemble lint --parallel --build-cache
- name: Run tests
shell: bash
run: |
# To run the CI with debug informations, add --info
./gradlew check --parallel --build-cache
- name: Generate Coverage Report
shell: bash
run: |
# To run the CI with debug informations, add --info
./gradlew jacocoTestReport --parallel --build-cache
- name: Generate Sarif Lint Report
shell: bash
run: |
# To run the CI with debug informations, add --info
./gradlew lintDebug --parallel --build-cache
- name: Upload lint sarif
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: fe2-android/app/build/reports/lint-results-debug.sarif
category: lint
- name: Cache SonarCloud packages
uses: actions/cache@v2
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Run SonarCloud analysis
if: ${{ !startsWith(github.head_ref, 'dependabot/') }} # execute even if previous steps failed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_FE2 }}
run: |
# To run the CI with debug informations, add --info
./gradlew sonarqube --parallel --build-cache
be2-scala:
name: Be2-Scala
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./be2-scala
steps:
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: "temurin"
java-version: "17"
- name: Setup repo
uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of Sonar analysis
- name: Check formatting
run: sbt scalafmtCheckAll
- name: Run unit tests
run: |
cd ./src/security/ && ./generateKeys.sh -test && cd ../.. # Generate test keys
sbt -Dscala.config="src/main/scala/ch/epfl/pop/config" -Dscala.security="src/security" -Dtest clean coverage test
rm -rf ./src/security/test/ # Remove test keys
- name: Report coverage
run: sbt coverageReport
- name: Run SonarCloud analysis
if: ${{ !startsWith(github.head_ref, 'dependabot/') }} # execute even if previous steps failed
env:
SONAR_HOST_URL: https://sonarcloud.io
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BE2 }}
run: sbt sonarScan
popcha-example-client:
name: popcha-example-web-client
runs-on: ubuntu-latest
defaults:
run:
working-directory: demo/popcha-client/web
steps:
- name: Setup repo
uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of Sonar analysis
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Setup pip dependencies
run: |
python -m pip install --upgrade pip
pip install ruff tox
pip install -r requirements.txt
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
ruff --output-format=github --select=E9,F63,F7,F82 --target-version=py39 .
# default set of ruff rules with GitHub Annotations
ruff --output-format=github --target-version=py39 .
- name: Run tests
run: |
tox -e py
- name: Run SonarCloud Analysis
if: ${{ !startsWith(github.head_ref, 'dependabot/') }} # execute even if previous steps failed
uses: SonarSource/sonarcloud-github-action@master
with:
projectBaseDir: demo/popcha-client/web
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_POPCHA_WEB_CLIENT }}
protocol:
name: protocol examples test
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./protocol/test
steps:
- name: Setup repo
uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of Sonar analysis
- name: Setup node 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Setup node cache
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Setup npm dependencies
run: |
npm install
- name: Check npm security issues
run: |
npm audit fix
- name: Run test
run: |
npm run test