Skip to content

Commit

Permalink
feat: Add test coverage job to workflow
Browse files Browse the repository at this point in the history
Part of #2

It sends the report to Codacy
  • Loading branch information
Gashmob committed Jul 16, 2024
1 parent 89140a9 commit 46e21a6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
1 change: 0 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

...


## Checklist before requesting a review

- [ ] I've followed Contributions guidelines
Expand Down
32 changes: 27 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ env:

jobs:
configure:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Set matrix data
id: set-matrix
run: |
Expand All @@ -33,7 +33,7 @@ jobs:
matrix: ${{ fromJson(needs.configure.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- name: Install Nix
uses: cachix/install-nix-action@ba0dd844c9180cbf77aa72a116d6fbc515d0e87b
Expand All @@ -52,7 +52,7 @@ jobs:
matrix: ${{ fromJson(needs.configure.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- name: Install Nix
uses: cachix/install-nix-action@ba0dd844c9180cbf77aa72a116d6fbc515d0e87b
Expand All @@ -61,4 +61,26 @@ jobs:
with:
script: |
bazel build //:unit-tests --copt="--target=${{ matrix.triple }}"
bazel test //:unit-tests
bazel test //:unit-tests
test-coverage:
name: "Unit test coverage"
needs: configure
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- name: Install Nix
uses: cachix/install-nix-action@ba0dd844c9180cbf77aa72a116d6fbc515d0e87b
- name: Run tests
id: tests
uses: workflow/nix-shell-action@10ebd4e80eae8a5bc5147c0a36ebb568d1b277bd
with:
script: |
bazel coverage --combined_report=lcov //:unit-tests
echo "coverage_path=$(bazel info output_path)/_coverage/_coverage_report.dat" >> "$GITHUB_OUTPUT"
- name: Upload coverage report to Codacy
uses: codacy/codacy-coverage-reporter-action@89d6c85cfafaec52c72b6c5e8b2878d33104c699
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ${{ steps.tests.outputs.coverage_path }}

0 comments on commit 46e21a6

Please sign in to comment.