From 9fb94d645c07030c46d004848feca96ec1b34db9 Mon Sep 17 00:00:00 2001 From: Vasco Guita <33404234+vascoguita@users.noreply.github.com> Date: Mon, 16 Jan 2023 15:56:32 +0100 Subject: [PATCH] Add coverage report (#3608) --- .github/workflows/changelog.yml | 4 +++- .github/workflows/docker.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/release.yml | 7 ++++++- .github/workflows/test.yml | 11 ++++++++++- Makefile | 2 +- changelog/unreleased/enhancement-coverage-report.md | 3 +++ 7 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 changelog/unreleased/enhancement-coverage-report.md diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index dc8d66417b..7207e6febc 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -24,4 +24,6 @@ jobs: with: go-version-file: go.mod - name: Check changelog - run: make check-changelog PR=${{ github.event.pull_request.number }} + run: make check-changelog + env: + PR: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a559299dd8..be63b63f77 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -26,7 +26,7 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build ${{ (inputs.push && 'and push') || '' }} ${{ inputs.tags }} Docker image + - name: Build ${{ inputs.push && 'and push' || '' }} ${{ inputs.tags }} Docker image uses: docker/build-push-action@v3 with: context: . diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 81aa6a61e6..51e34bb6c3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,7 +5,7 @@ on: - "go.mod" - "go.sum" push: - tags-ignore: + branches: - "*" workflow_dispatch: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c7df70b62f..475b8adb8a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,11 +11,16 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Setup Go environment + id: go uses: actions/setup-go@v3.3.0 with: go-version-file: go.mod - name: Make distribution - run: make dist VERSION=${{ github.ref_name }} GIT_COMMIT=${{ github.sha }} GO_VERSION=$(go version | awk '{print $3}') + run: make dist + env: + VERSION: ${{ github.ref_name }} + GIT_COMMIT: ${{ github.sha }} + GO_VERSION: ${{ steps.go.outputs.go-version }} - name: Release uses: softprops/action-gh-release@v1 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1e666799bc..47a63864fa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,7 @@ name: Test on: pull_request: push: - tags-ignore: + branches: - "*" workflow_dispatch: @@ -34,6 +34,15 @@ jobs: go-version-file: go.mod - name: Test run: make test + env: + COVER_PROFILE: ${{ github.event_name == 'push' && 'coverage.out' || '' }} + - name: Run codacy-coverage-reporter + uses: codacy/codacy-coverage-reporter-action@v1 + if: github.event_name == 'push' + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + coverage-reports: coverage.out + force-coverage-parser: go docker: strategy: fail-fast: false diff --git a/Makefile b/Makefile index 07d4ee5cae..4bbaa8e441 100644 --- a/Makefile +++ b/Makefile @@ -119,7 +119,7 @@ build-reva-docker: off .PHONY: test test: off - go test -race $$(go list ./... | grep -v /tests/integration) + go test $$([[ -z "${COVER_PROFILE}" ]] && echo "" || echo "-coverprofile=${COVER_PROFILE}") -race $$(go list ./... | grep -v /tests/integration) .PHONY: test-integration test-integration: build-revad diff --git a/changelog/unreleased/enhancement-coverage-report.md b/changelog/unreleased/enhancement-coverage-report.md new file mode 100644 index 0000000000..38cf29967c --- /dev/null +++ b/changelog/unreleased/enhancement-coverage-report.md @@ -0,0 +1,3 @@ +Enhancement: Add Golang test coverage report for Codacy + +https://github.com/cs3org/reva/pull/3608 \ No newline at end of file