Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0ce5041

Browse files
authoredMar 28, 2024··
Generate code coverage for tests in pipeline (#192)
1 parent a8f3a02 commit 0ce5041

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed
 

‎.github/workflows/scenario-testing.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,16 @@ jobs:
3939
- name: Build all targets.
4040
run: |
4141
make build-all
42-
make test-all
42+
make test-all WITH_COVERAGE=true
43+
- name: Upload test coverage
44+
uses: actions/upload-artifact@v2
45+
if: github.event_name == 'pull_request'
46+
with:
47+
name: coverage
48+
path: coverage.html
4349
- name: Sign into Azure
4450
uses: azure/login@v1
51+
if: github.event_name != 'pull_request'
4552
with:
4653
client-id: ${{ secrets.AZURE_CLIENT_ID }}
4754
tenant-id: ${{ secrets.AZURE_TENANT_ID }}

‎.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ bin/
99

1010
# Ignore ie logs
1111
ie.log
12+
13+
# Ignore test coverage
14+
coverage.html
15+
coverage.out

‎Makefile

+10-1
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,19 @@ install-ie:
2121

2222
# ------------------------------ Test targets ----------------------------------
2323

24+
WITH_COVERAGE := false
25+
2426
test-all:
25-
@echo "Running all tests..."
2627
@go clean -testcache
28+
ifeq ($(WITH_COVERAGE), true)
29+
@echo "Running all tests with coverage..."
30+
@go test -v -coverprofile=coverage.out ./...
31+
@go tool cover -html=coverage.out -o coverage.html
32+
else
33+
@echo "Running all tests..."
2734
@go test -v ./...
35+
endif
36+
2837

2938
SUBSCRIPTION ?= 00000000-0000-0000-0000-000000000000
3039
SCENARIO ?= ./README.md

0 commit comments

Comments
 (0)
Please sign in to comment.