Skip to content

Commit

Permalink
fix: add a go-test option to upload coverage artifacts
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ozym committed Oct 29, 2024
1 parent 12c9a58 commit 33bb69b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/reusable-go-container-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/reusable-go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 33bb69b

Please sign in to comment.