-
Notifications
You must be signed in to change notification settings - Fork 5
223 lines (191 loc) · 6.81 KB
/
test.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
name: Test Changes
on:
push:
paths-ignore:
- "README.md"
jobs:
code-quality:
name: Code Quality
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: cache ~/.cargo
uses: Swatinem/rust-cache@v2
- name: rustup install
uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
components: clippy, rustfmt
override: true
- name: install protoc
run: |
Invoke-WebRequest -OutFile /tmp/protoc.zip -Uri https://github.com/protocolbuffers/protobuf/releases/download/v3.20.2/protoc-3.20.2-linux-x86_64.zip
Expand-Archive /tmp/protoc.zip -DestinationPath ../tools
Add-Content -Path $env:GITHUB_PATH -Value "$((get-item ./).parent.fullname)/tools/bin"
Get-Content $env:GITHUB_PATH
shell: pwsh
- name: cargo clippy
uses: actions-rs/cargo@v1.0.3
with:
command: clippy
args: --all-targets --all-features
- name: cargo fmt --check
uses: actions-rs/cargo@v1.0.3
with:
command: fmt
args: --check --all
test-platforms:
name: ${{ matrix.os }}-${{ matrix.arch }}-test
runs-on: ${{ matrix.run_on }}
continue-on-error: ${{ matrix.experimental || false }}
permissions:
id-token: write
contents: read
strategy:
matrix:
include:
- arch: amd64
os: windows
run_on: windows-latest
target: x86_64-pc-windows-msvc
extension: .exe
- arch: amd64
run_on: ubuntu-latest
os: linux
target: x86_64-unknown-linux-gnu
coverage: true
setup: |
sudo apt-get update
sudo apt-get install -y libdbus-1-3 libdbus-1-dev
# - arch: "386"
# os: linux
# run_on: ubuntu-20.04
# target: i686-unknown-linux-gnu
# experimental: true
# skiptests: true
# setup: |
# sudo apt-get update
# sudo apt-get install -y libdbus-1-3 libdbus-1-dev
- arch: "arm64"
os: linux
run_on: ubuntu-latest
target: aarch64-unknown-linux-gnu
experimental: true
skiptests: true
setup: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu lld
# Ensure that the libgcc library can be found
sudo ln -s /usr/aarch64-linux-gnu/lib/libgcc_s.so.1 /usr/aarch64-linux-gnu/lib/libgcc_s.so
flags: --no-default-features
- arch: amd64
run_on: macos-latest
os: darwin
target: x86_64-apple-darwin
- arch: arm64
run_on: macos-latest
os: darwin
target: aarch64-apple-darwin
experimental: true
skiptests: true
steps:
- name: setup dependencies
run: ${{ matrix.setup }}
if: matrix.setup
- uses: actions/checkout@v4
- name: rustup install nightly
uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
profile: minimal
target: ${{ matrix.target }}
override: true
components: llvm-tools-preview
- name: cache ~/.cargo
uses: Swatinem/rust-cache@v2
- name: install protoc
run: |
if ('${{ matrix.os }}' -eq 'windows') {
$protoc_arch = 'win64'
} elseif ('${{ matrix.os }}' -eq 'darwin') {
$protoc_arch = 'osx-x86_64'
} else {
$protoc_arch = 'linux-x86_64'
}
$protoc_url = "https://github.com/protocolbuffers/protobuf/releases/download/v3.20.2/protoc-3.20.2-$protoc_arch.zip"
Write-Host "Downloading protoc from '$protoc_url'"
Invoke-WebRequest -OutFile protoc.zip -Uri $protoc_url
Expand-Archive protoc.zip -DestinationPath ../tools
Add-Content -Path $env:GITHUB_PATH -Value "$((Get-Item ./).Parent.FullName)/tools/bin"
shell: pwsh
- name: git config
run: |
git config --global init.defaultBranch "main"
- name: cargo build
uses: actions-rs/cargo@v1.0.3
if: matrix.skiptests
with:
command: build
args: --target ${{ matrix.target }} ${{ matrix.flags }}
- name: cargo test
uses: actions-rs/cargo@v1.0.3
if: "!matrix.skiptests"
with:
command: test
args: --no-fail-fast --target ${{ matrix.target }} ${{ matrix.flags }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUSTFLAGS: "-C instrument_coverage"
LLVM_PROFILE_FILE: default.profraw
- name: install rustfilt
uses: actions-rs/cargo@v1.0.3
if: matrix.coverage || false
with:
command: install
args: rustfilt
- name: prepare coverage output
if: matrix.coverage || false
shell: pwsh
run: |
Write-Host "Merging raw profile output files"
&"$(rustc --print target-libdir)/../bin/llvm-profdata" merge -sparse default.profraw -o default.profdata
$latest_asset = Get-ChildItem -Path ./target/${{ matrix.target }}/debug/deps -Filter "git_tool-*" -File `
| Where-Object { $_.Name.EndsWith(".exe") -or (-not $_.Name.Contains(".")) } `
| Sort-Object -Top 1 -Property LastWriteTime
Write-Host "Latest Asset: $latest_asset"
Write-Host "Exporting LCOV coverage report"
&"$(rustc --print target-libdir)/../bin/llvm-cov" export -instr-profile default.profdata $latest_asset `
-Xdemangler=rustfilt `
-ignore-filename-regex='.cargo|rustc' `
-compilation-dir=src `
-format=lcov > lcov.info
- name: get secrets - codecov
uses: hashicorp/vault-action@v3.0.0
if: matrix.coverage || false
with:
url: https://vault.sierrasoftworks.com
method: jwt
path: github-actions
role: pull_request
jwtGithubAudience: https://vault.sierrasoftworks.com
secrets: |
secrets/data/repos/SierraSoftworks/git-tool/public/codecov token | CODECOV_TOKEN;
- name: codecov upload
uses: codecov/codecov-action@v4
if: matrix.coverage || false
with:
token: ${{ env.CODECOV_TOKEN }}
# - uses: anchore/sbom-action@v0
# with:
# file: "target/${{ matrix.target }}/debug/git-tool${{ matrix.extension }}"
# format: 'spdx-json'
# output-file: 'sbom.spdx.json'
# upload-artifact: false
test-done:
name: Tests Complete
needs:
- test-platforms
- code-quality
runs-on: ubuntu-20.04
steps:
- run: echo "Tests Complete for All Platforms"