-
-
Notifications
You must be signed in to change notification settings - Fork 46
400 lines (350 loc) · 11.7 KB
/
ci.yml
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
395
396
397
398
399
400
name: "Building and testing ArkScript"
on:
push:
branches: [ dev, master ]
paths-ignore:
- '.github/workflows/benchmarks.yml'
- '.github/workflows/docker.yml'
- '.github/workflows/label.yml'
- '.github/workflows/lizard.yml'
- '.github/workflows/release.yml'
- '.vscode/*.*'
- 'examples/*.ark'
- '.github/images/*.*'
- '*.md'
- 'docs/*.*'
- 'Dockerfile'
- '.dockerignore'
- 'LICENCE'
- '.gitignore'
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
BUILD_TYPE: Debug
SQLITE_VERSION: 3390100 # 3.39.1
jobs:
check:
name: Formatting Check
runs-on: ubuntu-24.04
strategy:
matrix:
path:
- 'src'
- 'include'
steps:
- uses: actions/checkout@v4
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/[email protected]
with:
clang-format-version: '13'
check-path: ${{ matrix.path }}
fallback-style: 'Mozilla' # optional
check_ark:
name: ArkScript formatting check
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
path:
- examples
- examples/games
- examples/games/snake
steps:
- uses: actions/checkout@v4
- name: Format check
uses: ArkScript-lang/action-format@master
with:
folder: ${{ matrix.path }}
repo_visualizer:
runs-on: ubuntu-24.04
needs: [ check ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Update diagram
uses: githubocto/repo-visualizer@main
with:
excluded_paths: 'dist,node_modules,submodules'
should_push: false
output_file: 'diagram.svg'
artifact_name: 'diagram'
build:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.name }}
needs: [ check ]
strategy:
fail-fast: false
matrix:
config:
- {
os: ubuntu-24.04, name: "Ubuntu Clang 16",
compiler: clang, compiler_version: 16, sanitizers: "On",
artifact: "ubuntu-clang-16"
}
- {
os: ubuntu-24.04, name: "Ubuntu Clang 16 (valgrind)",
compiler: clang, compiler_version: 16, sanitizers: "Off",
artifact: "ubuntu-clang-valgrind"
}
- {
os: ubuntu-24.04, name: "Ubuntu GCC 14",
compiler: gcc, compiler_version: 14, sanitizers: "On",
artifact: "ubuntu-gcc-14"
}
- {
os: windows-latest, name: "Windows VS 2022",
compiler: msvc, compiler_version: "", sanitizers: "On",
artifact: "windows-msvc-22"
}
- {
os: macos-latest, name: "MacOS Clang 16",
artifact: "macos-clang-16",
compiler: clang, compiler_version: 16, sanitizers: "On"
}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup compilers, dependencies, project and build
uses: ./.github/workflows/setup-compilers
with:
os_name: ${{ matrix.config.os }}
compiler: ${{ matrix.config.compiler }}
compiler_version: ${{ matrix.config.compiler_version }}
sanitizers: ${{ matrix.config.sanitizers }}
with_deps: true
- name: Organize files for upload
shell: bash
run: |
mkdir -p artifact/lib/std
# Linux/MacOS
if [[ '${{ startsWith(matrix.config.os, 'ubuntu') }}' == 'true' ]] || [[ '${{ startsWith(matrix.config.os, 'macos') }}' == 'true' ]]; then
cp build/arkscript artifact || true
cp build/libArkReactor.* artifact || true
fi
# Windows
if [[ '${{ startsWith(matrix.config.os, 'windows') }}' == 'true' ]]; then
cp build/$BUILD_TYPE/arkscript.exe artifact || true
cp build/$BUILD_TYPE/ArkReactor.dll artifact || true
fi
# Generic
cp lib/*.arkm artifact/lib
cp lib/std/*.ark artifact/lib/std
rm -rf artifact/lib/std/{.git,.github,tests/__arkscript__}
- name: Organize temp artifact
shell: bash
run: |
mkdir -p temp/tests/unittests/
cp build/unittests temp/ || true
cp build/$BUILD_TYPE/unittests.exe temp/ || true
cp -r tests/unittests temp/tests/unittests
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.config.artifact }}
path: artifact
- name: Upload temp artifact
uses: actions/upload-artifact@v4
with:
name: temp-${{ matrix.config.artifact }}
path: temp
retention-days: 1
coverage:
runs-on: ubuntu-24.04
name: Coverage
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt-get install -yq -o Acquire::Retries=3 lcov
lcov --version
- name: Setup compilers, dependencies, project and build
uses: ./.github/workflows/setup-compilers
with:
os_name: ubuntu-24.04
compiler: clang
compiler_version: 16
sanitizers: On
coverage: On
with_deps: false
- name: Run tests
run: |
export ASAN_OPTIONS=detect_odr_violation=0
./build/unittests
- name: Gather coverage
run: cmake --build build --target coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
path-to-lcov: build/coverage.info
github-token: ${{ secrets.GITHUB_TOKEN }}
tests:
runs-on: ${{ matrix.config.os }}
name: Tests on ${{ matrix.config.name }}
needs: [ build ]
strategy:
fail-fast: false
matrix:
config:
- { os: ubuntu-24.04, name: "Ubuntu Clang 16", artifact: "ubuntu-clang-16", compiler_version: 16, }
- { os: ubuntu-24.04, name: "Ubuntu GCC 14", artifact: "ubuntu-gcc-14", compiler_version: 14, }
- { os: windows-latest, name: "Windows VS 2022", artifact: "windows-msvc-22", compiler_version: 22, }
- { os: macos-latest, name: "MacOS Clang 16", artifact: "macos-clang-16", compiler_version: 16, }
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup tests
uses: ./.github/workflows/setup-tests
with:
os_name: ${{ matrix.config.os }}
compiler_version: ${{ matrix.config.compiler_version }}
- name: Tests
shell: bash
run: |
export ASAN_OPTIONS=detect_odr_violation=0
./unittests
- name: Modules tests
shell: bash
run: |
export ASAN_OPTIONS=detect_odr_violation=0
chmod u+x ./lib/modules/.github/run-tests
(./lib/modules/.github/run-tests src)
fuzzing:
runs-on: ubuntu-24.04
name: Fuzz testing
continue-on-error: true
container:
image: aflplusplus/aflplusplus:v4.20c
env:
BUILD_FOLDER: afl
FUZZER_SEED: 0
FUZZ_TIME_SEC: 300
FUZZER_TIMEOUT_EXEC_MS: 500
AFL_NO_STARTUP_CALIBRATION: 1
AFL_CMPLOG_ONLY_NEW: 1
AFL_MAP_SIZE: 223723
volumes:
- ${{ github.workspace }}:/src
options: --cpus 4
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Build with AFL
run: |
cd /src
cmake -B${BUILD_FOLDER} \
-DCMAKE_C_COMPILER=/AFLplusplus/afl-cc \
-DCMAKE_CXX_COMPILER=/AFLplusplus/afl-c++ \
-DCMAKE_BUILD_TYPE=Release \
-DARK_BUILD_EXE=On \
-DARK_SANITIZERS=On
cmake --build ${BUILD_FOLDER} --config Release -j 4
- name: Fuzz
run: |
afl-fuzz -i tests/fuzzing/corpus-cmin-tmin \
-o output \
-s $FUZZER_SEED \
-t $FUZZER_TIMEOUT_EXEC_MS \
-V $FUZZ_TIME_SEC \
-- ${BUILD_FOLDER}/arkscript @@ -L ./lib
- uses: 8BitJonny/[email protected]
id: PR
with:
sha: ${{ github.event.pull_request.head.sha }}
# Only return if PR is still open
filterOutClosed: true
- run: |
echo "PR found: ${prFound}"
echo "PR ${prNumber:-ERROR} ${prTitle:-NOTITLE}"
env:
# Direct access to common PR properties
prNumber: ${{ steps.PR.outputs.number }}
prTitle: ${{ steps.PR.outputs.pr_title }}
prFound: ${{ steps.PR.outputs.pr_found }}
- name: Summarize for PR
id: summary
if: steps.PR.outputs.pr_found == 'true'
shell: bash
run: |
echo "FUZZ_SUMMARY<<EOF" >> $GITHUB_ENV
afl-whatsup -s -d output >> $GITHUB_ENV
afl-showmap -C -i output -o /dev/null -- ./${BUILD_FOLDER}/arkscript @@ -L ./lib | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" | grep -v Reading | grep -v Scanning >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Summarize
if: steps.PR.outputs.pr_found == 'false'
shell: bash
run: |
afl-whatsup -s -d output
afl-showmap -C -i output -o /dev/null -- ./${BUILD_FOLDER}/arkscript @@ -L ./lib
- name: Find Comment
uses: peter-evans/find-comment@v3
if: steps.PR.outputs.pr_found == 'true'
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Fuzzing report
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
if: steps.PR.outputs.pr_found == 'true'
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## Fuzzing report
${{ env.FUZZ_SUMMARY }}
edit-mode: replace
- name: Sort files for upload
continue-on-error: true
run: |
mkdir crashes
cp output/default/crashes/id:* crashes/
tar -czvf crashes.tar.gz crashes
- name: Upload crashes
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: crashes
path: crashes.tar.gz
valgrind:
runs-on: ubuntu-24.04
name: Ubuntu Clang Valgrind
needs: [ build ]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Download artifact
id: download
uses: actions/download-artifact@v4
with:
name: "ubuntu-clang-valgrind"
path: build
- name: Update LLVM compilers
shell: bash
run: |
mv build/lib/*.arkm lib/
chmod u+x build/arkscript
sudo apt-get update --fix-missing
sudo apt-get install -y clang-16 lld-16 libc++-16-dev libc++abi-16-dev clang-tools-16
- name: Install valgrind 3.20.0
shell: bash
run: |
wget --no-check-certificate http://ftp.us.debian.org/debian/pool/main/v/valgrind/valgrind_3.20.0-2.1_amd64.deb
sudo apt remove needrestart
sudo apt install ./valgrind_3.20.0-2.1_amd64.deb
- name: Valgrind checks for memory leaks
shell: bash
run: |
valgrind --leak-check=full --show-leak-kinds=all \
--track-origins=yes --track-fds=yes \
--trace-children=yes \
--verbose -s \
--error-exitcode=1 \
build/arkscript tests/unittests/resources/LangSuite/unittests.ark -L ./lib valgrind