Skip to content

Commit

Permalink
test: consolidate tests and add code coverage
Browse files Browse the repository at this point in the history
This commit consolidates the `tests` and `e2e` tests in one.
The command `make tests` already run all the tests (unit and e2e).

This commit also includes in witness.yml the action to save the
cover.out to be used later by the pipeline to download the cover.out and
upload to the CodeCov.

Signed-off-by: Kairo de Araujo <[email protected]>
  • Loading branch information
kairoaraujo committed Jan 4, 2024
1 parent 9c3dda8 commit 8c9b079
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
27 changes: 15 additions & 12 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,31 @@ jobs:
attestations: "github"
command: go vet ./...

test:
tests:
needs: [fmt, static_analysis]
uses: ./.github/workflows/witness.yml
with:
pull_request: ${{ github.event_name == 'pull_request' }}
step: "test"
attestations: "github"
command: go test -v -coverprofile=profile.cov -covermode=atomic ./...

e2e-tests:
needs: test
uses: ./.github/workflows/witness.yml
with:
pull_request: ${{ github.event_name == 'pull_request' }}
step: "e2e"
step: "tests"
attestations: "github"
command: |
make clean
make test
codecov:
needs: tests
runs-on: ubuntu-latest
steps:
- name: Download CodeCov from e2e tests
uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110
with:
name: cover.out
path: .
- name: Upload coverage to Codecov
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d

release:
needs: e2e-tests
needs: [tests, codecov]
permissions:
id-token: write
contents: write
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/witness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,12 @@ jobs:
step: ${{ inputs.step }}
attestations: ${{ inputs.attestations }}
command: /bin/sh -c "${{ inputs.command }}"

- if: ${{ inputs.pull_request == true }}
run: ${{ inputs.command }}

- if: ${{ inputs.step == 'tests' }}
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: code-coverage-report
path: cover.out

0 comments on commit 8c9b079

Please sign in to comment.