-
Notifications
You must be signed in to change notification settings - Fork 3
feat(workflows): add shared Go lint, test, build, release, and e2e reusable workflows #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
onuryilmaz
wants to merge
28
commits into
main
Choose a base branch
from
feat/shared-go-workflows
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
346cfaa
feat(workflows): add shared Go lint, test, build, release, and e2e re…
onuryilmaz 346f2b9
fix(workflows): address Copilot review comments
onuryilmaz 7147bd9
fix(workflows): add explicit permissions: contents: read to shared-go…
onuryilmaz 1e884b1
fix(workflows): harden shared-release.yaml
onuryilmaz 845b28e
fix(workflows): address abhijith-darshan review comments
onuryilmaz 74c09c7
fix(workflows): drop go-version input, always use go-version-file fro…
onuryilmaz bf067fd
fix(workflows): fix git add quoting and add missing permissions to li…
onuryilmaz 42b719b
fix(workflows): add guards for makefile-path and dispatch inputs
onuryilmaz c413099
chore: update status file with review round 4 changes
onuryilmaz f4bdca7
Revert "chore: update status file with review round 4 changes"
onuryilmaz c395839
refactor(workflows): commit version bump directly to default branch; …
onuryilmaz 843a3a8
fix(workflows): address Copilot review round 5 comments
onuryilmaz b752974
fix(workflows): run Greenhouse composite action before checking out c…
onuryilmaz b75e569
fix(workflows): address Copilot review round 6 comments
onuryilmaz 3ee7407
fix(workflows): address Copilot review round 7 comments
onuryilmaz cc53b89
fix(workflows): address Copilot review round 8 comments
onuryilmaz 84169ad
fix(workflows): address Copilot review round 9 comments
onuryilmaz 4533eba
fix(workflows): address Copilot review round 10 comments
onuryilmaz afe7634
fix(workflows): address Copilot review round 11 comments
onuryilmaz a1bbe7f
fix(workflows): add concurrency group to shared-release to prevent races
onuryilmaz 0f01479
fix(workflows): eliminate all inline template expressions in run: steps
onuryilmaz c5223f6
fix(workflows): quote govulncheck module@version argument
onuryilmaz 776800c
fix(workflows): add runner OS guard to test and build workflows
onuryilmaz fb71994
fix(workflows): remove unused GH_TOKEN from Commit version bump step
onuryilmaz 3ead49e
fix(workflows): anchor IMG sed to line start; add Linux runner guard …
onuryilmaz 3b5289e
fix(workflows): clarify makefile-path and bump-make-version input des…
onuryilmaz c8b144f
fix(e2e): replace undefined k8s-version and matrix context with valid…
onuryilmaz 09410c1
fix(workflows): support chart-only version computation; makefile-path…
onuryilmaz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| name: Shared E2E | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| runs-on: | ||
| description: "The runner to use for the job" | ||
| required: false | ||
| default: "ubuntu-latest" | ||
| type: string | ||
| greenhouse-ref: | ||
| description: "Ref (branch, tag, or SHA) of cloudoperators/greenhouse to deploy" | ||
| required: false | ||
| default: "main" | ||
| type: string | ||
| admin-k8s-version: | ||
| description: "Kubernetes node image tag for the admin KinD cluster (e.g. v1.31.0)" | ||
| required: true | ||
| type: string | ||
| remote-k8s-version: | ||
| description: "Kubernetes node image tag for the remote KinD cluster (e.g. v1.31.0)" | ||
| required: true | ||
| type: string | ||
| scenario: | ||
| description: "E2E scenario name passed to the composite action and make target" | ||
| required: true | ||
| type: string | ||
| test-target: | ||
| description: "The make target in the calling repo used to run e2e tests" | ||
| required: false | ||
| default: "e2e" | ||
| type: string | ||
| working-directory: | ||
| description: "Working directory for the make test target" | ||
| required: false | ||
| default: "." | ||
| type: string | ||
| environment: | ||
| description: "GitHub environment name to use for this job (optional)" | ||
| required: false | ||
| default: "" | ||
| type: string | ||
| jobs: | ||
| e2e: | ||
| runs-on: ${{ inputs.runs-on }} | ||
| environment: ${{ inputs.environment != '' && inputs.environment || null }} | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
|
Copilot marked this conversation as resolved.
|
||
| - name: Run Greenhouse E2E composite action | ||
| uses: cloudoperators/common/workflows/e2e@main | ||
| with: | ||
|
onuryilmaz marked this conversation as resolved.
|
||
| admin-k8s-version: ${{ inputs.admin-k8s-version }} | ||
| remote-k8s-version: ${{ inputs.remote-k8s-version }} | ||
|
onuryilmaz marked this conversation as resolved.
|
||
| scenario: ${{ inputs.scenario }} | ||
| ref: ${{ inputs.greenhouse-ref }} | ||
|
onuryilmaz marked this conversation as resolved.
onuryilmaz marked this conversation as resolved.
onuryilmaz marked this conversation as resolved.
onuryilmaz marked this conversation as resolved.
onuryilmaz marked this conversation as resolved.
|
||
|
|
||
|
onuryilmaz marked this conversation as resolved.
|
||
| - name: Checkout calling repository | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
|
onuryilmaz marked this conversation as resolved.
|
||
| with: | ||
| path: caller | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5 | ||
| with: | ||
| go-version-file: caller/${{ inputs.working-directory != '.' && format('{0}/go.mod', inputs.working-directory) || 'go.mod' }} | ||
| cache: true | ||
|
|
||
|
abhijith-darshan marked this conversation as resolved.
|
||
| - name: Run e2e tests | ||
| working-directory: caller/${{ inputs.working-directory }} | ||
| env: | ||
| TEST_TARGET: ${{ inputs.test-target }} | ||
| run: make "$TEST_TARGET" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| name: Shared Go Build | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| runs-on: | ||
| description: "The runner to use for the job" | ||
| required: false | ||
| default: "ubuntu-latest" | ||
| type: string | ||
| working-directory: | ||
| description: "Working directory for the job" | ||
| required: false | ||
| default: "." | ||
| type: string | ||
| build-target: | ||
| description: "The make target to run for the build (e.g. build, build-all, docker-build)" | ||
| required: false | ||
| default: "build" | ||
| type: string | ||
| docker-build: | ||
| description: "Build and optionally push a Docker image after the Go build" | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
| image-name: | ||
| description: "Full GHCR image name, e.g. ghcr.io/cloudoperators/myapp (must start with ghcr.io/ when push is true)" | ||
| required: false | ||
| default: "" | ||
| type: string | ||
|
onuryilmaz marked this conversation as resolved.
onuryilmaz marked this conversation as resolved.
|
||
| platforms: | ||
| description: "Comma-separated list of target platforms for the Docker image" | ||
| required: false | ||
| default: "linux/amd64,linux/arm64" | ||
| type: string | ||
| push: | ||
| description: "Push the built Docker image to the registry" | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
| secrets: | ||
| registry-token: | ||
| description: "Token used to authenticate to the container registry when pushing" | ||
| required: false | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ${{ inputs.runs-on }} | ||
| permissions: | ||
| contents: read | ||
| packages: ${{ inputs.push == true && 'write' || 'read' }} | ||
| defaults: | ||
| run: | ||
| working-directory: ${{ inputs.working-directory }} | ||
|
onuryilmaz marked this conversation as resolved.
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5 | ||
| with: | ||
| go-version-file: ${{ format('{0}/go.mod', inputs.working-directory) }} | ||
| cache: true | ||
|
Copilot marked this conversation as resolved.
|
||
| cache-dependency-path: ${{ format('{0}/go.sum', inputs.working-directory) }} | ||
|
|
||
| - name: Build | ||
| env: | ||
| BUILD_TARGET: ${{ inputs.build-target }} | ||
| run: make "$BUILD_TARGET" | ||
|
onuryilmaz marked this conversation as resolved.
|
||
|
|
||
| - name: Validate docker-build inputs | ||
| if: inputs.docker-build == true | ||
| run: | | ||
| if [ -z "${{ inputs.image-name }}" ]; then | ||
| echo "ERROR: image-name is required when docker-build is true" | ||
| exit 1 | ||
| fi | ||
|
onuryilmaz marked this conversation as resolved.
onuryilmaz marked this conversation as resolved.
|
||
| if [ "${{ inputs.push }}" = "true" ] && [[ "${{ inputs.image-name }}" != ghcr.io/* ]]; then | ||
| echo "ERROR: image-name must start with 'ghcr.io/' when push is true (got: '${{ inputs.image-name }}')" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Set up QEMU | ||
| if: inputs.docker-build == true | ||
| uses: docker/setup-qemu-action@29109295f81e9208d7d86ff9c25c0e60b9eba63c # v3 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| if: inputs.docker-build == true | ||
| uses: docker/setup-buildx-action@b5730b4fe97e6f9f14b9d7bb5f0f0b9f75a3b6ca # v3 | ||
|
|
||
| - name: Log in to container registry | ||
| if: inputs.docker-build == true && inputs.push == true | ||
| uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.registry-token != '' && secrets.registry-token || secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Extract Docker metadata | ||
| if: inputs.docker-build == true | ||
| id: meta | ||
| uses: docker/metadata-action@902fa8ec7d6ecbea8a63d9c1064e4b9e02685b72 # v5 | ||
| with: | ||
| images: ${{ inputs.image-name }} | ||
|
onuryilmaz marked this conversation as resolved.
|
||
|
|
||
| - name: Build and push Docker image | ||
| if: inputs.docker-build == true | ||
| uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6 | ||
| with: | ||
| context: ${{ inputs.working-directory }} | ||
| platforms: ${{ inputs.platforms }} | ||
| push: ${{ inputs.push }} | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| name: Shared Go Lint | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| runs-on: | ||
| description: "The runner to use for the job" | ||
| required: false | ||
| default: "ubuntu-latest" | ||
| type: string | ||
| golangci-lint-version: | ||
| description: "golangci-lint version to use" | ||
| required: false | ||
| default: "latest" | ||
| type: string | ||
| working-directory: | ||
| description: "Working directory for the job" | ||
| required: false | ||
| default: "." | ||
| type: string | ||
| enable-govulncheck: | ||
| description: "Run govulncheck in addition to golangci-lint" | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
|
onuryilmaz marked this conversation as resolved.
|
||
| govulncheck-version: | ||
| description: "Version of govulncheck to use (e.g. latest or v1.1.3)" | ||
| required: false | ||
| default: "latest" | ||
| type: string | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ${{ inputs.runs-on }} | ||
| permissions: | ||
| contents: read | ||
| defaults: | ||
|
onuryilmaz marked this conversation as resolved.
|
||
| run: | ||
| working-directory: ${{ inputs.working-directory }} | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5 | ||
| with: | ||
| go-version-file: ${{ format('{0}/go.mod', inputs.working-directory) }} | ||
| cache: true | ||
|
Copilot marked this conversation as resolved.
|
||
| cache-dependency-path: ${{ format('{0}/go.sum', inputs.working-directory) }} | ||
|
|
||
| - name: Run golangci-lint | ||
| uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0 | ||
| with: | ||
| version: ${{ inputs.golangci-lint-version }} | ||
| working-directory: ${{ inputs.working-directory }} | ||
|
|
||
| - name: Run govulncheck | ||
| if: inputs.enable-govulncheck == true | ||
| run: go run golang.org/x/vuln/cmd/govulncheck@${{ inputs.govulncheck-version }} ./... | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| name: Shared Go Test | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| runs-on: | ||
| description: "The runner to use for the job" | ||
| required: false | ||
| default: "ubuntu-latest" | ||
| type: string | ||
| working-directory: | ||
| description: "Working directory for the job" | ||
| required: false | ||
| default: "." | ||
| type: string | ||
| test-target: | ||
| description: "The make target to run for tests" | ||
| required: false | ||
| default: "test" | ||
| type: string | ||
| upload-coverage: | ||
| description: "Upload coverage report as an artifact" | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
| coverage-artifact-name: | ||
| description: "Name of the coverage artifact" | ||
| required: false | ||
| default: "code-coverage" | ||
| type: string | ||
| coverage-path: | ||
| description: "Path to the coverage output file" | ||
| required: false | ||
| default: "build/cover.out" | ||
| type: string | ||
| extra-env: | ||
| description: "Extra environment variables as newline-separated KEY=VALUE pairs" | ||
| required: false | ||
| default: "" | ||
| type: string | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ${{ inputs.runs-on }} | ||
| permissions: | ||
| contents: read | ||
| defaults: | ||
| run: | ||
| working-directory: ${{ inputs.working-directory }} | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5 | ||
| with: | ||
| go-version-file: ${{ format('{0}/go.mod', inputs.working-directory) }} | ||
| cache: true | ||
|
onuryilmaz marked this conversation as resolved.
Copilot marked this conversation as resolved.
|
||
| cache-dependency-path: ${{ format('{0}/go.sum', inputs.working-directory) }} | ||
|
|
||
| - name: Download Go modules | ||
| run: go mod download | ||
|
|
||
| - name: Set extra environment variables | ||
| if: inputs.extra-env != '' | ||
| env: | ||
| EXTRA_ENV: ${{ inputs.extra-env }} | ||
| run: | | ||
| printf '%s\n' "$EXTRA_ENV" >> "$GITHUB_ENV" | ||
|
onuryilmaz marked this conversation as resolved.
|
||
|
|
||
| - name: Run tests | ||
| env: | ||
| TEST_TARGET: ${{ inputs.test-target }} | ||
| run: make "$TEST_TARGET" | ||
|
onuryilmaz marked this conversation as resolved.
|
||
|
|
||
| - name: Upload coverage report | ||
| if: inputs.upload-coverage == true | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | ||
| with: | ||
| name: ${{ inputs.coverage-artifact-name }} | ||
| path: ${{ inputs.working-directory != '.' && format('{0}/{1}', inputs.working-directory, inputs.coverage-path) || inputs.coverage-path }} | ||
| if-no-files-found: warn | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.