-
Notifications
You must be signed in to change notification settings - Fork 13
136 lines (115 loc) · 4.23 KB
/
rust.yml
File metadata and controls
136 lines (115 loc) · 4.23 KB
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
name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
defaults:
run:
shell: bash
permissions:
id-token: write
checks: write
env:
CARGO_TERM_COLOR: always
jobs:
publish:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: publish if necessary
run: |
export THIS_VERSION=$(cargo pkgid | sed 's/.*#\(.*\)/\1/')
curl --head --fail https://static.crates.io/crates/cargo2junit/$THIS_VERSION/download || cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO }}
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: Linux x86_64 stable
os: ubuntu-latest
- name: Windows x86_64 stable
os: windows-latest
- name: Mac x86_64 stable
os: macos-latest
steps:
- uses: actions/checkout@v3
- name: determine LKG_VERSION
run: echo "LKG_VERSION=$(curl "https://crates.io/api/v1/crates/cargo2junit/versions" | jq .versions[0].num -r)" >> $GITHUB_ENV
- name: Dump Environment
run: env
- uses: actions/cache@v3
name: cache Rust dependencies
id: cache-cargo
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-build-${{ env.LKG_VERSION }}-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-build-${{ env.LKG_VERSION }}
- name: refresh crates.io index
run: cargo update --dry-run
# - if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }}
# name: Install (LKG) cargo2junit
# run: cargo install --locked cargo2junit
- name: Build
run: cargo build
- name: Test
run: cargo test -- -Z unstable-options --format json --report-time | tee test_results_debug.json
env: # See https://github.com/johnterickson/cargo2junit/issues/79
RUSTC_BOOTSTRAP: 1
- name: Build release
run: cargo build --release
- name: Test release
run: cargo test --release -- -Z unstable-options --format json --report-time | tee test_results_release.json
env: # See https://github.com/johnterickson/cargo2junit/issues/79
RUSTC_BOOTSTRAP: 1
# - name: convert to junit using LKG cargo2junit
# run: |
# cat test_results_debug.json | cargo2junit > test_results_debug_lkg.xml
# cat test_results_release.json | cargo2junit > test_results_release_lkg.xml
# - name: Publish Test Report Debug LKG
# uses: mikepenz/action-junit-report@v3
# if: always() # always run even if the previous step fails
# with:
# report_paths: 'test_results_debug_lkg.xml'
# check_title_template: ${{ matrix.name }} debug_lkg
# - name: Publish Test Report Release LKG
# uses: mikepenz/action-junit-report@v3
# if: always() # always run even if the previous step fails
# with:
# report_paths: 'test_results_release_lkg.xml'
# check_title_template: ${{ matrix.name }} release_lkg
- name: convert to junit using just-built cargo2junit
run: |
cat test_results_debug.json | ./target/debug/cargo2junit > test_results_debug.xml
cat test_results_release.json | ./target/debug/cargo2junit > test_results_release.xml
- name: Publish Test Report Debug
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: 'test_results_debug.xml'
check_title_template: ${{ matrix.name }} debug
- name: Publish Test Report Release
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: 'test_results_release.xml'
check_title_template: ${{ matrix.name }} release
- uses: philips-software/sbom-tool-installer-action@v1.0.0
- run: >
sbom-tool generate
-b ./target/release
-bc .
-pn cargo2junit
-pv $(cat Cargo.toml | grep '^version =' | grep -Eo [0-9]+\.[0-9]+\.[0-9])
-ps johnterickson
-nsb https://github.com/johnterickson
-V Verbose