diff --git a/.github/workflows/backend-test.yml b/.github/workflows/backend-test.yml index eb3799f51d0..287e7274d5f 100644 --- a/.github/workflows/backend-test.yml +++ b/.github/workflows/backend-test.yml @@ -64,6 +64,7 @@ jobs: set -x cd backend go test ./... -coverprofile=coverage.out -covermode=atomic -coverpkg=./... + go tool cover -html=coverage.out -o backend_coverage.html testcoverage_full=$(go tool cover -func=coverage.out) testcoverage=$(go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+') testcoverage_full_base64=$(echo "$testcoverage_full" | base64 -w 0) @@ -75,6 +76,19 @@ jobs: rm ~/.config/Headlamp/kubeconfigs/config shell: bash + - name: Upload coverage report as artifact + uses: actions/upload-artifact@v3 + with: + name: backend-coverage-report + path: ./backend/backend_coverage.html + + - name: Get backend_coverage artifact URL + id: get-artifact-url + run: | + ARTIFACT_ID=$(gh api -H "Accept: application/vnd.github.v3+json" /repos/${{ github.repository }}/actions/artifacts | jq -r '.artifacts[] | select(.name=="backend-coverage-report") | .id') + ARTIFACT_URL="https://github.com/${{ github.repository }}/suites/${{ github.run_id }}/artifacts/$ARTIFACT_ID" + echo "artifact_url=$ARTIFACT_URL" >> $GITHUB_ENV + - name: Get base branch code coverage if: ${{ github.event_name }} == 'pull_request' run: | @@ -134,6 +148,7 @@ jobs: base_coverage="${{ env.base_coverage }}" coverage_diff="${{ env.coverage_diff }}" + artifact_url="${{ env.artifact_url }}" if (( $(echo "$coverage_diff < 0" | bc -l) )); then emoji="😞" # Decreased coverage @@ -148,13 +163,16 @@ jobs: comment="${comment}
- See full coverage report + Coverage report \`\`\` $testcoverage_full \`\`\` -
" + + + [Html coverage report download](artifact_url) + " echo "$comment"