name: CI
on: [push, pull_request]
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUSTFLAGS: -Dwarnings
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
CI: true
jobs:
check_project_files:
if: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- name: Restore lychee cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae with:
path: .lycheecache
key: cache-lychee-${{ github.sha }}
restore-keys: cache-lychee-
- uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 with:
args: "--cache --max-cache-age 1d . -v *.md"
failIfEmpty: false
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 with:
shared-key: "${{ github.workflow }}"
- uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696
- name: Query Cargo.toml
id: query-cargo-toml
run: echo "rust_version=$(yq '.package.rust-version' Cargo.toml)" >> "$GITHUB_OUTPUT"
- run: rustup default "${STEPS_QUERY_CARGO_TOML_OUTPUTS_RUST_VERSION}"
env:
STEPS_QUERY_CARGO_TOML_OUTPUTS_RUST_VERSION: ${{ steps.query-cargo-toml.outputs.rust_version }}
- run: rustup component add rustfmt clippy llvm-tools-preview
- run: cargo verify-project
- run: cargo fmt --check --all
- run: cargo clippy --all-targets -- -D warnings
- run: cargo check --all-targets --future-incompat-report
- run: cargo doc --no-deps --document-private-items
- name: Build
env:
RUSTFLAGS: -Cinstrument-coverage
run: cargo build --verbose
- name: Install grcov
uses: taiki-e/install-action@e49978b799e49ff429d162b7a30601a569ab6538 with:
tool: grcov
- name: Test
env:
LLVM_PROFILE_FILE: toml-rgb2ansi256-%p-%m.profraw
RUSTFLAGS: -Cinstrument-coverage
run: cargo test --verbose
- name: Generate coverage
run: |
mkdir -p ./target/debug/coverage/
grcov $(find . -name "toml-rgb2ansi256-*.profraw" -print) \
--branch \
--ignore-not-existing \
--binary-path ./target/debug/ \
-s . \
-t lcov \
--ignore "/*" \
-o ./target/debug/coverage/
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ./target/debug/coverage/lcov