From 066ac4feaed555c7fdf42ef28652c2e1eaf35588 Mon Sep 17 00:00:00 2001 From: Zhou Cheng Date: Wed, 25 Dec 2024 21:22:03 +0800 Subject: [PATCH] CI: coverage for ut. (#5431) --- .github/workflows/sync.yml | 6 +++--- .github/workflows/unittests.yml | 19 +++++++++++++++++-- Makefile | 10 +++++----- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 498e049b737e..b902b5fda844 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -76,9 +76,9 @@ jobs: elif [[ "${{matrix.type}}" == 'sync_exclude' ]]; then sudo GOCOVERDIR=$(pwd)/cover python3 .github/scripts/hypo/sync_test.py if [ "${{github.event_name}}" == "schedule" ]; then - sudo GOCOVERDIR=$(pwd)/cover MAX_EXAMPLE=500 STEP_COUNT=100 PROFILE=ci python3 .github/scripts/hypo/sync.py + sudo GOCOVERDIR=$(pwd)/cover MAX_EXAMPLE=100 STEP_COUNT=50 PROFILE=ci python3 .github/scripts/hypo/sync.py else - sudo GOCOVERDIR=$(pwd)/cover MAX_EXAMPLE=200 STEP_COUNT=50 PROFILE=ci python3 .github/scripts/hypo/sync.py + sudo GOCOVERDIR=$(pwd)/cover MAX_EXAMPLE=50 STEP_COUNT=30 PROFILE=ci python3 .github/scripts/hypo/sync.py fi else echo "Unknown type: ${{matrix.type}}" @@ -86,7 +86,7 @@ jobs: fi - name: upload coverage report - timeout-minutes: 5 + timeout-minutes: 10 uses: ./.github/actions/upload-coverage with: UPLOAD_TOKEN: ${{ secrets.CI_COVERAGE_FILE_UPLOAD_AUTH_TOKEN }} diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index fa55b5eccec1..27d6b8c5657b 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -60,7 +60,16 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 1 - + + - name: mount coverage dir + timeout-minutes: 5 + uses: ./.github/actions/mount-coverage-dir + with: + mount_point: cover + access_key: ${{ secrets.CI_COVERAGE_AWS_AK }} + secret_key: ${{ secrets.CI_COVERAGE_AWS_SK }} + token: ${{ secrets.CI_COVERAGE_AWS_TOKEN }} + - name: Build timeout-minutes: 10 uses: ./.github/actions/build @@ -102,10 +111,16 @@ jobs: test=${{matrix.test}} make $test + - name: upload coverage report + timeout-minutes: 5 + uses: ./.github/actions/upload-coverage + with: + UPLOAD_TOKEN: ${{ secrets.CI_COVERAGE_FILE_UPLOAD_AUTH_TOKEN }} + - name: Code Coverage uses: codecov/codecov-action@v3 with: - files: ./cov.out + files: cover/cover.txt - name: Setup upterm session if: failure() && (github.event.inputs.debug == 'true' || github.run_attempt != 1) diff --git a/Makefile b/Makefile index 1b76f20ddaac..428c47d47522 100644 --- a/Makefile +++ b/Makefile @@ -87,16 +87,16 @@ release: juicedata/golang-cross:latest release --rm-dist test.meta.core: - SKIP_NON_CORE=true go test -v -cover -count=1 -failfast -timeout=12m ./pkg/meta/... -coverprofile=cov.out + SKIP_NON_CORE=true go test -v -cover -count=1 -failfast -timeout=12m ./pkg/meta/... -args -test.gocoverdir="$(shell realpath cover/)" test.meta.non-core: - go test -v -cover -run='TestRedisCluster|TestPostgreSQLClient|TestLoadDumpSlow|TestEtcdClient|TestKeyDB' -count=1 -failfast -timeout=12m ./pkg/meta/... -coverprofile=cov.out + go test -v -cover -run='TestRedisCluster|TestPostgreSQLClient|TestLoadDumpSlow|TestEtcdClient|TestKeyDB' -count=1 -failfast -timeout=12m ./pkg/meta/... -args -test.gocoverdir="$(shell realpath cover/)" test.pkg: - go test -tags gluster -v -cover -count=1 -failfast -timeout=12m $$(go list ./pkg/... | grep -v /meta) -coverprofile=cov.out + go test -tags gluster -v -cover -count=1 -failfast -timeout=12m $$(go list ./pkg/... | grep -v /meta) -args -test.gocoverdir="$(shell realpath cover/)" test.cmd: - sudo JFS_GC_SKIPPEDTIME=1 MINIO_ACCESS_KEY=testUser MINIO_SECRET_KEY=testUserPassword GOMAXPROCS=8 go test -v -count=1 -failfast -cover -timeout=8m ./cmd/... -coverprofile=cov.out -coverpkg=./pkg/...,./cmd/... + sudo JFS_GC_SKIPPEDTIME=1 MINIO_ACCESS_KEY=testUser MINIO_SECRET_KEY=testUserPassword GOMAXPROCS=8 go test -v -count=1 -failfast -cover -timeout=8m ./cmd/... -coverpkg=./pkg/...,./cmd/... -args -test.gocoverdir="$(shell realpath cover/)" test.fdb: - go test -v -cover -count=1 -failfast -timeout=4m ./pkg/meta/ -tags fdb -run=TestFdb -coverprofile=cov.out + go test -v -cover -count=1 -failfast -timeout=4m ./pkg/meta/ -tags fdb -run=TestFdb -args -test.gocoverdir="$(shell realpath cover/)"