From b10b9aeb84c143aa0798c24f1337d6e3c0cdfbce 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-test.yml | 9 ++++++++- README.md | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-go-test.yml b/.github/workflows/reusable-go-test.yml index 768b4ab..0d8ba66 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 7cf6424..5c9c0bd 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