Skip to content

Actions cache

Actions cache #60

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: Dump Environment
run: env
- uses: actions/cache@v3
name: cache Rust dependencies
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-build
- name: refresh crates.io index
run: cargo update --dry-run
- 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