Skip to content

Commit

Permalink
chore(ci): include coverage in test workflow (#1537)
Browse files Browse the repository at this point in the history
Move coverage workflow under test workflow and change the trigger to
allow users to trigger coverage run directly in GH Actions. Update
sanity workflow step names to show what's run there.
  • Loading branch information
BartoszCiesla authored Feb 15, 2025
1 parent 4adba54 commit 4de0a86
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 43 deletions.
47 changes: 12 additions & 35 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
name: coverage

on:
pull_request:
branches:
- master
paths:
- '**/*.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
push:
branches:
- master
paths:
- '**/*.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
workflow_dispatch:
workflow_call:

env:
CARGO_TERM_COLOR: always
GITHUB_BOT_CONTEXT_STRING: "coveralls coverage reporting job"

jobs:
coverage:
name: Code coverage
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
Expand All @@ -34,7 +25,7 @@ jobs:

- name: Install gnome-keyring and keyutils on Linux
run: |
sudo apt-get update --yes && sudo apt-get install --yes gnome-keyring keyutils
sudo apt-get update --yes && sudo apt-get install --yes gnome-keyring keyutils lcov
rm -f $HOME/.local/share/keyrings/*
echo -n "test" | gnome-keyring-daemon --unlock
Expand All @@ -50,27 +41,13 @@ jobs:
- name: Generate code coverage
run: source <(cargo llvm-cov show-env --export-prefix) && cargo llvm-cov report --lcov --output-path coverage.lcov --ignore-filename-regex '(bench\/|integration\/|tools\/|tpc\/)'

- name: Display code coverage
run: lcov --summary coverage.lcov

- name: Upload code to Coveralls
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-coverage') }}
# Do not upload coverage for user triggered workflows
if: github.event_name == 'workflow_call'
uses: coverallsapp/github-action@v2
with:
fail-on-error: false
github-token: ${{ secrets.GITHUB_TOKEN }}

finalize_coverage:
runs-on: ubuntu-latest
needs: coverage
if: always()
steps:
- uses: actions/checkout@v4
- name: Everything is fine
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Something went wrong
if: ${{ contains(needs.*.result, 'failure') && github.event_name == 'push' }}
uses: JasonEtco/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_BOT_CONTEXT_STRING: "coveralls coverage reporting job"
with:
filename: .github/BOT_ISSUE_TEMPLATE.md
15 changes: 8 additions & 7 deletions .github/workflows/sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
check:
name: Check
name: cargo check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -14,7 +14,7 @@ jobs:
with:
command: check
fmt:
name: Rustfmt
name: cargo fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -25,7 +25,7 @@ jobs:
command: fmt
args: --all -- --check
clippy:
name: Clippy
name: cargo clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -36,7 +36,7 @@ jobs:
args: --all-targets --all-features -- -D warnings

sort:
name: Sort dependencies
name: cargo sort
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -45,22 +45,22 @@ jobs:
- run: cargo sort --check --workspace

doctest:
name: Test documentation
name: cargo test docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --doc

unused_dependencies:
name: Unused dependencies
name: cargo machete
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bnjbvr/[email protected]

check-commit-message:
name: Validate commit messages
name: commit messages
runs-on: ubuntu-latest
# This action isn't working with workflow_dispatch, skip it
if: github.event_name != 'workflow_dispatch'
Expand All @@ -74,6 +74,7 @@ jobs:
accessToken: ${{ secrets.GITHUB_TOKEN }} # needed only when checkAllCommitMessages is true
pattern: '^.{0,80}(\n.*)*$'
error: "Subject of all commits in the PR and PR body/title has to be shorter than 80 characters."

# Uncomment this when we have a proper release - 1.0.0
# semver-checks:
# name: SemVer SDK
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/test_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
pull_request:
branches:
- master
types: [opened, synchronize, reopened]
types: [ opened, synchronize, reopened ]

env:
CRATE_NAME: iggy
Expand All @@ -27,9 +27,25 @@ concurrency:

jobs:
sanity:
name: check
uses: ./.github/workflows/sanity.yml

coverage:
name: Code coverage
if: |
(github.event_name == 'pull_request' &&
(contains(github.event.pull_request.changed_files, '.rs') ||
contains(github.event.pull_request.changed_files, 'Cargo.toml') ||
contains(github.event.pull_request.changed_files, 'Cargo.lock')))
||
(github.event_name == 'push' &&
(contains(github.event.head_commit.modified, '.rs') ||
contains(github.event.head_commit.modified, 'Cargo.toml') ||
contains(github.event.head_commit.modified, 'Cargo.lock')))
uses: ./.github/workflows/coverage.yml

backwards_compatibility:
name: Backwards compatibility
uses: ./.github/workflows/backwards_compatibility.yml
needs: sanity
with:
Expand Down Expand Up @@ -138,6 +154,7 @@ jobs:
runs-on: ubuntu-latest
needs:
- sanity
- coverage
- backwards_compatibility
- build_and_test
if: always()
Expand Down

0 comments on commit 4de0a86

Please sign in to comment.