-
Notifications
You must be signed in to change notification settings - Fork 0
207 lines (161 loc) · 5.69 KB
/
rust.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
name: Digital Voting CI
on:
push:
branches: [ main ]
pull_request:
types: [opened, synchronize]
jobs:
check:
name: Check
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
# - os: ubuntu-latest
# target: aarch64-unknown-linux-gnu
# - os: macos-latest
# target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
# - os: windows-latest
# target: i686-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Install Rust Default Toolchain
run: rustup toolchain install stable --profile minimal
- name: Add target
run: rustup target add ${{ matrix.target }}
- name: cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}-cargo-check-${{ hashFiles('**/Cargo.lock') }}
- name: Check project
run: cargo check --verbose --workspace --release --target ${{ matrix.target }}
test:
name: Test
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
# - os: ubuntu-latest
# target: aarch64-unknown-linux-gnu
# - os: macos-latest
# target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
# - os: windows-latest
# target: i686-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Install Rust Default Toolchain
run: rustup toolchain install stable --profile minimal
- name: Add target
run: rustup target add ${{ matrix.target }}
- name: cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
- name: Run tests
run: cargo test --verbose --workspace --target ${{ matrix.target }}
formatting:
name: Check formatting
runs-on: ubuntu-latest
container:
image: thrasherlt/digital-voting-rust-multi-toolchain:latest
steps:
- uses: actions/checkout@v2
- name: Install Rust Default Toolchain
run: rustup toolchain install stable --profile default
- name: Check formatting
run: cargo fmt -- --check
- name: Check leptos formatting
run: leptosfmt --check subcrates/client/src/**.rs
docrs:
name: Build documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust Default Toolchain
run: rustup toolchain install stable --profile default
- name: cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-cargo-docrs-${{ hashFiles('**/Cargo.lock') }}
- name: Build documentation
run: cargo doc --verbose --workspace --no-deps
lint:
name: Run linters
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
# - os: ubuntu-latest
# target: aarch64-unknown-linux-gnu
# - os: macos-latest
# target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
# - os: windows-latest
# target: i686-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Install Rust Default Toolchain
run: rustup toolchain install stable --profile default
- name: Add target
run: rustup target add ${{ matrix.target }}
- name: cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
- name: Lint with Clippy
# Enabling all and pedantic since they seem to produce good results even if sometimes annoying.
run: cargo clippy -- -D warnings --target ${{ matrix.target }} -W clippy::all -W clippy::pedantic
dependencies:
name: Check dependencies
runs-on: ubuntu-latest
# Building udeps and deny takes way too long, so using a prebuilt image.
container:
image: thrasherlt/digital-voting-rust-multi-toolchain:latest
steps:
- uses: actions/checkout@v2
# TODO not sure if two separate caches are required here:
- name: cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-cargo-dependencies-${{ hashFiles('**/Cargo.lock') }}
- name: Check dependencies with cargo-deny
run: cargo deny --workspace check
- name: Check unused dependencies with cargo-udeps
run: cargo +nightly udeps --workspace --all-targets
wasm-test:
name: Test on WASM
runs-on: ubuntu-latest
# Using custom container to avoid waiting for wasm-pack and chromium driver to be installed
container:
image: thrasherlt/digital-voting-rust-multi-toolchain:latest
steps:
- uses: actions/checkout@v2
- name: cache
uses: Swatinem/rust-cache@v2
with:
key: wasm-cargo-test-${{ hashFiles('**/Cargo.lock') }}
# TODO figure out a better way to test multiple crates:
# Seems like wasm-pack doesn't allow specifying multiple crates:
- name: Run WASM tests for crypto subcrate
run: wasm-pack test --chrome --headless subcrates/crypto/
- name: Run WASM tests for protocol subcrate
run: wasm-pack test --chrome --headless subcrates/protocol/
- name: Run WASM tests for client subcrate
run: wasm-pack test --chrome --headless subcrates/client/