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

tests: add go module unit coverage statistics in Codecov #1524

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
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
51 changes: 45 additions & 6 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ jobs:
cache-dependency-path: "**/*.sum"
- name: Build Contrib
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/bin v1.54.2
make -e DOCKER=false nydusify-release
make -e DOCKER=false contrib-test
- name: Upload Nydusify
uses: actions/upload-artifact@master
with:
Expand Down Expand Up @@ -171,6 +169,27 @@ jobs:
CARGO_BIN=$(which cargo)
sudo -E CARGO=${CARGO_BIN} make ut-nextest

contrib-unit-test-coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Golang
uses: actions/setup-go@v4
with:
go-version-file: 'go.work'
cache-dependency-path: "**/*.sum"
- name: Unit Test
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/bin v1.54.2
make -e DOCKER=false contrib-test
- name: Upload contrib coverage file
uses: actions/upload-artifact@master
with:
name: contrib-test-coverage-artifact
path: |
contrib/nydusify/coverage.txt

nydus-unit-test-coverage:
runs-on: ubuntu-latest
env:
Expand All @@ -192,11 +211,31 @@ jobs:
CARGO_HOME=${HOME}/.cargo
CARGO_BIN=$(which cargo)
sudo -E CARGO=${CARGO_BIN} make coverage-codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
- name: Upload nydus coverage file
uses: actions/upload-artifact@master
with:
files: codecov.json
fail_ci_if_error: true
name: nydus-test-coverage-artifact
path: |
codecov.json

upload-coverage-to-codecov:
runs-on: ubuntu-latest
needs: [contrib-unit-test-coverage, nydus-unit-test-coverage]
steps:
- uses: actions/checkout@v3
- name: Download nydus coverage file
uses: actions/download-artifact@master
with:
name: nydus-test-coverage-artifact
- name: Download contrib coverage file
uses: actions/download-artifact@master
with:
name: contrib-test-coverage-artifact
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./codecov.json,./coverage.txt
fail_ci_if_error: true

nydus-cargo-deny:
name: cargo-deny
Expand Down
1 change: 1 addition & 0 deletions contrib/nydusify/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ tmp
cmd/nydusify
output
nydus-hook-plugin
coverage.txt
2 changes: 1 addition & 1 deletion contrib/nydusify/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ plugin:
test: build
@go vet $(PACKAGES)
golangci-lint run
@go test -covermode=atomic -coverprofile=coverage.out -count=1 -v -timeout 20m -race ./pkg/... ./cmd/...
@go test -covermode=atomic -coverprofile=coverage.txt -count=1 -v -timeout 20m -race ${PACKAGES}

coverage: test
@go tool cover -func=coverage.out
Expand Down