forked from pyrsia/pyrsia
-
Notifications
You must be signed in to change notification settings - Fork 0
349 lines (301 loc) · 13.2 KB
/
rust.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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
---
name: Rust
on:
push:
branches: [main]
pull_request:
paths: # Make sure to keep sync'd https://github.com/pyrsia/pyrsia/blob/main/.github/workflows/rust-skipped.yml#L8
- .github/workflows/rust.yml
- '**/*.rs'
- '**/Cargo.toml'
- Cargo.lock
- 'installers/**'
release:
types: [published]
env:
CARGO_TERM_COLOR: always
jobs:
# OS/X Build Job
build-osx:
permissions:
contents: 'read'
id-token: 'write'
runs-on: macos-12
env:
RUSTC_WRAPPER: /Users/runner/.cargo/bin/sccache
CARGO_INCREMENTAL: 0
steps:
- uses: actions/checkout@v3
# Use sscache store in GitHub cache
- uses: actions/cache@v3
with:
path: /Users/runner/Library/Caches/Mozilla.sccache
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# Install sccache from binary
- name: Start sccache
run: |
.github/workflows/sccache-macos.sh
sccache --start-server
sccache --show-stats
- uses: pyrsia/rust-toolchain@v2
with:
packages: set-cargo-version
# Need to add build number to version number
- id: add-fqbvn-and-export
name: Add Build Number to Version Number and Export to Output
# if: github.repository_owner == 'pyrsia' && github.event_name == 'push' && github.event.pull_request.merged == true
run: |
set-cargo-version Cargo.toml ${{ env.PKG_VERSION }}+${{ github.run_number }}
echo "TAG_NAME=${{ env.PKG_VERSION }}+${{ github.run_number }}" >> $GITHUB_OUTPUT
shell: /bin/zsh -e {0}
- name: Build Release and Test Binaries
run: |
.github/workflows/build.sh
sccache --show-stats
- name: Execute Test Cases
run: |
cargo test --workspace --verbose --release
# Creates installer archive of pyrsia and pyrsia_node
- id: generate-homebrew-archives
name: Create Pyrsia Homebrew archives
run: |
tar -C target/release -czf pyrsia-${{ steps.add-fqbvn-and-export.outputs.TAG_NAME }}.tar.gz pyrsia pyrsia_node
shell: /bin/zsh -e {0}
- id: build-osx-google-auth
name: Google Auth
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
uses: 'google-github-actions/auth@v1'
with:
workload_identity_provider: 'projects/679352079717/locations/global/workloadIdentityPools/pyrsia-pool/providers/github-provider'
service_account: '[email protected]'
- id: build-osx-setup-cloud-sdk
name: Set up Cloud SDK
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
uses: 'google-github-actions/setup-gcloud@v1'
- id: build-osx-install-crcmod-gsutil-version-info
name: 'Install crcmod and gsutil version info'
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
run: |
pip3 install -U crcmod
gsutil version -l
gcloud info
shell: /bin/zsh -e {0}
# Publish nightly version of installer archive to cloud bucket
- id: build-osx-publish-nightly-gcs-repo
name: Publish Build to NIGHTLY GCS repo
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
run: |
.github/workflows/homebrew-installer-upload.sh ${{ steps.add-fqbvn-and-export.outputs.TAG_NAME }} latest x86_64
shell: /bin/zsh -e {0}
env:
GPG_KEY: ${{ secrets.GPG_KEY }}
# Publish stable version of installer archive to cloud bucket
- id: build-osx-publish-stable-gcs-repo
name: Publish Release to STABLE GCS repo
if: github.repository_owner == 'pyrsia' && github.event_name == 'release'
run: |
.github/workflows/homebrew-installer-upload.sh ${{ steps.add-fqbvn-and-export.outputs.TAG_NAME }} stable x86_64
shell: /bin/zsh -e {0}
env:
GPG_KEY: ${{ secrets.GPG_KEY }}
# Windows Build Job
build-windows:
runs-on: windows-2022
env:
RUSTC_WRAPPER: C:\Users\runneradmin\.cargo\bin\sccache.exe
CARGO_INCREMENTAL: 0
steps:
- uses: actions/checkout@v3
# Use sscache store in GitHub cache
- uses: actions/cache@v3
with:
path: C:/Users/runneradmin/AppData/Local/Mozilla/sccache/cache
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# Install and start sccache from binary
- name: Start sccache
run: |
.github/workflows/sccache-windows.bat
sccache --start-server
sccache --show-stats
- uses: pyrsia/rust-toolchain@v2
with:
packages: set-cargo-version
# Need to add build number to version number
- name: Add Build to Version Number
run: |
set-cargo-version Cargo.toml ${{ env.PKG_VERSION }}+${{ github.run_number }}
- name: Build Release and Test Binaries
shell: bash
run: |
.github/workflows/build.sh
sccache --show-stats
- name: Execute Test Cases
run: |
cargo test --workspace --verbose --release
# Create installers
- name: Create MSIs
shell: bash
# todo: uncomment: if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
env:
WIX_PATH_CANDLE: "C:/Program Files (x86)/WiX Toolset v3.11/bin/candle.exe"
WIX_PATH_LIGHT: "C:/Program Files (x86)/WiX Toolset v3.11/bin/light.exe"
run: |
cd installers/windows
"$WIX_PATH_CANDLE" -ext WixUIExtension -ext WixUtilExtension installer.wxs
"$WIX_PATH_LIGHT" -ext WixUIExtension -ext WixUtilExtension installer.wixobj -out pyrsia.msi
"$WIX_PATH_CANDLE" -ext WixUIExtension -ext WixUtilExtension installerps1.wxs
"$WIX_PATH_LIGHT" -ext WixUIExtension -ext WixUtilExtension installerps1.wixobj -out pyrsia_service.msi
cd ../..
# for now, upload installers
- name: Upload Installer
uses: actions/upload-artifact@v3
with:
name: windows-installer
path: ${{ github.workspace }}/installers/windows/pyrsia.msi
- name: Upload Installer_with_Service
uses: actions/upload-artifact@v3
with:
name: windows-installer-with-service
path: ${{ github.workspace }}/installers/windows/pyrsia_service.msi
build-push-linux:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-20.04
env:
RUSTC_WRAPPER: /home/runner/.cargo/bin/sccache
CARGO_INCREMENTAL: 0
steps:
- uses: actions/checkout@v3
# Use sscache store in GitHub cache
- uses: actions/cache@v3
with:
path: /home/runner/.cache/sccache
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# Install and start sccache from binary
- name: Start sccache
run: |
.github/workflows/sccache-linux.sh
sccache --start-server
sccache --show-stats
- uses: pyrsia/rust-toolchain@v2
with:
packages: cargo-deb set-cargo-version
# Need to add build number to version number
- name: Add Build to Version Number
run: |
set-cargo-version Cargo.toml ${{ env.PKG_VERSION }}+${{ github.run_number }}
# Run cargo build in parallel using sscache to avoid OS locking errors
- name: Build Release and Test Binaries
run: |
.github/workflows/build.sh
sccache --show-stats
- name: Execute Test Cases
run: |
cargo test --workspace --verbose --release
# Create Pyrsia .deb file
- name: Package Pyrsia as deb file
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
run: |
cargo deb --no-build -v
# Login to GCS
- name: Google Auth
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
uses: 'google-github-actions/auth@v1'
with:
workload_identity_provider: 'projects/679352079717/locations/global/workloadIdentityPools/pyrsia-pool/providers/github-provider'
service_account: '[email protected]'
# Add gsutils
- name: Set up Cloud SDK
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
uses: 'google-github-actions/setup-gcloud@v1'
# Add the prysia .deb file to the NIGHTLY apt repo which resides on GCS
- name: Publish Build to NIGHTLY GCS repo
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
run: |
.github/workflows/aptly.sh target/debian/pyrsia_${{ env.PKG_VERSION }}+${{ github.run_number }}_amd64.deb nightly
env:
GPG_KEY: ${{ secrets.GPG_KEY }}
# Add the prysia .deb file to the STABLE apt repo which resides on GCS
- name: Publish Release to STABLE GCS repo
# Only add to STABLE on publishing of a release
if: github.repository_owner == 'pyrsia' && github.event_name == 'release'
run: |
.github/workflows/aptly.sh target/debian/pyrsia_${{ env.PKG_VERSION }}+${{ github.run_number }}_amd64.deb stable
env:
GPG_KEY: ${{ secrets.GPG_KEY }}
coverage:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: pyrsia/rust-toolchain@v2
with:
packages: cargo-tarpaulin
- name: Run cargo-tarpaulin
run: |
cargo tarpaulin --workspace --lib --bins --tests --benches --out Lcov --output-dir ./coverage
- name: Upload to coveralls.io
id: coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Display coveralls.io link
run: |
echo '${{ steps.coveralls.outputs.coveralls-api-result }}' | jq -r ".url" | xargs echo Reults
# Docker build that uses the published .deb file from the Linux build
docker:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-20.04
needs: [build-push-linux]
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
steps:
- uses: actions/checkout@v3
- uses: pyrsia/rust-toolchain@v2 # Setup toolchain to pull version info from Cargo.toml
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and Push Docker Image for Pyrsia Node
uses: docker/build-push-action@v4
with:
context: .
push: true
file: installers/docker/AptGet.Dockerfile
tags: pyrsiaoss/pyrsia-node:${{ env.PKG_VERSION }}-${{ github.run_number }}
build-args: |
GIT_REPO=${{ github.repository }}
GIT_COMMIT=${{ github.sha }}
GIT_BRANCH=${{ github.ref_name }}
PYRSIA_VERSION=${{ env.PKG_VERSION }}+${{ github.run_number }}
# Update the helm chart values with the image tag
- name: Add Build to Version Number in Chart and Values files
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
run: |
sudo go install github.com/mikefarah/yq/v4@latest
yq e '.image.tag |= "${{ env.PKG_VERSION }}-${{ github.run_number }}"' -i installers/helm/pyrsia-node/values.yaml
yq e '.version |= "${{ env.PKG_VERSION }}+${{ github.run_number }}"' -i installers/helm/pyrsia-node/Chart.yaml
yq e '.appVersion |= "${{ env.PKG_VERSION }}+${{ github.run_number }}"' -i installers/helm/pyrsia-node/Chart.yaml
# Login to GCS
- name: Google Auth
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
uses: 'google-github-actions/auth@v1'
with:
workload_identity_provider: 'projects/679352079717/locations/global/workloadIdentityPools/pyrsia-pool/providers/github-provider'
service_account: '[email protected]'
# Add gsutils
- name: Set up Cloud SDK
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
uses: 'google-github-actions/setup-gcloud@v1'
# Add the updated helm chart to the helm NIGHTLY repo
- name: Add the updated helm chart to the helm NIGHTLY repo
if: github.repository_owner == 'pyrsia' && (github.event_name == 'push' || github.event_name == 'release')
run: |
.github/workflows/chartmuseum.sh nightly
# Add the updated helm chart to the helm STABLE repo
- name: Add the updated helm chart to the helm STABLE repo
if: github.repository_owner == 'pyrsia' && github.event_name == 'release'
run: |
.github/workflows/chartmuseum.sh stable