-
Notifications
You must be signed in to change notification settings - Fork 2
295 lines (271 loc) · 9.15 KB
/
pr.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
name: Pull Request
on:
pull_request:
types:
- opened
- reopened
- synchronize
- closed
push:
tags:
- '*'
jobs:
style:
name: Style
runs-on: ubuntu-latest
container:
image: ghcr.io/tektronix/tsp-toolkit-build:latest
credentials:
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
steps:
- name: Tool Versions
run: cargo fmt --version
- name: Checkout
uses: actions/checkout@v4
- name: Check Style
run: cargo fmt --check --verbose
lint:
name: Lint
runs-on: ubuntu-latest
container:
image: ghcr.io/tektronix/tsp-toolkit-build:latest
credentials:
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
steps:
- name: Tool Versions
run: cargo clippy --version
- name: Checkout
uses: actions/checkout@v4
- name: Lint
run: cargo clippy
sbom:
name: Generate CycloneDX
runs-on: ubuntu-latest
container:
image: ghcr.io/tektronix/tsp-toolkit-build:latest
credentials:
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate Rust BOM
run: cargo cyclonedx --format json --all --describe crate -vvv
- name: Upload Results
uses: actions/upload-artifact@v4
with:
name: software-bom
path: |
**/*.cdx.json
test:
name: Test
runs-on: ubuntu-latest
container:
image: ghcr.io/tektronix/tsp-toolkit-build:latest
credentials:
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
env:
CARGO_HOME: ".cargo"
RUSTFLAGS: "-Cinstrument-coverage -L ./"
TEST_DIR: "test-results"
LLVM_PROFILE_FILE: "../test-results/%p-%m.profraw"
steps:
- name: Tool Versions
run: |
# TODO reinstate after this issue closes: https://github.com/xd009642/tarpaulin/issues/1493
# cargo install cargo-tarpaulin
# cargo tarpaulin --version
cargo --version
grcov --version
- name: Checkout
uses: actions/checkout@v4
- name: Get Latest VISA Stub Release
uses: robinraju/release-downloader@v1
with:
repository: tektronix/libvisa-stub
latest: true
fileName: '*'
- name: List Directory
run: ls -Rl *
- name: Prebuild
run: mkdir -p ${{env.CARGO_HOME}}; cargo build --tests
- name: Run Tests
run: |
mkdir -p "${{env.TEST_DIR}}"
# TODO reinstate after this issue closes: https://github.com/xd009642/tarpaulin/issues/1493
# cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --engine llvm --out xml --output-dir ${{env.TEST_DIR}}
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD" cargo test --all -- -Z unstable-options --format json --report-time > ${{env.TEST_DIR}}/cargo_test.json
# - name: Process Test Results
# run: |
# cat ${{env.TEST_DIR}}/cargo_test.json | cargo2junit > ${{env.TEST_DIR}}/report.xml
# env:
# CARGO_HOME: ".cargo"
# TEST_DIR: "test-results"
- name: Upload Results
uses: actions/upload-artifact@v4
if: ${{always()}}
with:
name: unit-test-report
path: |
${{env.TEST_DIR}}
code_coverage:
name: Code Coverage
runs-on: ubuntu-latest
needs: test
steps:
- name: Download Test Results
uses: actions/download-artifact@v4
with:
name: unit-test-report
path: test-results
- name: Display structure of downloaded files
run: ls -R
- name: Code Coverage Report
uses: irongut/[email protected]
continue-on-error: true
with:
filename: test-results/cobertura.xml
badge: true
format: markdown
hide_branch_rate: true
hide_complexity: true
indicators: true
output: both
thresholds: "30 50"
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
continue-on-error: true
if: github.event_name == 'pull_request'
with:
header: Test Coverage
path: code-coverage-results.md
build:
name: Build
strategy:
matrix:
include:
- runner: ubuntu-latest
triple: x86_64-unknown-linux-gnu
vscode-platform: linux-x64
- runner: windows-latest
triple: x86_64-pc-windows-msvc
vscode-platform: win32-x64
- runner: macos-latest
triple: aarch64-apple-darwin
vscode-platform: darwin-arm64
runs-on: ${{matrix.runner}}
env:
RUSTFLAGS: "-L ${{github.workspace}}"
LIB_VISA_PATH: "${{github.workflow}}"
steps:
- name: Tool Setup
run: rustup update nightly && rustup default nightly
- name: Ensure Correct Target is Installed
run: rustup target add ${{matrix.triple}}
- name: Tool Versions
run: rustc --version
- name: Checkout
uses: actions/checkout@v4
- name: Get Latest VISA Stub Release
uses: robinraju/release-downloader@v1
with:
repository: tektronix/libvisa-stub
latest: true
fileName: '*'
- name: Build LAN-only
run: |
cargo build --verbose --target "${{matrix.triple}}" --release
cargo build --verbose --target "${{matrix.triple}}" --release --tests
- name: Build VISA
if: ${{ matrix.runner != 'macos-latest' }}
run: |
cargo build --verbose --target "${{matrix.triple}}" --release --features "visa"
cargo build --verbose --target "${{matrix.triple}}" --release --tests --features "visa"
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: executable
path: |
target/${{matrix.triple}}/release/kic*
!target/${{matrix.triple}}/**/*.d
!target/${{matrix.triple}}/**/*.rlib
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
checks: write
pull-requests: read
needs:
- build
- lint
- style
- test
- code_coverage
- sbom
if: ${{ (endsWith(github.base_ref, 'main') && (contains(github.head_ref, 'release/')) || github.event.pull_request.merged ) }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Get RC Version
id: lasttag
run: |
apt-get update && apt-get install -yqq jq
COMMIT="${{github.sha}}"
if ${{contains(github.head_ref, 'release/')}}; then
V="${{github.head_ref}}"
V="${V#release/}"
else
V="$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version')"
V=v${V//\"/} #remove '"'s
fi
# Check to see if the version tag already exists
# If it does, print a message and exit with an error code
if [ $(git tag --list "$V") ]; then
echo "Version tag already exists. Did you bump the version number?"
exit 1
fi
# Create an RC release if
# 1) This PR is a release branch that hasn't been merged to main.
# 2) This is a feature branch being merged into the main branch.
if ${{(! github.event.pull_request.merged && contains(github.head_ref, 'release/')) || (github.event.pull_request.merged && !contains(github.head_ref, 'release/'))}}; then
V="${V}-$(git tag --list ${V}* | wc -l)"
fi
CL=${V#v}
CL=${CL%-*}
echo "version=${V}" >> $GITHUB_OUTPUT
echo "cl_version=${CL}" >> $GITHUB_OUTPUT
echo "commit=${COMMIT}" >> $GITHUB_OUTPUT
- run: 'git tag --list ${V}*'
- name: Get SBOM
uses: actions/download-artifact@v4
with:
name: software-bom
path: sbom
- name: Get Changelog for this Tag
id: changelog
uses: coditory/changelog-parser@v1
with:
version: ${{steps.lasttag.outputs.cl_version}}
- name: Create Release
uses: ncipollo/release-action@v1
with:
name: ${{steps.lasttag.outputs.version}}
artifacts: sbom/**/*
body: |
## Features Requests / Bugs
If you find issues or have a feature request, please enter a [new issue on GitHub](${{github.server_url}}/${{github.repository}}/issues/new).
## Installation
View the installation instructions in the [README](${{github.server_url}}/${{github.repository}}/blob/main/README.md)
## Changelog
${{steps.changelog.outputs.description}}
prerelease: ${{ (! github.event.pull_request.merged) || (github.event.pull_request.merged && ! contains(github.head_ref, 'release/')) }}
commit: ${{steps.lasttag.outputs.commit}}
makeLatest: true
tag: ${{steps.lasttag.outputs.version}}