Skip to content

ci: invoke the tool when collecting coverage #106

ci: invoke the tool when collecting coverage

ci: invoke the tool when collecting coverage #106

Workflow file for this run

name: ci
on: [push, pull_request]
permissions:
contents: read
id-token: write
env:
RUST_BACKTRACE: 1
jobs:
style:
name: Check Style
# needless matrix to make copy-pasting common steps easier
strategy:
matrix:
os:
- ubuntu-latest
rust:
- nightly
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust (${{ matrix.rust }})
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
components: rustfmt
cache-shared-key: ${{ matrix.os }}-${{ matrix.rust }}
- name: Run Rustfmt
run: cargo fmt --all --check
check-and-test:
name: Run Clippy Checks and Tests
needs: [style]
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
rust:
- "1.86"
- "1.87"
- "1.88"
- "1.89"
- "1.90"
- stable
- beta
- nightly
rustc_bootstrap:
- "0"
- "1"
exclude:
# bootstrap is only relevant for non-nightly toolchains
- os: ubuntu-latest
rust: nightly
rustc_bootstrap: "0"
- os: macos-latest
rust: nightly
rustc_bootstrap: "0"
- os: windows-latest
rust: nightly
rustc_bootstrap: "0"
runs-on: ${{ matrix.os }}
env:
RUSTFLAGS: "-D warnings"
RUSTC_BOOTSTRAP: ${{ matrix.rustc_bootstrap }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust (${{ matrix.rust }})
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
components: clippy,llvm-tools-preview
cache-shared-key: ${{ matrix.os }}-${{ matrix.rust }}${{ matrix.rust != 'nightly' && matrix.rustc_bootstrap == '1' && '-bootstrap' || '' }}
- name: Install grcov
run: cargo install grcov --locked
- name: Fetch cargo dependencies
run: cargo fetch --verbose --locked
# Following commands use `--frozen` to ensure that the lockfile is up-to-date and
# all dependencies were downloaded with `cargo fetch`.
- name: Run Clippy (no default features)
run: cargo clippy --verbose --workspace --all-targets --no-default-features --frozen
- name: Run Clippy (default features)
run: cargo clippy --verbose --workspace --all-targets --frozen
- name: Run Clippy (all features)
run: cargo clippy --verbose --workspace --all-targets --all-features --frozen
- name: Run Tests (no default features)
run: cargo test --verbose --workspace --no-default-features --frozen
- name: Run Tests (default features)
run: cargo test --verbose --workspace --frozen
- name: Run Tests (all features)
run: cargo test --verbose --workspace --all-features --frozen
- name: Build Binaries
if: matrix.rust == 'nightly'
run: cargo build --verbose --bins --workspace --frozen --profile=release-lto
- name: Print diagnostics
if: matrix.rust == 'nightly' && runner.os == 'Windows'
shell: powershell
run: |
Get-ChildItem -Path .\target\release-lto
- name: Print diagnostics
if: matrix.rust == 'nightly' && runner.os != 'Windows'
run: |
ls -Al ./target/release-lto
- name: Upload Binaries as GitHub artifact
if: matrix.rust == 'nightly'
uses: actions/upload-artifact@v4.6.0
with:
name: git-remote-codecommit-${{ matrix.os }}
path: |
target/release-lto/git-remote-codecommit
target/release-lto/git-remote-codecommit.exe
compression-level: 0
- name: Configure AWS credentials
if: github.repository == 'demosdemon/git-remote-codecommit'
uses: aws-actions/configure-aws-credentials@v4.0.2
env:
RUST_BACKTRACE: 1
AWS_REGION: us-west-2
with:
role-to-assume: arn:aws:iam::339712996426:role/github-git-remote-codecommit
aws-region: ${{ env.AWS_REGION }}
- name: Run Rust tests with coverage
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Cinstrument-coverage"
shell: bash
run: |
cargo build --verbose --workspace --all-targets --frozen
export LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw'
export PATH="$PWD/target/debug:$PATH"
git remote add aws codecommit://git-remote-codecommit
git fetch aws main --depth=1 || true # if this is a fork the credentials won't be set
cargo test --verbose --workspace --frozen
mkdir -p ./target/debug/coverage/
grcov . \
--source-dir . \
--binary-path ./target/debug/ \
--output-types lcov,html \
--llvm \
--branch \
--keep-only 'crates/**' \
--ignore-not-existing \
--excl-line 'grcov-excl-line|#\[derive\(|ensure!\(|assert!\(|/!|///' \
--excl-start 'grcov-excl-start' \
--excl-stop 'grcov-excl-stop' \
--output-path ./target/debug/coverage/
- name: Upload out if failed
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-failure-${{ matrix.rust }}-${{ matrix.os }}${{ matrix.rust != 'nightly' && matrix.rustc_bootstrap == '1' && '-bootstrap' || '' }}
path: target/debug/build/git-remote-codecommit-*
retention-days: 1
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage-report-${{ matrix.rust }}-${{ matrix.os }}${{ matrix.rust != 'nightly' && matrix.rustc_bootstrap == '1' && '-bootstrap' || '' }}
path: target/debug/coverage/html/
retention-days: 7
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
files: target/debug/coverage/lcov
flags: unittests
use_oidc: true
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
files: target/debug/coverage/lcov
flag-name: code-coverage-report-${{ matrix.rust }}-${{ matrix.os }}${{ matrix.rust != 'nightly' && matrix.rustc_bootstrap == '1' && '-bootstrap' || '' }}
parallel: true
finalize-coveralls-run:
name: Finalize Coveralls Run
needs: [check-and-test]
if: always()
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set carryforward
id: set_carryforward
run: |
echo "carryforward<<EOF" >> $GITHUB_OUTPUT
python3 .github/scripts/matrix.py >> $GITHUB_OUTPUT
echo EOF >> $GITHUB_OUTPUT
- name: Finalize Coveralls Run
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
carryforward: ${{ steps.set_carryforward.outputs.carryforward }}
build-docs:
name: Build Documentation
needs: [check-and-test]
# needless matrix to make copy-pasting common steps easier
strategy:
matrix:
os:
- ubuntu-latest
rust:
- nightly
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust (${{ matrix.rust }})
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
cache-shared-key: ${{ matrix.os }}-${{ matrix.rust }}
- name: Fetch cargo dependencies
run: cargo fetch --verbose --locked
- name: Build Documentation
run: cargo doc --verbose --workspace --document-private-items --frozen
- name: Print diagnostics
run: |
find ./target/doc -ls
du -hd1 ./target/doc | sort -h
- name: Upload Documentation as GitHub artifact
uses: actions/upload-artifact@v4.6.0
with:
name: docs
path: target/doc
compression-level: 9
push-to-codecommit:
concurrency: push-to-codecommit
name: Push to CodeCommit
needs: [finalize-coveralls-run, build-docs, check-and-test]
runs-on: ubuntu-latest
env:
RUST_BACKTRACE: 1
AWS_REGION: us-west-2
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # need the history in order to push to CodeCommit
- name: Configure AWS credentials
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'demosdemon/git-remote-codecommit'
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
role-to-assume: arn:aws:iam::339712996426:role/github-git-remote-codecommit
aws-region: ${{ env.AWS_REGION }}
- name: Download git-remote-codecommit
uses: actions/download-artifact@v4
with:
name: git-remote-codecommit-ubuntu-latest
path: target/release-lto
- name: Make git-remote-codecommit executable
run: chmod +x target/release-lto/git-remote-codecommit
- name: Add git-remote-codecommit to PATH
run: echo "$PWD/target/release-lto" >> $GITHUB_PATH
- name: Check version
run: git-remote-codecommit --version
- name: Push to CodeCommit
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'demosdemon/git-remote-codecommit'
run: |
git remote add aws codecommit://git-remote-codecommit
git push aws --tags
git push aws HEAD:refs/heads/main