-
Notifications
You must be signed in to change notification settings - Fork 14
219 lines (211 loc) · 7.32 KB
/
Copy pathci.yml
File metadata and controls
219 lines (211 loc) · 7.32 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
on:
push:
branches:
- master
paths-ignore:
- "**.md"
- "!.github/workflows/*.yml"
- "!rln-wasm/**"
- "!rln/src/**"
- "!rln/resources/**"
- "!utils/src/**"
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled]
paths-ignore:
- "**.md"
- "!.github/workflows/*.yml"
- "!rln-wasm/**"
- "!rln/src/**"
- "!rln/resources/**"
- "!utils/src/**"
name: CI
jobs:
test:
name: Test - ${{ matrix.crate }} - ${{ matrix.platform }}
# skip tests on draft PRs
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !github.event.pull_request.draft)
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
crate: [utils, rln]
runs-on: ${{ matrix.platform }}
timeout-minutes: 60
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: make installdeps
- name: Test ${{ matrix.crate }}
run: cargo make test --release
working-directory: ${{ matrix.crate }}
rln-wasm-test:
name: Test - rln-wasm - ${{ matrix.platform }}
# skip tests on draft PRs
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !github.event.pull_request.draft)
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
timeout-minutes: 60
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: make installdeps
- name: Build rln-wasm
run: cargo make build
working-directory: rln-wasm
- name: Test rln-wasm on node
run: cargo make test --release
working-directory: rln-wasm
- name: Test rln-wasm on browser
run: cargo make test_browser --release
working-directory: rln-wasm
rln-wasm-parallel-test:
name: Test - rln-wasm-parallel - ${{ matrix.platform }}
# skip tests on draft PRs
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !github.event.pull_request.draft)
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
timeout-minutes: 60
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
targets: wasm32-unknown-unknown
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: make installdeps
- name: Build rln-wasm in parallel mode
run: cargo make build_parallel
working-directory: rln-wasm
- name: Test rln-wasm in parallel mode on browser
run: cargo make test_parallel --release
working-directory: rln-wasm
fmt:
name: Format
# skip on draft PRs
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !github.event.pull_request.draft)
# run fmt tests only on ubuntu
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: Install cargo-make
run: cargo install cargo-make
- name: Check formatting
run: cargo make fmt_check
clippy:
name: Clippy - ${{ matrix.crate }}
# skip on draft PRs
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !github.event.pull_request.draft)
strategy:
matrix:
# run clippy only on ubuntu
crate: [rln, rln-wasm, utils]
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Install wasm32 target
if: matrix.crate == 'rln-wasm'
run: rustup target add wasm32-unknown-unknown
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: make installdeps
- name: Check clippy wasm target
if: matrix.crate == 'rln-wasm'
run: cargo clippy --target wasm32-unknown-unknown --tests --release -- -D warnings
working-directory: ${{ matrix.crate }}
- name: Check clippy
if: matrix.crate != 'rln-wasm'
run: cargo clippy --all-targets --release -- -D warnings
working-directory: ${{ matrix.crate }}
benchmark:
name: Benchmark - ${{ matrix.crate }}
# run only on ready PRs
if: github.event_name == 'pull_request' && !github.event.pull_request.draft
strategy:
matrix:
# run benchmarks only on ubuntu
crate: [utils, rln]
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Compare benchmarks
uses: boa-dev/criterion-compare-action@v3
with:
branchName: ${{ github.base_ref }}
cwd: ${{ matrix.crate }}
coverage:
name: Coverage
if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-coverage')
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: make installdeps
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
- name: Run coverage
run: |
cargo tarpaulin --engine llvm --timeout 300 --out Html --output-dir ./coverage -- --test-threads 1
- name: Upload coverage reports
uses: actions/upload-artifact@v7
with:
name: coverage-reports
path: ./coverage/
- name: Comment on PR with coverage link
uses: actions/github-script@v9
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
});
const coverageArtifact = artifacts.data.artifacts.find(art => art.name === 'coverage-reports');
if (coverageArtifact) {
const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/artifacts/${coverageArtifact.id}`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Coverage report uploaded. [Download HTML Report](${artifactUrl})`
});
}