-
Notifications
You must be signed in to change notification settings - Fork 9
228 lines (185 loc) · 6.72 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
name: CI
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0 1 * *' # Monthly
env:
RUN_SLOW_TESTS: 1
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019]
rust: [stable, beta]
configuration: [debug, release]
cross: [false, true]
exclude:
- configuration: release
rust: beta
- cross: true
os: windows-2019
include:
- os: ubuntu-20.04
cross: false
label: Ubuntu
target: i686-unknown-linux-gnu
filename: libbxt_rs.so
- os: ubuntu-20.04
cross: true
label: Debian (cross to Windows)
target: i686-pc-windows-gnu
filename: bxt_rs.dll
cross-dep: gcc-mingw-w64-i686
# MinGW on Ubuntu fails to link, so use rust:latest which is based on Debian.
container: rust:latest
- os: windows-2019
label: Windows
target: i686-pc-windows-msvc
filename: bxt_rs.dll
- configuration: release
release-flag: '--release'
name: ${{ matrix.rust }} - ${{ matrix.label }} - ${{ matrix.configuration }}
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@v3
with:
# We need the full history to find the tag
fetch-depth: 0
# Containers have wrong permissions for the folder, so git freaks out.
# https://github.com/actions/runner/issues/2033
- if: job.container
run: chown -R $(id -u):$(id -g) .
# We need the tags for the version string inside bxt-rs
- run: git fetch --force --tags
# Install sudo so that the subsequent steps are the same between container and no container.
- name: Install sudo
if: job.container
run: |
apt-get update -y
apt-get install sudo -y
- name: Install dependencies
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get update -y
sudo apt-get install -y libc6-dev-i386 ${{ matrix.cross-dep }}
- name: Install Rust
run: |
rustup set auto-self-update check-only
rustup toolchain install ${{ matrix.rust }} --profile minimal
rustup override set ${{ matrix.rust }}
rustup target add ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.configuration }}-${{ matrix.cross }}
- name: Build
run: cargo build --target ${{ matrix.target }} ${{ matrix.release-flag }}
- name: Build Tests
# Testing cross-compiled build requires wine which is large. We test native Windows anyway so no need.
if: |
!matrix.cross
run: cargo test --no-run --all --target ${{ matrix.target }} ${{ matrix.release-flag }}
- name: Test
# Testing cross-compiled build requires wine which is large. We test native Windows anyway so no need.
if: |
!matrix.cross
run: cargo test --all --target ${{ matrix.target }} ${{ matrix.release-flag }} -- --nocapture
- uses: actions/upload-artifact@v3
if: matrix.rust == 'stable' && !matrix.cross
with:
name: bxt-rs-${{ runner.os }}-${{ matrix.configuration }}
path: target/${{ matrix.target }}/${{ matrix.configuration }}/${{ matrix.filename }}
if-no-files-found: error
- name: Prepare Release
if: startsWith(github.ref, 'refs/tags/') && matrix.rust == 'stable' && matrix.configuration == 'release' && !matrix.cross
run: |
cp target/${{ matrix.target }}/${{ matrix.configuration }}/${{ matrix.filename }} ${{ matrix.filename }}
7z a bxt-rs-${{ runner.os }}.7z ${{ matrix.filename }} COPYING
- name: Release
if: startsWith(github.ref, 'refs/tags/') && matrix.rust == 'stable' && matrix.configuration == 'release' && !matrix.cross
uses: softprops/action-gh-release@v1
with:
files: bxt-rs-${{ runner.os }}.7z
draft: true
fail_on_unmatched_files: true
- name: Generate Wiki Page
if: >
github.event_name == 'push' &&
github.ref == 'refs/heads/master' &&
matrix.os == 'ubuntu-20.04' &&
matrix.rust == 'stable' &&
matrix.configuration == 'release' &&
!matrix.cross
run: |
mkdir temp_wiki_output
cargo run --target ${{ matrix.target }} --release --bin gen-wiki > temp_wiki_output/Features.md
- name: Upload Wiki Page Artifact
uses: actions/upload-artifact@v3
if: >
github.event_name == 'push' &&
github.ref == 'refs/heads/master' &&
matrix.os == 'ubuntu-20.04' &&
matrix.rust == 'stable' &&
matrix.configuration == 'release' &&
!matrix.cross
with:
name: wiki
path: temp_wiki_output/
clippy:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
label: Ubuntu
target: i686-unknown-linux-gnu
- os: windows-2019
label: Windows
target: i686-pc-windows-msvc
name: clippy - ${{ matrix.label }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install dependencies
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get install libc6-dev-i386
- name: Install Rust
run: |
rustup set auto-self-update check-only
rustup toolchain install stable --profile minimal --component clippy
rustup target add ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Run clippy
run: cargo clippy --all --all-targets --target ${{ matrix.target }}
rustfmt:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Install Rust
run: |
rustup set auto-self-update check-only
rustup toolchain install nightly --profile minimal --component rustfmt
rustup override set nightly
- name: Run rustfmt
run: cargo fmt --all -- --check
publish-wiki:
name: Publish Wiki
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [build, clippy, rustfmt]
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@v3
with:
name: wiki
path: temp_wiki_output/
- run: ls --recursive temp_wiki_output/
- uses: SwiftDocOrg/github-wiki-publish-action@v1
with:
path: temp_wiki_output/
env:
GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}