Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: store merged coverage as artifact #1613

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 57 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
env:
GOTRACEBACK: crash
run: |
gotestsum --raw-command --ignore-non-json-output-lines --junitfile junit.xml -- vimto -kernel :stable-selftests -- go test -timeout 5m -short -count 1 -json ./...
gotestsum --raw-command --ignore-non-json-output-lines --junitfile junit.xml -- vimto -kernel :stable-selftests -- go test -timeout 5m -short -count 1 -json ./... -coverprofile=coverage-pre-go.out

- name: Benchmark
run: vimto -kernel :stable-selftests -- go test -short -run '^$' -bench . -benchtime=1x ./...
Expand All @@ -149,6 +149,13 @@ jobs:
name: Test Results (previous stable Go)
path: junit.xml

- name: Upload Coverage Report
if: always()
uses: actions/upload-artifact@v4
with:
name: Coverage Report (previous stable Go)
path: coverage-pre-go.out

test-on-arm64:
name: Run tests on arm64
runs-on: ubuntu-22.04-arm64
Expand All @@ -168,7 +175,7 @@ jobs:

- name: Test
# Skip TestGoarches/loong64 because the GH arm64 Go toolchain seems to be weird.
run: gotestsum --ignore-non-json-output-lines --junitfile junit.xml -- -exec 'sudo -E' -short -count 1 -skip '^TestGoarches/loong64$' -json ./...
run: gotestsum --ignore-non-json-output-lines --junitfile junit.xml -- -exec 'sudo -E' -short -count 1 -skip '^TestGoarches/loong64$' -json ./... -coverprofile=coverage-arm64.out

- name: Benchmark
run: go test -exec sudo -short -run '^$' -bench . -benchtime=1x ./...
Expand All @@ -185,6 +192,13 @@ jobs:
run: |
sudo dmesg

- name: Upload Coverage Report
if: always()
uses: actions/upload-artifact@v4
with:
name: Coverage Report (arm64)
path: coverage-arm64.out

vm-test:
name: Run tests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -217,11 +231,50 @@ jobs:
- run: sudo chmod 0666 /dev/kvm

- name: Test
run: gotestsum --raw-command --ignore-non-json-output-lines --junitfile junit.xml -- vimto -kernel :${{ matrix.tag }} -- go test -short -count 1 -json ./...

run: gotestsum --raw-command --ignore-non-json-output-lines --junitfile junit.xml -- vimto -kernel :${{ matrix.tag }} -- go test -short -count 1 -json ./... -coverprofile=coverage-${{ matrix.tag }}.out
ti-mo marked this conversation as resolved.
Show resolved Hide resolved
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Test Results (${{ matrix.tag }})
path: junit.xml

- name: Upload Coverage Report
if: always()
uses: actions/upload-artifact@v4
with:
name: Coverage Report (${{ matrix.tag }})
path: coverage-${{ matrix.tag }}.out

merge-coverage:
name: Merge Coverage Reports
runs-on: ubuntu-latest
needs: [vm-test, test-on-arm64, test-on-prev-go]
timeout-minutes: 10
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '${{ env.go_version }}'

- name: Download Coverage Reports
uses: actions/download-artifact@v4
with:
pattern: coverage-*.out
path: coverage-reports

- name: Merge Coverage Reports
run: |
go tool covdata -merge coverage-reports/coverage-*.out -o coverage-merged.out
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go tool covdata doesn't work on the plaintext files generated with go test -coverprofile=. It only works with the new binary format, which is currently a bit annoying to produce with go test, see golang/go#66225 (comment). The cover directory needs to exist for this to work.

Documentation:
https://go.dev/doc/build-cover
https://go.dev/blog/integration-test-coverage

Please make sure your code (the commands executed, at least) work before pushing up your changes. It looks like you've been pushing commits blindly so far, which is not very respectful of a reviewer's time.

If you want to experiment with GHA workflows offline, take a look at https://github.com/nektos/act.

go tool cover -html=coverage-merged.out -o coverage.html

- name: Upload Merged Coverage Report
uses: actions/upload-artifact@v4
with:
name: Merged Coverage Report
path: coverage.html