-
Notifications
You must be signed in to change notification settings - Fork 6
244 lines (212 loc) · 7.87 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
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
name: CI
on:
schedule:
- cron: '0 0 * * 0'
push:
branches:
- master
- staging
- trying
tags:
- 'v[0-9]+.[0-9]+.[0-9]+**'
pull_request:
jobs:
rustfmt:
name: Rustfmt
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup `stable-x86_64-unknown-linux-gnu`
uses: actions-rs/toolchain@v1
with:
toolchain: stable-x86_64-unknown-linux-gnu
default: true
profile: minimal
components: rustfmt
- name: cargo-fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
grcov:
name: grcov
runs-on: ubuntu-18.04
if: "github.repository_owner == 'qryxip' && github.ref == 'refs/heads/master'"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install `nightly-x86_64-unknown-linux-gnu`
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: cargo-test
uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast --workspace --features snowchains_core/__test_with_credentials
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off'
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off'
RUST_BACKTRACE: full
ATCODER_USERNAME: ${{ secrets.ATCODER_USERNAME }}
ATCODER_PASSWORD: ${{ secrets.ATCODER_PASSWORD }}
CODEFORCES_USERNAME: ${{ secrets.CODEFORCES_USERNAME }}
CODEFORCES_PASSWORD: ${{ secrets.CODEFORCES_PASSWORD }}
- name: grcov
id: grcov
uses: actions-rs/[email protected]
- name: Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ${{ steps.grcov.outputs.report }}
build:
strategy:
fail-fast: false
matrix:
name:
- stable-x86_64-pc-windows-msvc
- stable-x86_64-apple-darwin
- stable-x86_64-unknown-linux-gnu
include:
- { name: stable-x86_64-pc-windows-msvc , channel: stable, target-triple: x86_64-pc-windows-msvc , host-triple: x86_64-pc-windows-msvc , os: windows-2019 }
- { name: stable-x86_64-apple-darwin , channel: stable, target-triple: x86_64-apple-darwin , host-triple: x86_64-apple-darwin , os: macos-10.15 }
- { name: stable-x86_64-unknown-linux-gnu , channel: stable, target-triple: x86_64-unknown-linux-gnu , host-triple: x86_64-unknown-linux-gnu, os: ubuntu-18.04 }
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
# Workaround for https://github.com/actions/cache/issues/403
- name: Install GNU tar
run: |
brew install gnu-tar
echo "PATH=/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV
if: matrix.os == 'macos-10.15'
- name: 'Setup `${{ matrix.channel }}-${{ matrix.host-triple }}` (target: `${{ matrix.target-triple }}`)'
id: install-toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.channel }}-${{ matrix.host-triple }}
target: ${{ matrix.target-triple }}
default: true
profile: minimal
components: clippy
- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/git
~/.cargo/registry
./target
key: build-${{ matrix.name }}-${{ steps.install-toolchain.outputs.rustc_hash }}-${{ hashFiles('./**/Cargo.*') }}
- name: cargo-clippy (without `snowchains_core/__test_with_credentials`)
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --all-targets --target ${{ matrix.target-triple }} -- -D warnings
- name: cargo-clippy (with `snowchains_core/__test_with_credentials`)
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --all-targets --features snowchains_core/__test_with_credentials --target ${{ matrix.target-triple }} -- -D warnings
- name: Determine `cargo test` features
id: cargo-test-features
run: |
if ${{ !!secrets.ATCODER_USERNAME }}; then
echo '::set-output name=features::--features snowchains_core/__test_with_credentials'
else
echo '::set-output name=features::'
fi
shell: bash
- name: cargo-test
uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast --workspace ${{ steps.cargo-test-features.outputs.features }} --target ${{ matrix.target-triple }}
env:
RUST_BACKTRACE: full
ATCODER_USERNAME: ${{ secrets.ATCODER_USERNAME }}
ATCODER_PASSWORD: ${{ secrets.ATCODER_PASSWORD }}
CODEFORCES_USERNAME: ${{ secrets.CODEFORCES_USERNAME }}
CODEFORCES_PASSWORD: ${{ secrets.CODEFORCES_PASSWORD }}
upload:
strategy:
fail-fast: false
matrix:
target-triple:
- x86_64-pc-windows-msvc
- x86_64-apple-darwin
- x86_64-unknown-linux-gnu
include:
- { target-triple: x86_64-pc-windows-msvc , host-triple: x86_64-pc-windows-msvc , os: windows-2019 }
- { target-triple: x86_64-apple-darwin , host-triple: x86_64-apple-darwin , os: macos-10.15 }
- { target-triple: x86_64-unknown-linux-gnu , host-triple: x86_64-unknown-linux-gnu, os: ubuntu-18.04 }
name: Upload (${{ matrix.target-triple }})
runs-on: ${{ matrix.os }}
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: 'Setup `stable-${{ matrix.host-triple }}` (target: `${{ matrix.target-triple }}`)'
uses: actions-rs/toolchain@v1
with:
toolchain: stable-${{ matrix.host-triple }}
target: ${{ matrix.target-triple }}
default: true
profile: minimal
- name: cargo-install
uses: actions-rs/cargo@v1
with:
command: install
args: --path . --target ${{ matrix.target-triple }} -v --locked
- name: cargo-build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target-triple }}
- name: Create an asset
id: asset
run: |
BIN_TARGET=snowchains
if ${{ contains(matrix.target-triple, 'pc-windows') }}; then
DOT_EXE=.exe
fi
ASSET_STEM="$BIN_TARGET-${GITHUB_REF#refs/tags/}-${{ matrix.target-triple }}"
git archive -o "./$ASSET_STEM.tar" --prefix "$ASSET_STEM/" HEAD
tar -xf "./$ASSET_STEM.tar"
mv "$HOME/.cargo/bin/$BIN_TARGET$DOT_EXE" "./$ASSET_STEM/"
if ${{ contains(matrix.target-triple, 'pc-windows') }}; then
ASSET="$ASSET_STEM.zip"
7z a "$ASSET" "./$ASSET_STEM"
zipinfo "./$ASSET"
else
ASSET="$ASSET_STEM.tar.gz"
tar -czvf "./$ASSET" "./$ASSET_STEM"
fi
echo "::set-output name=asset::$ASSET"
shell: bash
- name: Upload the artifact
uses: actions/upload-artifact@v2
with:
name: assets
path: ${{ steps.asset.outputs.asset }}
release:
name: GitHub Release
runs-on: ubuntu-18.04
needs: [rustfmt, build, upload]
steps:
- name: Download the assets
uses: actions/download-artifact@v2
with:
name: assets
path: ./assets
- name: GH Release
uses: softprops/action-gh-release@v1
with:
files: ./assets/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}