From 9cb0dc735a86724f21ef10596ed94d5cc31aa672 Mon Sep 17 00:00:00 2001 From: vmarcella Date: Thu, 28 Mar 2024 16:26:18 -0700 Subject: [PATCH 1/4] [add] code coverage generation. --- .github/workflows/scenario-testing.yaml | 9 ++++++++- Makefile | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/scenario-testing.yaml b/.github/workflows/scenario-testing.yaml index 023608ea..92952439 100644 --- a/.github/workflows/scenario-testing.yaml +++ b/.github/workflows/scenario-testing.yaml @@ -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.out - 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 }} diff --git a/Makefile b/Makefile index a65ba58c..8e9a15bb 100644 --- a/Makefile +++ b/Makefile @@ -21,10 +21,17 @@ install-ie: # ------------------------------ Test targets ---------------------------------- +WITH_COVERAGE:=false test-all: - @echo "Running all tests..." @go clean -testcache - @go test -v ./... + 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 ./... + SUBSCRIPTION ?= 00000000-0000-0000-0000-000000000000 SCENARIO ?= ./README.md From 1251354f34931417e20c3809de9d05c9a2575a15 Mon Sep 17 00:00:00 2001 From: vmarcella Date: Thu, 28 Mar 2024 16:36:51 -0700 Subject: [PATCH 2/4] [fix] indentation and add coverage files to git ignore. --- .gitignore | 4 ++++ Makefile | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index c76f479a..d8c21bc6 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,7 @@ bin/ # Ignore ie logs ie.log + +# Ignore test coverage +coverage.html +coverage.out diff --git a/Makefile b/Makefile index 8e9a15bb..a09a2f82 100644 --- a/Makefile +++ b/Makefile @@ -21,16 +21,18 @@ install-ie: # ------------------------------ Test targets ---------------------------------- -WITH_COVERAGE:=false +WITH_COVERAGE := false + test-all: @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 ./... +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 From 5077e1a3d62f36434dc5e5cd40dacc68d51c083d Mon Sep 17 00:00:00 2001 From: vmarcella Date: Thu, 28 Mar 2024 16:38:29 -0700 Subject: [PATCH 3/4] [update] spacing. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a09a2f82..82e12250 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ WITH_COVERAGE := false test-all: @go clean -testcache -ifeq ($(WITH_COVERAGE),true) +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 From 9713a2f1c07702d19a04a636d5ab3f2e0e782a51 Mon Sep 17 00:00:00 2001 From: vmarcella Date: Thu, 28 Mar 2024 16:41:26 -0700 Subject: [PATCH 4/4] [add] correct file. --- .github/workflows/scenario-testing.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scenario-testing.yaml b/.github/workflows/scenario-testing.yaml index 92952439..c1f2b1ce 100644 --- a/.github/workflows/scenario-testing.yaml +++ b/.github/workflows/scenario-testing.yaml @@ -45,7 +45,7 @@ jobs: if: github.event_name == 'pull_request' with: name: coverage - path: coverage.out + path: coverage.html - name: Sign into Azure uses: azure/login@v1 if: github.event_name != 'pull_request'