-
Notifications
You must be signed in to change notification settings - Fork 11
175 lines (149 loc) · 4.33 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
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
# run every morning at 10am Pacific Time
- cron: '0 17 * * *'
name: ci
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
RUST_BACKTRACE: 1
# Pin the nightly toolchain to prevent breakage.
# This should be occasionally updated.
RUST_NIGHTLY_TOOLCHAIN: nightly-2024-10-07
jobs:
env:
runs-on: ubuntu-latest
outputs:
rust-versions: ${{ steps.definitions.outputs.versions }}
msrv: ${{ steps.definitions.outputs.msrv }}
steps:
- uses: actions/checkout@v3
- name: Evaluate definitions
id: definitions
run: |
export MSRV=$(cat rust-toolchain | awk '{$1=$1};1')
echo "msrv=$MSRV" >> "$GITHUB_OUTPUT"
export RAW_VERSIONS="stable beta $RUST_NIGHTLY_TOOLCHAIN $MSRV"
export VERSIONS=$(echo $RAW_VERSIONS | jq -scR 'rtrimstr("\n")|split(" ")|.')
echo "versions=$VERSIONS" >> "$GITHUB_OUTPUT"
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
id: toolchain
with:
toolchain: ${{ env.RUST_NIGHTLY_TOOLCHAIN }}
profile: minimal
override: true
components: rustfmt
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- toolchain: stable
# fail on stable warnings
args: "-D warnings"
- toolchain: beta
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions-rs/[email protected]
id: toolchain
with:
toolchain: ${{ matrix.toolchain }}
profile: minimal
override: true
components: clippy
- uses: camshaft/rust-cache@v1
- name: Cache node_modules
uses: actions/[email protected]
continue-on-error: true
with:
path: duvet/www/node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('duvet/www/package-lock.json') }}
- name: Build script.js
run: |
make duvet/www/public/script.js
# TODO translate json reports to in-action warnings
- name: Run cargo clippy
uses: actions-rs/[email protected]
with:
command: clippy
args: --all-features --all-targets -- -A clippy::uninlined_format_args ${{ matrix.args }}
udeps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions-rs/[email protected]
id: toolchain
with:
toolchain: ${{ env.RUST_NIGHTLY_TOOLCHAIN }}
profile: minimal
override: true
- uses: camshaft/rust-cache@v1
- uses: camshaft/install@v1
with:
crate: cargo-udeps
- name: Cache node_modules
uses: actions/[email protected]
continue-on-error: true
with:
path: duvet/www/node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('duvet/www/package-lock.json') }}
- name: Build script.js
run: |
make duvet/www/public/script.js
- name: Run cargo udeps
run: cargo udeps --workspace --all-targets
env:
RUSTC_WRAPPER: ""
test:
runs-on: ${{ matrix.os }}
needs: env
strategy:
matrix:
rust: ${{ fromJson(needs.env.outputs.rust-versions) }}
os: [ubuntu-latest, macOS-latest]
steps:
- uses: actions/checkout@v3
with:
lfs: true
- uses: actions-rs/toolchain@v1
id: toolchain
with:
toolchain: ${{ matrix.rust }}
override: true
- uses: camshaft/rust-cache@v1
with:
key: ${{ matrix.target }}
- name: Cache node_modules
uses: actions/[email protected]
continue-on-error: true
with:
path: duvet/www/node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('duvet/www/package-lock.json') }}
- name: Build script.js
run: |
make duvet/www/public/script.js
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test