This repository has been archived by the owner on Sep 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
373 lines (340 loc) · 13.2 KB
/
run_test_suite.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
on:
workflow_dispatch:
push:
branches: [main]
pull_request:
name: Run test suite
jobs:
build-noosphere-apple-artifacts:
name: 'Build Noosphere artifacts (Apple)'
uses: ./.github/workflows/noosphere_apple_build.yaml
with:
for-test: true
run-test-suite-mac-os-swift:
runs-on: macos-12
needs: ['build-noosphere-apple-artifacts']
steps:
- uses: actions/checkout@v3
- name: 'Download XCode Framework artifact'
uses: actions/download-artifact@v3
with:
name: libnoosphere_apple_framework
- name: 'Run Swift tests'
run: |
unzip ./libnoosphere-apple-xcframework.zip
sed -i '' -e "s#url: \"[^\"]*\",#path: \"./LibNoosphere.xcframework\"),#" ./Package.swift
sed -i '' -e "s#checksum: \"[^\"]*\"),##" ./Package.swift
# Enable malloc debugging features
# https://developer.apple.com/library/archive/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html
export MallocPreScribble=1
export MallocScribble=1
swift build --sanitize=address
swift test --sanitize=address
run-linting-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: 'Setup Rust'
run: |
curl -sSf https://sh.rustup.rs | sh -s -- -y
rustup component add clippy
rustup component add rustfmt
- name: 'Install environment packages'
run: |
sudo apt-get update -qqy
sudo apt-get install jq protobuf-compiler cmake
- name: 'Check Format'
run: cargo fmt --all -- --check
- name: 'Run Linter'
run: cargo clippy --all -- -D warnings
run-full-test-suite:
strategy:
matrix:
features: ['test-kubo,headers', 'test-kubo,headers,rocksdb']
platform: ['windows-latest', 'ubuntu-latest']
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: 'Setup Rust'
run: |
curl -sSf https://sh.rustup.rs | sh -s -- -y
- name: 'Install environment packages (Windows)'
if: ${{ matrix.platform == 'windows-latest' }}
run: |
choco install -y cmake protoc openssl
shell: sh
- name: 'Install environment packages (Linux)'
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
sudo apt-get update -qqy
sudo apt-get install jq protobuf-compiler cmake
- name: 'Install IPFS Kubo'
uses: ibnesayeed/setup-ipfs@master
with:
ipfs_version: v0.17.0
run_daemon: true
- name: Install cargo-binstall
uses: cargo-bins/[email protected]
- name: Install binaries from cargo
run: |
cargo binstall cargo-nextest --no-confirm --force
- name: 'Run Rust tests'
run: cargo nextest run --features ${{matrix.features}} --retries 5 --color always 2>&1 | tee test-results.log
env:
NOOSPHERE_LOG: academic
- name: Parse test results
run: |
RESULTS_PATH="./test-results.log"
csplit -q "$RESULTS_PATH" %^------------%
if [[ -f "./xx00" ]]; then
SUMMARY=`tail ./xx00 -n+2`
if [[ "$SUMMARY" =~ 'FLAKY' ]]; then
# See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
{
echo "summary<<EOF"
echo "$SUMMARY"
echo "EOF"
} >> $GITHUB_OUTPUT
fi
fi
- name: Report test flakes
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const flakeyTestsHeader = '### Test flake analysis for `${{ matrix.platfrom }}` (`${{ matrix.features }}`)';
const existingComment = comments.find(comment => {
return comment.user.type === 'Bot' && comment.body.includes(flakeyTestsHeader)
});
let body;
if (`${{ steps['Parse test results'].outputs.summary }}`) {
body = `${flakeyTestsHeader}
\`\`\`shell
${{ steps['Parse test results'].outputs.summary }}
\`\`\`
`;
} else {
body = `${flakeyTestsHeader}
No flakes detected!
`;
}
if (existingComment) {
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body
})
} else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body
})
}
run-test-suite-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: 'Setup Rust'
run: |
curl -sSf https://sh.rustup.rs | sh -s -- -y
- name: 'Install environment packages'
run: |
sudo apt-get update -qqy
sudo apt-get install jq protobuf-compiler cmake
- name: Install cargo-binstall
uses: cargo-bins/[email protected]
- name: Install binaries from cargo
run: |
cargo binstall cargo-nextest --no-confirm --force
- name: 'Install IPFS Kubo'
uses: ibnesayeed/setup-ipfs@master
with:
ipfs_version: v0.17.0
run_daemon: true
- name: 'Run Rust native target tests'
run: cargo nextest run --features test-kubo,headers --retries 5 --color always 2>&1 | tee test-results.log
env:
NOOSPHERE_LOG: academic
- uses: actions/upload-artifact@v3
with:
name: test-results-linux
path: ./test-results.log
report-test-flakes:
name: 'Report test flakes (Linux)'
needs: ['run-test-suite-linux']
uses: ./.github/workflows/report_test_flakes.yaml
secrets: inherit
with:
target: 'linux'
# run-test-suite-windows:
# runs-on: windows-latest
# steps:
# - uses: actions/checkout@v3
# - uses: Swatinem/rust-cache@v2
# - name: 'Setup Rust'
# run: |
# curl -sSf https://sh.rustup.rs | sh -s -- -y
# - name: 'Install environment packages'
# run: |
# choco install -y cmake protoc openssl
# shell: sh
# - name: Install cargo-binstall
# uses: cargo-bins/[email protected]
# - name: Install binaries from cargo
# run: |
# cargo binstall cargo-nextest --no-confirm
# - name: 'Install IPFS Kubo'
# uses: ibnesayeed/setup-ipfs@master
# with:
# ipfs_version: v0.17.0
# run_daemon: true
# - name: 'Run Rust native target tests'
# run: cargo nextest run --features test-kubo,headers --retries 5 --color always 2>&1 | tee test-results.log
# env:
# NOOSPHERE_LOG: academic
# run-test-suite-linux-rocksdb:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: Swatinem/rust-cache@v2
# - name: 'Setup Rust'
# run: |
# curl -sSf https://sh.rustup.rs | sh -s -- -y
# - name: 'Install environment packages'
# run: |
# sudo apt-get update -qqy
# sudo apt-get install jq protobuf-compiler cmake libclang-dev
# - name: Install cargo-binstall
# uses: cargo-bins/[email protected]
# - name: Install binaries from cargo
# run: |
# cargo binstall cargo-nextest --no-confirm --force
# - name: 'Install IPFS Kubo'
# uses: ibnesayeed/setup-ipfs@master
# with:
# ipfs_version: v0.17.0
# run_daemon: true
# - name: 'Run Rust native target tests (RocksDB)'
# run: cargo nextest run --features rocksdb,test-kubo,headers --retries 5 --color always
# env:
# NOOSPHERE_LOG: academic
run-test-suite-linux-c:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: 'Setup Rust'
run: |
curl -sSf https://sh.rustup.rs | sh -s -- -y
- name: 'Install environment packages'
run: |
sudo apt-get update -qqy
sudo apt-get install jq protobuf-compiler cmake make
- name: 'Link Noosphere from C'
run: |
make build -C ./c/example
- name: 'Run C integration tests'
run: |
make run -C ./c/example
run-test-suite-web-wasm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: 'Setup Rust'
run: |
curl -sSf https://sh.rustup.rs | sh -s -- -y
rustup component add clippy
rustup component add rustfmt
- name: 'Install environment packages'
run: |
sudo apt-get update -qqy
sudo apt-get install jq protobuf-compiler cmake
- name: 'Install Rust/WASM test dependencies'
run: |
rustup target install wasm32-unknown-unknown
cargo install toml-cli
WASM_BINDGEN_VERSION=`toml get ./Cargo.lock . | jq '.package | map(select(.name == "wasm-bindgen"))[0].version' | xargs echo`
cargo install wasm-bindgen-cli --vers "$WASM_BINDGEN_VERSION"
shell: bash
# See: https://github.com/SeleniumHQ/selenium/blob/5d108f9a679634af0bbc387e7e3811bc1565912b/.github/actions/setup-chrome/action.yml
- name: 'Setup Chrome and chromedriver'
run: |
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list.d/google-chrome.list
sudo apt-get update -qqy
sudo apt-get -qqy install google-chrome-stable
CHROMEDRIVER_URL=$(curl https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json |
jq -r '.channels.Stable.downloads.chromedriver | map(select(.platform == "linux64")) | first.url')
curl -L -O "$CHROMEDRIVER_URL"
unzip chromedriver-linux64.zip
pushd ./chromedriver-linux64
chmod +x chromedriver
sudo mv chromedriver /usr/local/bin
popd
chromedriver -version
shell: bash
- name: 'Run Rust headless browser tests'
working-directory: ./rust
run: CHROMEDRIVER=/usr/local/bin/chromedriver cargo test --target wasm32-unknown-unknown
shell: bash
run-test-suite-web-typescript:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
# Disable wireit cache for now, seeing some errors pop up:
# https://github.com/subconsciousnetwork/noosphere/actions/runs/4682179827/jobs/8295693844
# - uses: google/wireit@setup-github-actions-caching/v1
- name: 'Setup Rust'
run: |
curl -sSf https://sh.rustup.rs | sh -s -- -y
- uses: actions/setup-node@v3
with:
node-version: lts/*
- name: 'Install environment packages'
run: |
sudo apt-get update -qqy
sudo apt-get install jq protobuf-compiler cmake
- name: 'Install Rust/WASM test dependencies'
run: |
rustup target install wasm32-unknown-unknown
cargo install toml-cli
WASM_BINDGEN_VERSION=`toml get ./Cargo.lock . | jq '.package | map(select(.name == "wasm-bindgen"))[0].version' | xargs echo`
cargo install wasm-bindgen-cli --vers "$WASM_BINDGEN_VERSION"
cargo install wasm-opt --locked
shell: bash
# See: https://github.com/SeleniumHQ/selenium/blob/5d108f9a679634af0bbc387e7e3811bc1565912b/.github/actions/setup-chrome/action.yml
- name: 'Setup Chrome and chromedriver'
run: |
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list.d/google-chrome.list
sudo apt-get update -qqy
sudo apt-get -qqy install google-chrome-stable
CHROMEDRIVER_URL=$(curl https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json |
jq -r '.channels.Stable.downloads.chromedriver | map(select(.platform == "linux64")) | first.url')
curl -L -O "$CHROMEDRIVER_URL"
unzip chromedriver-linux64.zip
pushd ./chromedriver-linux64
chmod +x chromedriver
sudo mv chromedriver /usr/local/bin
popd
chromedriver -version
shell: bash
- name: 'Install NPM dependencies'
working-directory: ./typescript
run: npm ci
- name: 'Run TypeScript headless browser tests'
working-directory: ./typescript
run: npm run test