From 7bd960a9ecae0065f9ff708de32d8f4dabc1da75 Mon Sep 17 00:00:00 2001 From: Yadong Ding Date: Mon, 18 Dec 2023 19:40:36 +0800 Subject: [PATCH] tests: add go module unit coverage to Codecov resolve dragonflyoss#1518. Signed-off-by: Yadong Ding --- .github/workflows/smoke.yml | 35 ++++++++++++++++++++++++++++++----- contrib/nydusify/.gitignore | 2 +- contrib/nydusify/Makefile | 2 +- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index e5102f939ab..ba477ba83be 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -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 @@ -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 @@ -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.json + + 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.json,coverage.txt + fail_ci_if_error: true nydus-cargo-deny: name: cargo-deny diff --git a/contrib/nydusify/.gitignore b/contrib/nydusify/.gitignore index 3b175fe05a3..5f11974a951 100644 --- a/contrib/nydusify/.gitignore +++ b/contrib/nydusify/.gitignore @@ -3,4 +3,4 @@ tmp cmd/nydusify output nydus-hook-plugin -coverage.out +coverage.txt diff --git a/contrib/nydusify/Makefile b/contrib/nydusify/Makefile index ac23cc9017c..937554c5c3b 100644 --- a/contrib/nydusify/Makefile +++ b/contrib/nydusify/Makefile @@ -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