Capture coverage of integration tests

To capture the coverage also for the integration tests,
a test only executing the cmd.Run function is used.

The test always exits with code 0 and prints the
real exit code to stdout. Otherwise no coverage
report is generated.

Those changes enable a more accurate coverage report
for future contributions.
This commit is contained in:
Benj Fassbind
2022-07-11 16:04:06 +02:00
parent 69d473ea6f
commit 1d4e6183be
9 changed files with 140 additions and 23 deletions
+15 -4
View File
@@ -51,10 +51,15 @@ jobs:
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- name: Get aptly version
run: |
make version
go generate
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
@@ -82,9 +87,9 @@ jobs:
with:
directory: ${{ runner.temp }}
- name: Get aptly version
- name: Create temp dir
run: |
make version
echo "COVERAGE_DIR=$(mktemp -d)" >> $GITHUB_ENV
- name: Make
env:
@@ -95,8 +100,14 @@ jobs:
run: |
make
- name: Merge code coverage
if: matrix.run_long_tests == 'yes'
run: |
go install github.com/wadey/gocovmerge@latest
~/go/bin/gocovmerge unit.out $COVERAGE_DIR/*.out > coverage.txt
- name: Upload code coverage
if: matrix.run_long_tests
if: matrix.run_long_tests == 'yes'
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}