Skip to content

Commit

Permalink
Merge pull request #2119 from headlamp-k8s/skip-coverage
Browse files Browse the repository at this point in the history
github: backend-test: Skip coverage except for PRs
  • Loading branch information
illume authored Jul 5, 2024
2 parents cf1c841 + 4e75623 commit a2451d1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/backend-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
- name: Run tests and calculate code coverage
run: |
set -x
cd backend
go test ./... -coverprofile=coverage.out -covermode=atomic -coverpkg=./...
testcoverage=$(go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+')
Expand All @@ -70,7 +71,14 @@ jobs:
shell: bash

- name: Get base branch code coverage
if: ${{ github.event_name }} == 'pull_request'
run: |
set -x
if [[ -z "${{ github.base_ref }}" ]]; then
echo "Base branch is empty. Skipping code coverage comparison."
exit 0
fi
cd backend
base_branch="${{ github.base_ref }}"
testcoverage="${{ env.coverage }}"
Expand All @@ -83,7 +91,14 @@ jobs:
shell: bash

- name: Compare code coverage
if: ${{ github.event_name }} == 'pull_request'
run: |
set -x
if [[ -z "${{ github.base_ref }}" ]]; then
echo "Base branch is empty. Skipping code coverage comparison."
exit 0
fi
testcoverage="${{ env.coverage }}"
base_coverage="${{ env.base_coverage }}"
if [[ -z $testcoverage || -z $base_coverage ]]; then
Expand All @@ -101,7 +116,13 @@ jobs:
shell: bash

- name: Comment on PR
if: ${{ github.event_name }} == 'pull_request'
run: |
set -x
if [[ -z "${{ github.base_ref }}" ]]; then
echo "Base branch is empty. Skipping code coverage comparison."
exit 0
fi
testcoverage="${{ env.coverage }}"
base_coverage="${{ env.base_coverage }}"
coverage_diff="${{ env.coverage_diff }}"
Expand Down

0 comments on commit a2451d1

Please sign in to comment.