diff --git a/.github/workflows/reusable-go-apps.yml b/.github/workflows/reusable-go-apps.yml index 7825c5b..78f9c27 100644 --- a/.github/workflows/reusable-go-apps.yml +++ b/.github/workflows/reusable-go-apps.yml @@ -23,6 +23,16 @@ on: type: string description: | extra args to pass `go test` + test-coverage-upload-role: + type: string + required: false + description: | + the AWS IAM role to use to upload test results to s3 bucket + test-coverage-upload-bucket: + type: string + required: false + description: | + the AWS S3 bucket name to upload test results to. jobs: go-build: if: ${{ contains(fromJSON('["workflow_call", "workflow_dispatch", "push", "pull_request"]'), github.event_name) && startsWith(github.repository, 'GeoNet/') != false }} @@ -40,10 +50,12 @@ jobs: setup: ${{ inputs.buildSetup }} 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@caS3-gotest with: setup: ${{ inputs.testSetup || inputs.buildSetup }} extraArgs: ${{ inputs.goTestExtraArgs }} + aws-role-arn-to-assume: ${{ inputs.test-coverage-upload-role }} + s3-bucket: ${{ inputs.test-coverage-upload-bucket }} go-vet: 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-vet.yml@main diff --git a/.github/workflows/reusable-go-test.yml b/.github/workflows/reusable-go-test.yml index 768b4ab..b3edc9a 100644 --- a/.github/workflows/reusable-go-test.yml +++ b/.github/workflows/reusable-go-test.yml @@ -12,6 +12,17 @@ on: type: string description: | extra args to pass `go test` + aws-role-arn-to-assume: + type: string + required: false + description: | + role to use to upload test results to s3 bucket, + see reusable-copy-to-s3 workflow for more detail. + s3-bucket: + type: string + required: false + description: | + the AWS S3 bucket name to upload test results to. jobs: go-test: runs-on: ubuntu-latest @@ -39,7 +50,7 @@ jobs: id: coverage-html run: | go tool cover -html=/tmp/coverage.out -o /tmp/coverage.html - - name: Upload test log + - name: Upload test log to GitHub Artifacts uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 if: always() with: @@ -50,3 +61,11 @@ jobs: if-no-files-found: error retention-days: 1 overwrite: true + - name: Upload test log to S3 + uses: GeoNet/Actions/.github/actions/copy-to-s3@caS3 + if: ${{ inputs.aws-role-arn-to-assume && inputs.s3-bucket }} + with: + aws-role-arn-to-assume: ${{ inputs.aws-role-arn-to-assume }} + artifact-name: test-results + artifact-path: ./coverage + s3-bucket-uri: s3://${{inputs.s3-bucket}}/test-coverage-results/${{github.repository}}/go/ \ No newline at end of file