From 8c0b0ffa779b12435ad75ee34ada8fd52b39b998 Mon Sep 17 00:00:00 2001 From: Kairo de Araujo Date: Thu, 4 Jan 2024 11:18:05 +0100 Subject: [PATCH] test: consolidate tests and add code coverage 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 --- .github/workflows/pipeline.yml | 27 +++++++++++++++------------ .github/workflows/witness.yml | 7 +++++++ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index a1eb5096..38eed2df 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -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: code-coverage-report + path: . + - name: Upload coverage to Codecov + uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d + release: - needs: e2e-tests + needs: [tests, codecov] permissions: id-token: write contents: write diff --git a/.github/workflows/witness.yml b/.github/workflows/witness.yml index 777d793d..06fa7d03 100644 --- a/.github/workflows/witness.yml +++ b/.github/workflows/witness.yml @@ -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