diff --git a/.github/workflows/automation-integration-test-build.yml b/.github/workflows/automation-integration-test-build.yml new file mode 100644 index 0000000..c5d1fb1 --- /dev/null +++ b/.github/workflows/automation-integration-test-build.yml @@ -0,0 +1,50 @@ +name: Integration test build + +on: + workflow_call: + inputs: + test-source-path: + description: 'Path to the Go test suite directory' + required: true + type: string + repository: + description: 'Repository to checkout (defaults to calling repo)' + required: false + type: string + default: '' + ref: + description: 'Git ref to checkout. Accepts branch names (master, feature/foo), tags (v1.0.0), full refs (refs/heads/master, refs/tags/v1.0.0), or commit SHAs. Defaults to calling ref.' + required: false + type: string + default: '' + artifact-name: + description: 'Name for the uploaded test binary artifact' + required: false + type: string + default: 'integration-test-binary' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + repository: ${{ inputs.repository || github.repository }} + ref: ${{ inputs.ref || github.ref }} + + - name: Setup Go + uses: actions/setup-go@v6 + with: + go-version-file: ${{ inputs.test-source-path }}/go.mod + cache-dependency-path: ${{ inputs.test-source-path }}/go.sum + + - name: Build test binary + working-directory: ${{ inputs.test-source-path }} + run: go test -c -v -vet=off -o /tmp/test.bin + + - name: Upload test binary + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.artifact-name }} + path: /tmp/test.bin diff --git a/README.md b/README.md index 1824c81..d5d40c7 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Shared workflows and actions: - [Enforce PR labels](#enforce-pr-labels) - [Golang test suite](#golang-test-suite) - [Housekeeping](#housekeeping) + - [Integration test build](#integration-test-build) - [Multi architecture docker build](#multi-architecture-docker-build) - [Block on-hold PRs](#block-on-hold-prs) - [Add comment from PR template on Renovate pull requests](#add-comment-from-pr-template-on-renovate-pull-requests) @@ -162,6 +163,32 @@ jobs: status_checks: true ``` +### Integration test build + +_This is a workflow_ + +Builds a Go integration test binary and uploads it as an artifact. Designed for infrastructure integration tests that are compiled once and run against multiple environments. + +How to invoke this workflow: + +```yaml +name: Integration test build + +on: + push: + branches: [master] + +jobs: + build-test: + uses: dfds/shared-workflows/.github/workflows/automation-integration-test-build.yml@master + with: + test-source-path: test/integration/suite + repository: dfds/infrastructure-modules + ref: master + artifact-name: test-binary + +``` + ### Multi architecture docker build _This is a workflow_ diff --git a/examples/automation-integration-test-build.yml b/examples/automation-integration-test-build.yml new file mode 100644 index 0000000..4177ccb --- /dev/null +++ b/examples/automation-integration-test-build.yml @@ -0,0 +1,15 @@ +name: Integration test build +description: Builds a Go integration test binary and uploads it as an artifact. Designed for infrastructure integration tests that are compiled once and run against multiple environments. + +on: + push: + branches: [master] + +jobs: + build-test: + uses: dfds/shared-workflows/.github/workflows/automation-integration-test-build.yml@master + with: + test-source-path: test/integration/suite + repository: dfds/infrastructure-modules + ref: master + artifact-name: test-binary