From 33bb69b10c4ceb0d48f12fa3d57fb4b9705aeee2 Mon Sep 17 00:00:00 2001 From: Mark Chadwick Date: Wed, 30 Oct 2024 09:51:23 +1300 Subject: [PATCH] fix: add a go-test option to upload coverage artifacts This is to fix a breaking change in the v4 artifact upload action. It requires unique names for uploads, but if the action is called multiple times in a run it will hit this error. Options are have a unique name per run, or simply not do the upload. I expect a future action that simply does test coverage will would be a simpler option if needed. --- .github/workflows/reusable-go-container-apps.yml | 2 +- .github/workflows/reusable-go-test.yml | 9 ++++++++- README.md | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable-go-container-apps.yml b/.github/workflows/reusable-go-container-apps.yml index c9d7c8f0..9a974a91 100644 --- a/.github/workflows/reusable-go-container-apps.yml +++ b/.github/workflows/reusable-go-container-apps.yml @@ -142,7 +142,7 @@ jobs: setup: ${{ inputs.golangciSetup }} go-test: if: ${{ contains(fromJSON('["workflow_call", "workflow_dispatch", "push", "pull_request"]'), github.event_name) && startsWith(github.repository, 'GeoNet/') != false }} - uses: GeoNet/Actions/.github/workflows/reusable-go-test.yml@main + uses: GeoNet/Actions/.github/workflows/reusable-go-test.yml@go-coverage with: setup: ${{ inputs.testSetup }} extraArgs: ${{ inputs.goTestExtraArgs }} diff --git a/.github/workflows/reusable-go-test.yml b/.github/workflows/reusable-go-test.yml index 768b4abb..0d8ba667 100644 --- a/.github/workflows/reusable-go-test.yml +++ b/.github/workflows/reusable-go-test.yml @@ -12,6 +12,13 @@ on: type: string description: | extra args to pass `go test` + upload: + required: false + default: false + type: boolean + description: | + set to true to push test coverage as an artifact + jobs: go-test: runs-on: ubuntu-latest @@ -41,7 +48,7 @@ jobs: go tool cover -html=/tmp/coverage.out -o /tmp/coverage.html - name: Upload test log uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 - if: always() + if: ${{ inputs.upload }} with: name: test-results path: | diff --git a/README.md b/README.md index 7cf6424a..5c9c0bd1 100644 --- a/README.md +++ b/README.md @@ -607,7 +607,7 @@ jobs: uses: GeoNet/Actions/.github/workflows/reusable-go-test.yml@main ``` -test coverage results upload to job artifacts, found at the bottom of a job summary page. +test coverage results can be uploaded to job artifacts, found at the bottom of a job summary page. ### Go vulnerability check