Skip to content

Commit

Permalink
Added shared coverage folder for code cov
Browse files Browse the repository at this point in the history
  • Loading branch information
mirackara committed Dec 21, 2023
1 parent ec77f5a commit b5a4c51
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ jobs:
uses: actions/checkout@v2
with:
path: "go-agent"

- name: Create a directory for code coverage reports
run: mkdir -p ${{ github.workspace }}/coverage-reports

- name: Set up Codecov environment variables
run: ci_env=`bash <(curl -s https://codecov.io/env)`

- name: Build Docker Image
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

Expand All @@ -80,17 +85,23 @@ jobs:
IFS=',' read -ra DIRS <<< "${{ matrix.dirs }}"
for dir in "${DIRS[@]}"; do
if [ -d "go-agent/$dir" ]; then
coverage_dir="${{ github.workspace }}/coverage-reports/"
mkdir -p "$coverage_dir"
if [[ "$dir" == *"nrnats"* ]]; then
docker run $ci_env -e CI=true -e GOPROXY=direct go-agent-tests-amd64 ./go-agent/run-tests.sh "$dir"
docker run $ci_env -e CI=true -e GOPROXY=direct -v "$coverage_dir:/coverage" go-agent-tests-amd64 ./go-agent/run-tests.sh "$dir"
else
docker run $ci_env -e CI=true go-agent-tests-amd64 ./go-agent/run-tests.sh "$dir"
docker run $ci_env -e CI=true -v "$coverage_dir:/coverage" go-agent-tests-amd64 ./go-agent/run-tests.sh "$dir"
fi
else
echo "Directory /app/$dir does not exist."
fi
done
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ${{ github.workspace }}/coverage-reports/*


# Arm64 tests
go-agent-v3-arm64:
Expand Down Expand Up @@ -132,7 +143,4 @@ jobs:
else
echo "Directory /app/$dir does not exist."
fi
done
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
done
4 changes: 2 additions & 2 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ cd $TEST_DIR

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

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

0 comments on commit b5a4c51

Please sign in to comment.