Skip to content

Commit 2fe89a1

Browse files
authored
Generate code coverage for tests in pipeline (#192)
1 parent 0aca4d9 commit 2fe89a1

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

.github/workflows/scenario-testing.yaml

Lines changed: 8 additions & 1 deletion
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 10 additions & 1 deletion
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)