fix: Install dependencies for security workflow. #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
name: Test with Code Coverage | |
permissions: | |
contents: read | |
issues: read | |
checks: write | |
pull-requests: write | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
test: | |
name: Test | |
env: | |
PROJECT_NAME_UNDERSCORE: test2 | |
CARGO_INCREMENTAL: 0 | |
RUSTFLAGS: -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort | |
RUSTDOCFLAGS: -Cpanic=abort | |
runs-on: ubuntu-latest | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 | |
with: | |
egress-policy: audit | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: dtolnay/rust-toolchain@525fbff0dae0f21267554d5c96520a169909e20a # nightly | |
with: | |
components: llvm-tools-preview | |
- name: Cache dependencies | |
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 | |
env: | |
cache-name: cache-dependencies | |
with: | |
path: | | |
~/.cargo/.crates.toml | |
~/.cargo/.crates2.json | |
~/.cargo/bin | |
~/.cargo/registry/index | |
~/.cargo/registry/cache | |
target | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }} | |
- name: Install grcov | |
uses: taiki-e/install-action@33e32f55072c61d57aa7ddee0fc8e94f46298976 # v2.45.5 | |
with: | |
tool: grcov,cargo-llvm-cov | |
- name: Run tests | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
cargo test --all-features | |
- name: Set env | |
run: echo "CARGO2JUNIT_VERSION=$(curl -sL https://api.github.com/repos/yonasBSD/cargo2junit/releases/latest | jq -r ".tag_name" | cut -d'v' -f2)" >> $GITHUB_ENV | |
- name: Generate test result and coverage report | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
wget https://github.com/yonasBSD/cargo2junit/releases/download/v${CARGO2JUNIT_VERSION}/cargo2junit_${CARGO2JUNIT_VERSION}_amd64.deb | |
sudo dpkg -i cargo2junit_${CARGO2JUNIT_VERSION}_amd64.deb | |
rm cargo2junit_${CARGO2JUNIT_VERSION}_amd64.deb | |
cargo clean | |
cargo test $CARGO_OPTIONS -- -Z unstable-options --format json | cargo2junit > results.xml; | |
cargo llvm-cov --all-features --workspace --codecov --output-path ./codecov.json | |
- name: Upload test results | |
uses: EnricoMi/publish-unit-test-result-action@170bf24d20d201b842d7a52403b73ed297e6645b # v2.18.0 | |
with: | |
check_name: Test Results | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
files: results.xml | |
- name: Run xtask coverage | |
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
command: xtask | |
args: coverage | |
#- name: Upload Coverage Report | |
# uses: codecov/codecov-action@v5 | |
# with: | |
# verbose: true | |
# token: ${{ secrets.CODECOV_TOKEN }} | |
# files: ${{ github.workspace }}/codecov.json | |
# - name: Upload to codecov.io | |
# uses: codecov/codecov-action@v5 | |
# with: | |
# files: coverage/*.lcov | |
# fail_ci_if_error: true |