-
Notifications
You must be signed in to change notification settings - Fork 6
233 lines (202 loc) · 8 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
name: CI
on:
schedule:
- cron: '0 0 * * 0'
push:
branches:
- master
tags:
- 'v[0-9]+.[0-9]+.[0-9]+**'
pull_request:
env:
BIN_TARGET: snowchains
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 --all -- --check`'
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
build:
strategy:
fail-fast: false
matrix:
name:
- stable-x86_64-pc-windows-msvc
- stable-x86_64-apple-darwin
- stable-x86_64-unknown-linux-gnu
- stable-x86_64-unknown-linux-musl
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-latest }
- { name: stable-x86_64-apple-darwin , channel: stable, target-triple: x86_64-apple-darwin , host-triple: x86_64-apple-darwin , os: macos-latest }
- { 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: stable-x86_64-unknown-linux-musl, channel: stable, target-triple: x86_64-unknown-linux-musl, 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
- name: '`sudo apt-get install musl-tools`'
run: sudo apt-get install musl-tools
if: matrix.target-triple == 'x86_64-unknown-linux-musl'
- name: 'Setup `${{ matrix.channel }}-${{ matrix.host-triple }}` (target: `${{ matrix.target-triple }}`)'
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.channel }}-${{ matrix.host-triple }}
target: ${{ matrix.target-triple }}
default: true
profile: minimal
components: clippy
- name: '`cargo clippy --workspace --all-targets --target ${{ matrix.target-triple }} -- -D warnings`'
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --all-targets --target ${{ matrix.target-triple }} -- -D warnings
if: matrix.channel == 'stable'
- name: Determine `cargo test` targets
id: cargo_test_targets
run: |
if ${{ !!secrets }}; then
echo '::set-output name=targets::--workspace --all-targets'
else
echo '::set-output name=targets::--workspace --lib --test batch'
fi
shell: bash
- name: '`cargo test --no-fail-fast ${{ steps.cargo_test_targets.outputs.targets }} --target ${{ matrix.target-triple }}`'
uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast ${{ steps.cargo_test_targets.outputs.targets }} --target ${{ matrix.target-triple }}
env:
RUST_BACKTRACE: full
ATCODER_USERNAME: ${{ secrets.ATCODER_USERNAME }}
ATCODER_PASSWORD: ${{ secrets.ATCODER_PASSWORD }}
DROPBOX_ACCESS_TOKEN: ${{ secrets.DROPBOX_ACCESS_TOKEN }}
CODEFORCES_USERNAME: ${{ secrets.CODEFORCES_USERNAME }}
CODEFORCES_PASSWORD: ${{ secrets.CODEFORCES_PASSWORD }}
CODEFORCES_API_KEY: ${{ secrets.CODEFORCES_API_KEY }}
CODEFORCES_API_SECRET: ${{ secrets.CODEFORCES_API_SECRET }}
YUKICODER_REVEL_SESSION: ${{ secrets.YUKICODER_REVEL_SESSION }}
upload:
strategy:
fail-fast: false
matrix:
target-triple:
- x86_64-pc-windows-msvc
- x86_64-apple-darwin
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
include:
- { target-triple: x86_64-pc-windows-msvc , host-triple: x86_64-pc-windows-msvc , os: windows-latest }
- { target-triple: x86_64-apple-darwin , host-triple: x86_64-apple-darwin , os: macos-latest }
- { target-triple: x86_64-unknown-linux-gnu , host-triple: x86_64-unknown-linux-gnu, os: ubuntu-18.04 }
- { target-triple: x86_64-unknown-linux-musl, 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: '`sudo apt-get install musl-tools`'
run: sudo apt-get install musl-tools
if: matrix.target-triple == 'x86_64-unknown-linux-musl'
- 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 --path . --target ${{ matrix.target-triple }} -v --locked`'
uses: actions-rs/cargo@v1
with:
command: install
args: --path . --target ${{ matrix.target-triple }} -v --locked
- name: '`cargo build --release --target ${{ matrix.target-triple }}`'
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target-triple }}
- name: Create an asset
id: asset
run: |
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 }}
publish:
name: Publish
runs-on: ubuntu-18.04
needs: [release]
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
- name: '`cargo publish --token "$CRATES_IO_TOKEN"` --allow-dirty -v'
uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CRATES_IO_TOKEN }} --allow-dirty -v
# https://github.com/sunng87/cargo-release/issues/195
#- name: '`cargo install --debug cargo-release`'
# uses: actions-rs/cargo@v1
# with:
# command: install
# args: --debug cargo-release
#
#- name: '`cargo release --workspace --skip-push --skip-tag --no-dev-version --token "$CRATES_IO_TOKEN" --no-confirm`'
# uses: actions-rs/cargo@v1
# with:
# command: release
# args: --workspace --skip-push --skip-tag --no-dev-version --token ${{ secrets.CRATES_IO_TOKEN }} --no-confirm