Skip to content

Actions cache

Actions cache #65

Workflow file for this run

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:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: Linux x86_64 stable
os: ubuntu-latest
rust: stable
- name: Windows x86_64 stable
os: windows-latest
rust: stable
- name: Mac x86_64 stable
os: macos-latest
rust: stable
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/[email protected]
- 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