Skip to content

Commit b5a4c51

Browse files
committed
Added shared coverage folder for code cov
1 parent ec77f5a commit b5a4c51

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

.github/workflows/ci.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,13 @@ jobs:
7070
uses: actions/checkout@v2
7171
with:
7272
path: "go-agent"
73+
74+
- name: Create a directory for code coverage reports
75+
run: mkdir -p ${{ github.workspace }}/coverage-reports
76+
7377
- name: Set up Codecov environment variables
7478
run: ci_env=`bash <(curl -s https://codecov.io/env)`
79+
7580
- name: Build Docker Image
7681
run: docker build -f ${{ github.workspace }}/go-agent/Dockerfile ${{ github.workspace }} --build-arg GO_VERSION=${{ matrix.go-version || env.INTEGRATION_TESTS_GO_VERSION }} -t go-agent-tests-amd64
7782

@@ -80,17 +85,23 @@ jobs:
8085
IFS=',' read -ra DIRS <<< "${{ matrix.dirs }}"
8186
for dir in "${DIRS[@]}"; do
8287
if [ -d "go-agent/$dir" ]; then
88+
coverage_dir="${{ github.workspace }}/coverage-reports/"
89+
mkdir -p "$coverage_dir"
8390
if [[ "$dir" == *"nrnats"* ]]; then
84-
docker run $ci_env -e CI=true -e GOPROXY=direct go-agent-tests-amd64 ./go-agent/run-tests.sh "$dir"
91+
docker run $ci_env -e CI=true -e GOPROXY=direct -v "$coverage_dir:/coverage" go-agent-tests-amd64 ./go-agent/run-tests.sh "$dir"
8592
else
86-
docker run $ci_env -e CI=true go-agent-tests-amd64 ./go-agent/run-tests.sh "$dir"
93+
docker run $ci_env -e CI=true -v "$coverage_dir:/coverage" go-agent-tests-amd64 ./go-agent/run-tests.sh "$dir"
8794
fi
8895
else
8996
echo "Directory /app/$dir does not exist."
9097
fi
9198
done
99+
92100
- name: Upload coverage to Codecov
93101
uses: codecov/codecov-action@v3
102+
with:
103+
files: ${{ github.workspace }}/coverage-reports/*
104+
94105

95106
# Arm64 tests
96107
go-agent-v3-arm64:
@@ -132,7 +143,4 @@ jobs:
132143
else
133144
echo "Directory /app/$dir does not exist."
134145
fi
135-
done
136-
137-
- name: Upload coverage to Codecov
138-
uses: codecov/codecov-action@v3
146+
done

run-tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ cd $TEST_DIR
2121

2222
go mod tidy
2323
# Run Tests and Create Cover Profile for Code Coverage
24-
go test -race -benchtime=1ms -bench=. -coverprofile=coverage.out -covermode=atomic -coverpkg=./... ./...
24+
go test -race -benchtime=1ms -bench=. -coverprofile=/coverage/coverage.out -covermode=atomic -coverpkg=./... ./...
2525
go vet ./...
2626
verify_go_fmt
2727

2828
# Remove sql_driver_optional_methods from coverage.out file if it exists
29-
sed -i '/sql_driver_optional_methods/d' coverage.out
29+
sed -i '/sql_driver_optional_methods/d' /coverage/coverage.out

0 commit comments

Comments
 (0)