diff --git a/.github/workflows/lint-and-tests.yml b/.github/workflows/lint-and-tests.yml index d0200e72..ddb103df 100644 --- a/.github/workflows/lint-and-tests.yml +++ b/.github/workflows/lint-and-tests.yml @@ -4,6 +4,7 @@ on: push: branches: [ "main" ] paths: + - '.github/workflows/**' - 'pkg/**' - 'cmd/**' - 'api/**' @@ -13,6 +14,7 @@ on: pull_request: branches: [ "main" ] paths: + - '.github/workflows/**' - 'pkg/**' - 'cmd/**' - 'api/**' @@ -64,4 +66,24 @@ jobs: restore-keys: | ${{ runner.os }}-go- - name: Run Unit Tests - run: make test \ No newline at end of file + run: make test + - name: Archive code coverage results + uses: actions/upload-artifact@v4 + with: + name: code-coverage + path: cover.out # Make sure to use the same file name you chose for the "-coverprofile" in the "Test" step + + code_coverage: + name: "Code coverage report" + if: github.event_name == 'pull_request' # Do not run when workflow is triggered by push to main branch + runs-on: ubuntu-latest + needs: test # Depends on the artifact uploaded by the "unit_tests" job + permissions: + contents: read + actions: read # to download code coverage results from "test" job + pull-requests: write # write permission needed to comment on PR + steps: + - uses: fgrosse/go-coverage-report@v1.1.1 # Consider using a Git revision for maximum security + with: + coverage-artifact-name: "code-coverage" # can be omitted if you used this default value + coverage-file-name: "cover.out" # can be omitted if you used this default value