-
Notifications
You must be signed in to change notification settings - Fork 52
252 lines (215 loc) · 8.41 KB
/
actions.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
245
246
247
248
249
250
251
252
name: build
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
RUST_MIN_STACK: 16777212
permissions: {}
jobs:
build:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
include:
- platform: ubuntu-latest
artifact-path: target/release/fend
artifact-platform-name: linux-x64
env-command: ">> $GITHUB_ENV"
- platform: macos-latest
artifact-path: target/release/fend
artifact-platform-name: macos-x64
env-command: ">> $GITHUB_ENV"
- platform: windows-latest
artifact-path: target/release/fend.exe
artifact-platform-name: windows-x64-exe
env-command: "| Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append"
permissions:
contents: read
runs-on: ${{ matrix.platform }}
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- name: Update Rust
run: rustup update
- uses: swatinem/rust-cache@v2
- name: Clippy, rustfmt
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
rustup component add clippy
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo fmt -- --check
- name: Build, get version
run: |
cargo run --release --package fend -- help
echo "FEND_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages | .[0].version')" ${{ matrix.env-command }}
# Only run unit tests on non-Linux platforms since Linux runs
# them as part of code coverage testing
- name: Test
if: ${{ matrix.platform != 'ubuntu-latest' }}
run: |
cargo test --workspace -- --nocapture --quiet
- name: Generate code coverage
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
RUSTFLAGS="-C instrument-coverage" \
cargo test --workspace -- --quiet
sudo apt-get update -y
sudo apt-get install -yq llvm
llvm-profdata merge -sparse */*.profraw -o fend.profdata
llvm-cov report \
--use-color \
--ignore-filename-regex='/.cargo/registry' \
--ignore-filename-regex='/rustc' \
--instr-profile=fend.profdata \
$( \
for file in \
$( \
RUSTFLAGS="-C instrument-coverage" \
cargo test --workspace --no-run --message-format=json \
| jq -r "select(.profile.test == true) | .filenames[]" \
| grep -v dSYM - \
); \
do \
printf "%s %s " -object $file; \
done \
)
llvm-cov export \
--ignore-filename-regex='/.cargo/registry' \
--ignore-filename-regex='/rustc' \
--format='lcov' \
--instr-profile=fend.profdata \
$( \
for file in \
$( \
RUSTFLAGS="-C instrument-coverage" \
cargo test --workspace --no-run --message-format=json \
| jq -r "select(.profile.test == true) | .filenames[]" \
| grep -v dSYM - \
); \
do \
printf "%s %s " -object $file; \
done \
) >coverage.txt
- name: Upload to codecov.io
if: ${{ matrix.platform == 'ubuntu-latest' }}
uses: codecov/codecov-action@v3
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: fend-${{ env.FEND_VERSION }}-${{ matrix.artifact-platform-name }}
path: ${{ matrix.artifact-path }}
if-no-files-found: error
- name: Build (Apple Silicon)
if: ${{ matrix.platform == 'macos-latest' }}
run: |
rustup target add aarch64-apple-darwin
cargo build --release --package fend --target aarch64-apple-darwin
- name: Upload artifacts (Apple Silicon)
uses: actions/upload-artifact@v3
if: ${{ matrix.platform == 'macos-latest' }}
with:
name: fend-${{ env.FEND_VERSION }}-macos-aarch64
path: target/aarch64-apple-darwin/release/fend
if-no-files-found: error
- name: Build (linux-armv7-gnueabihf)
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
rustup target add armv7-unknown-linux-gnueabihf
sudo apt-get install -yq gcc-arm-linux-gnueabihf
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=/usr/bin/arm-linux-gnueabihf-gcc
cargo build --release --package fend --target armv7-unknown-linux-gnueabihf
- name: Upload artifacts (linux-armv7-gnueabihf)
uses: actions/upload-artifact@v3
if: ${{ matrix.platform == 'ubuntu-latest' }}
with:
name: fend-${{ env.FEND_VERSION }}-linux-armv7-gnueabihf
path: target/armv7-unknown-linux-gnueabihf/release/fend
if-no-files-found: error
- name: Build (linux-aarch64-gnu)
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
rustup target add aarch64-unknown-linux-gnu
sudo apt-get install -yq gcc-aarch64-linux-gnu
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc
cargo build --release --package fend --target aarch64-unknown-linux-gnu
- name: Upload artifacts (linux-aarch64-gnu)
uses: actions/upload-artifact@v3
if: ${{ matrix.platform == 'ubuntu-latest' }}
with:
name: fend-${{ env.FEND_VERSION }}-linux-aarch64-gnu
path: target/aarch64-unknown-linux-gnu/release/fend
if-no-files-found: error
- name: Set up Homebrew
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
- name: Build fend-wasm
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
brew install pandoc
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
./web/build.sh
- name: Upload GitHub Pages artifact
if: ${{ matrix.platform == 'ubuntu-latest' }}
uses: actions/upload-pages-artifact@v1
with:
path: web
- name: Build man page
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
./documentation/build.sh
- name: Upload man page
if: ${{ matrix.platform == 'ubuntu-latest' }}
uses: actions/upload-artifact@v3
with:
name: man-page
path: documentation/fend.1
if-no-files-found: error
- name: Build MSIX installer
if: ${{ github.ref == 'refs/heads/main' && matrix.platform == 'windows-latest' }}
run: |
.\windows-msix\build.ps1
env:
WINDOWS_CERT_PASSWORD: ${{ secrets.WINDOWS_CERT_PASSWORD }}
- name: Upload artifacts (MSIX)
uses: actions/upload-artifact@v3
if: ${{ github.ref == 'refs/heads/main' && matrix.platform == 'windows-latest' }}
with:
name: fend-windows-x64-msix
path: windows-msix/fend-windows-x64.msix
if-no-files-found: error
- name: Build MSI installer
if: ${{ matrix.platform == 'windows-latest' }}
run: |
.\windows-wix\build.ps1
- name: Upload artifacts (MSI)
uses: actions/upload-artifact@v3
if: ${{ matrix.platform == 'windows-latest' }}
with:
name: fend-windows-x64-msi
path: windows-wix/build/fend-windows-x64.msi
if-no-files-found: error
- name: Deploy Telegram Bot
if: ${{ github.ref == 'refs/heads/main' && matrix.platform == 'ubuntu-latest' }}
run: |
./telegram-bot/build.sh
TELEGRAM_BOT_API_TOKEN=${{ secrets.TELEGRAM_BOT_API_TOKEN }} \
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
./telegram-bot/deploy.sh
deploy:
runs-on: ubuntu-latest
needs: [build]
if: ${{ github.ref == 'refs/heads/main' }}
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1