Skip to content

Commit

Permalink
Generate code coverage for tests in pipeline (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarcella authored Mar 28, 2024
1 parent 0aca4d9 commit 2fe89a1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/scenario-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,16 @@ jobs:
- name: Build all targets.
run: |
make build-all
make test-all
make test-all WITH_COVERAGE=true
- name: Upload test coverage
uses: actions/upload-artifact@v2
if: github.event_name == 'pull_request'
with:
name: coverage
path: coverage.html
- name: Sign into Azure
uses: azure/login@v1
if: github.event_name != 'pull_request'
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ bin/

# Ignore ie logs
ie.log

# Ignore test coverage
coverage.html
coverage.out
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,19 @@ install-ie:

# ------------------------------ Test targets ----------------------------------

WITH_COVERAGE := false

test-all:
@echo "Running all tests..."
@go clean -testcache
ifeq ($(WITH_COVERAGE), true)
@echo "Running all tests with coverage..."
@go test -v -coverprofile=coverage.out ./...
@go tool cover -html=coverage.out -o coverage.html
else
@echo "Running all tests..."
@go test -v ./...
endif


SUBSCRIPTION ?= 00000000-0000-0000-0000-000000000000
SCENARIO ?= ./README.md
Expand Down

0 comments on commit 2fe89a1

Please sign in to comment.