-
Notifications
You must be signed in to change notification settings - Fork 4
203 lines (180 loc) · 6 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
name: Continuous integration
on:
pull_request:
push:
branches:
- main
jobs:
build-and-test-wasm:
name: Build and test (WASM + Chrome)
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'
run: CHROMEDRIVER=/usr/local/bin/chromedriver cargo test --target wasm32-unknown-unknown
shell: bash
build_and_test:
name: Build and test
runs-on: ${{ matrix.os }}
continue-on-error: false
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]
rust: [stable]
experimental: [false]
include:
- os: ubuntu-latest
rust: stable
release-os: linux
release-arch: amd64
protoc-arch: linux-x86_64
- os: macos-latest
rust: stable
release-os: darwin
release-arch: aarch64
protoc-arch: osx-aarch_64
# windows is broken somehow atm
- os: windows-latest
rust: stable
release-os: windows
release-arch: amd64
env:
RUST_BACKTRACE: full
# Force not building debuginfo to save space on disk.
RUSTFLAGS: "-C debuginfo=0"
RUSTV: ${{ matrix.rust }}
MSRV: "1.70"
steps:
- uses: actions/checkout@master
- name: Set build arch
run: |
echo "PROTOC_ARCH=${{ matrix.protoc-arch }}" >> $GITHUB_ENV
- name: Install ${{ matrix.rust }}
run: |
rustup toolchain install --profile default ${{ matrix.rust }}
- name: Install Rust MSRV
if: matrix.os != 'windows-latest'
run: |
rustup toolchain install --profile minimal $MSRV
- name: Install Rust MSRV
if: matrix.os == 'windows-latest'
run: |
rustup toolchain install --profile minimal $Env:MSRV
- name: Install Protoc windows
if: matrix.os == 'windows-latest'
uses: arduino/setup-protoc@v1
with:
version: '3.20.1'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Protoc
if: matrix.os != 'windows-latest'
run: |
PROTOC_VERSION=3.20.1
PROTOC_ZIP=protoc-$PROTOC_VERSION-$PROTOC_ARCH.zip
curl --retry 3 --retry-max-time 90 -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -OL https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
rm -f $PROTOC_ZIP
echo "PROTOC=/usr/local/bin/protoc" >> $GITHUB_ENV
echo "PROTOC_INCLUDE=/usr/local/include" >> $GITHUB_ENV
- name: check MSRV
if: matrix.os != 'windows-latest'
run: |
cargo +$MSRV check --all-targets
- name: check MSRV
if: matrix.os == 'windows-latest'
run: |
cargo +$Env:MSRV check --all-targets
- name: check
run: |
cargo check --all-targets
- name: clippy
run: |
cargo clippy --all-targets -- -D warnings
- name: docs
env:
RUSTDOCFLAGS: -Dwarnings
run: |
cargo doc --no-deps --document-private-items
- name: tests
timeout-minutes: 30
run: |
cargo test --lib --bins --tests --examples
fmt:
name: Rustfmt
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
audit:
name: audit
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- uses: actions-rs/cargo@v1
with:
command: install
args: --force cargo-audit
- uses: actions-rs/cargo@v1
with:
command: generate-lockfile
- uses: actions-rs/cargo@v1
with:
command: audit