Merge pull request #1 from rustyhorde/feature/binstall-fix #2
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: | |
workflow_call: | |
inputs: | |
os: | |
description: 'The os to run this job on [ubuntu-latest, macos-latest, windows-latest]' | |
required: true | |
type: string | |
channel: | |
description: 'The rust channel to use [stable, beta, nightly, version i.e. 1.70.0]' | |
required: true | |
type: string | |
target: | |
description: 'The rust target, i.e x86_64-unknown-linux-gnu' | |
required: true | |
type: string | |
clean: | |
description: 'Clean the workspace before running llvm-cov' | |
default: false | |
required: false | |
type: boolean | |
lcov: | |
description: 'Generate an LCOV report (lcov.info)' | |
default: false | |
required: false | |
type: boolean | |
html: | |
description: 'Generate an HTML report' | |
default: false | |
required: false | |
type: boolean | |
run_cmd: | |
description: 'The command to run to generate the llvm-cov output' | |
default: cargo llvm-cov --no-report | |
required: false | |
type: string | |
name: 𧱠Coverage 𧱠| |
jobs: | |
coverage: | |
name: 𧱠Coverage 𧱠| |
runs-on: ${{ inputs.os }} | |
steps: | |
- name: β Checkout β | |
uses: actions/checkout@v4 | |
- name: π§Ή Cleanup π§Ή | |
if: inputs.os == 'ubuntu-latest' | |
run: | | |
rm -rf /home/runner/.cargo/bin/rustfmt | |
rm -rf /home/runner/.cargo/bin/cargo-fmt | |
rm -rf /home/runner/.cargo/bin/rust-analyzer | |
- name: π§Ή Cleanup π§Ή | |
if: inputs.os == 'windows-latest' | |
run: | | |
If (Test-Path C:\Users\runneradmin\.cargo\bin\rustfmt.exe) { Remove-Item C:\Users\runneradmin\.cargo\bin\rustfmt.exe } | |
If (Test-Path C:\Users\runneradmin\.cargo\bin\cargo-fmt.exe) { Remove-Item C:\Users\runneradmin\.cargo\bin\cargo-fmt.exe } | |
If (Test-Path C:\Users\runneradmin\.cargo\bin\rust-analyzer.exe) { Remove-Item C:\Users\runneradmin\.cargo\bin\rust-analyzer.exe } | |
- name: π§° Toolchain π§° | |
run: | | |
rustup toolchain remove ${{ inputs.channel }}-${{ inputs.target }} | |
rustup toolchain install ${{ inputs.channel }}-${{ inputs.target }} --profile minimal --no-self-update | |
rustup default ${{ inputs.channel }} | |
rustup component add llvm-tools-preview | |
- name: π΅ Rust Cache π΅ | |
uses: Swatinem/rust-cache@v2 | |
if: ${{ github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork }} | |
with: | |
key: ${{ inputs.target }} | |
cache-all-crates: true | |
- name: πΎ Install (cargo-binstall) πΎ | |
if: inputs.os == 'ubuntu-latest' || inputs.os == 'windows-latest' | |
uses: cargo-bins/cargo-binstall@main | |
- name: πΎ Install (cargo-binstall) πΎ | |
if: inputs.os == 'macos-latest' | |
uses: cargo install cargo-binstall --force | |
- name: πΎ Install (llvm-cov) πΎ | |
run: cargo binstall --no-confirm --no-symlinks cargo-llvm-cov --force | |
- name: πΎ Install (cargo-matrix) πΎ | |
run: cargo binstall --no-confirm --no-symlinks --no-discover-github-token cargo-matrix --force | |
- name: π Clean Workspace π | |
if: inputs.clean | |
run: cargo llvm-cov clean --workspace | |
- name: π Code Coverage π | |
env: | |
ARANGODB_ROOT_PASSWORD: ${{ secrets.ARANGODB_ROOT_PASSWORD }} | |
ARANGODB_RUARANGO_PASSWORD: ${{ secrets.ARANGODB_RUARANGO_PASSWORD }} | |
ARANGODB_URL: ${{ secrets.ARANGODB_URL }} | |
BB8_MONGODB_URL: ${{ secrets.BB8_MONGODB_URL }} | |
BB8_MONGODB_USER: ${{ secrets.BB8_MONGODB_USER }} | |
BB8_MONGODB_PASSWORD: ${{ secrets.BB8_MONGODB_PASSWORD }} | |
run: ${{ inputs.run_cmd }} | |
- name: π Code Coverage Report (LCOV) π | |
if: inputs.lcov | |
run: cargo llvm-cov report --lcov --output-path lcov.info | |
- name: π Code Coverage Report (HTML) π | |
if: inputs.html | |
run: cargo llvm-cov report --html | |
- name: π Upload Code Coverage π | |
if: inputs.lcov | |
uses: codecov/codecov-action@v4 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
with: | |
files: ./lcov.info |