Skip to content

Commit

Permalink
tests: add go module unit coverage to Codecov
Browse files Browse the repository at this point in the history
resolve dragonflyoss#1518.

Signed-off-by: Yadong Ding <[email protected]>
  • Loading branch information
Desiki-high committed Dec 18, 2023
1 parent a180c7a commit b24a4c5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
36 changes: 31 additions & 5 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ jobs:
CARGO_BIN=$(which cargo)
sudo -E CARGO=${CARGO_BIN} make ut-nextest
contrib-unit-test:
contrib-unit-test-coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -183,6 +183,12 @@ jobs:
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
Expand All @@ -205,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
2 changes: 1 addition & 1 deletion contrib/nydusify/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ tmp
cmd/nydusify
output
nydus-hook-plugin
coverage.out
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 ${PACKAGES}
@go test -covermode=atomic -coverprofile=coverage.txt -count=1 -v -timeout 20m -race ${PACKAGES}

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

0 comments on commit b24a4c5

Please sign in to comment.