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 #1518.

Signed-off-by: Yadong Ding <[email protected]>
  • Loading branch information
Desiki-high committed Dec 18, 2023
1 parent a180c7a commit 335ebce
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
35 changes: 30 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,30 @@ 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.txt
upload-coverage-to-codecov:
runs-on: ubuntu-latest
needs: [contrib-unit-test-coverage, nydus-unit-test-coverage]
steps:
- 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.txt,coverage.txt
fail_ci_if_error: true

nydus-cargo-deny:
name: cargo-deny
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ coverage: pre-coverage

# write unit teset coverage to codecov.json, used for Github CI
coverage-codecov:
TEST_WORKDIR_PREFIX=$(TEST_WORKDIR_PREFIX) ${CARGO} llvm-cov --codecov --output-path codecov.json --workspace $(EXCLUDE_PACKAGES) $(CARGO_COMMON) $(CARGO_BUILD_FLAGS) -- --skip integration --nocapture --test-threads=8
TEST_WORKDIR_PREFIX=$(TEST_WORKDIR_PREFIX) ${CARGO} llvm-cov --codecov --text --output-path codecov.txt --workspace $(EXCLUDE_PACKAGES) $(CARGO_COMMON) $(CARGO_BUILD_FLAGS) -- --skip integration --nocapture --test-threads=8

smoke-only:
make -C smoke test
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 335ebce

Please sign in to comment.