Skip to content

fix: actually prevent Cargo.lock from being modified in CI #438

fix: actually prevent Cargo.lock from being modified in CI

fix: actually prevent Cargo.lock from being modified in CI #438

Workflow file for this run

name: build
on:
pull_request:
branches-ignore:
- renovate/*
push:
branches: ["*"]
tags-ignore:
- "**"
jobs:
check:
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-D warnings"
RUSTDOCFLAGS: "-D warnings"
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: check-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: check-${{ runner.os }}-cargo
# Calling rustup show will install the toolchain in rust-toolchain
- name: Install toolchain
id: rustup
run: rustup show
# Important: run a command with the --locked flag first, so other commands can't modify Cargo.lock first. See https://github.com/iTrooz/efivar-rs/issues/81
- name: Fetch dependencies
run: cargo fetch --locked
- name: Run cargo fmt
run: cargo fmt -- --check
- name: Run cargo check
run: cargo check --all-features
- name: Run cargo clippy
run: cargo clippy --all-features
# Verify broken doc links
- name: Run cargo doc
run: cargo doc --all-features --no-deps
test:
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-latest
- runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: test-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: test-${{ runner.os }}-cargo
# Calling rustup show will install the toolchain in rust-toolchain
- name: Install toolchain
id: rustup
run: rustup show
# Install cargo-make which will drive the build
- name: Install cargo-make
uses: davidB/rust-cargo-make@v1
with:
version: 0.36.2
- name: Fetch dependencies
run: cargo fetch
# Run tests
- name: Run tests
shell: bash
run: |
if cargo make --list-all-steps --output-format autocomplete --quiet | grep -E '(^|\W)ci-test($|\W)' >/dev/null 2>&1; then
cargo make ci-test
else
echo "No test task found in Makefile.toml."
fi
- name: Upload coverage to codecov.io
uses: codecov/codecov-action@v3
with:
files: coverage/info.lcov
fail_ci_if_error: false # upload can randomly fail, see https://github.com/codecov/codecov-action/issues/557
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
build:
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
include:
- name: Linux
runs-on: ubuntu-latest
- name: Windows
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: build-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: build-${{ runner.os }}-cargo
- name: Setup Rust cache
uses: actions/cache@v3
with:
path: |
target/
key: build-${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
restore-keys: build-${{ runner.os }}-rust
# Calling rustup show will install the toolchain in rust-toolchain
- name: Install toolchain
id: rustup
run: rustup show
# Install cargo-make which will drive the build
- name: Install cargo-make
uses: davidB/rust-cargo-make@v1
with:
version: 0.36.2
- name: Fetch dependencies
run: cargo fetch
# Run binary build
- name: Build binaries
run: cargo make ci-build
# Upload artifacts
- name: Upload binaries from dist/
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.name }}
path: dist/