From 319b564d14883c0032eb76bf4513744d6370038d Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Sat, 3 Oct 2026 21:30:17 +0100 Subject: [PATCH] feat(autoupdate): let a repo set its own Go prepare and test commands An Encore app cannot be tested with plain go build and go test. Add go-prepare-command, which runs before the tests, and go-test-command, which replaces the default Go build and test commands. --- .github/workflows/renovate-autoupdate.yaml | 29 ++++++++++++++++++++-- README.md | 2 ++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/renovate-autoupdate.yaml b/.github/workflows/renovate-autoupdate.yaml index 8429092..ef8526f 100644 --- a/.github/workflows/renovate-autoupdate.yaml +++ b/.github/workflows/renovate-autoupdate.yaml @@ -28,6 +28,16 @@ on: required: false type: string default: "22" + go-prepare-command: + description: "Shell commands to run before the Go tests, for example installing a CLI. To put a tool on PATH, append its directory to $GITHUB_PATH." + required: false + type: string + default: "" + go-test-command: + description: "Replaces the default Go build and test commands, for example 'encore test ./...' for an Encore app. It runs in go-working-directory." + required: false + type: string + default: "" node: description: "Update and test the Node project. Turn off for a repo with no frontend to test." required: false @@ -314,15 +324,30 @@ jobs: cache: true cache-dependency-path: ${{ inputs.go-working-directory }}/go.sum + - name: Prepare Go + if: steps.merge.outputs.skip != 'true' && steps.detect.outputs.go == 'true' && inputs.go-prepare-command != '' + working-directory: ${{ inputs.go-working-directory }} + env: + GO_PREPARE_COMMAND: ${{ inputs.go-prepare-command }} + run: | + set -o pipefail + bash -c "$GO_PREPARE_COMMAND" 2>&1 | tee -a "$RUNNER_TEMP/test-output.log" + - name: Build and test Go if: steps.merge.outputs.skip != 'true' && steps.detect.outputs.go == 'true' working-directory: ${{ inputs.go-working-directory }} + env: + GO_TEST_COMMAND: ${{ inputs.go-test-command }} run: | set -o pipefail { go mod verify - go build ./... - go test -race -cover ./... + if [ -n "$GO_TEST_COMMAND" ]; then + bash -c "$GO_TEST_COMMAND" + else + go build ./... + go test -race -cover ./... + fi } 2>&1 | tee -a "$RUNNER_TEMP/test-output.log" - name: Setup Node.js diff --git a/README.md b/README.md index 06d3a3c..a36585b 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,8 @@ The workflow finds `go.mod` and `package.json` itself and tests what exists. A r | `go-version` | `>=1.24` | Go version | | `go` | `true` | Update and test the Go module. Turn off for a repo with no Go code. | | `go-working-directory` | `.` | Directory that holds `go.mod`. Only this module is updated and tested. | +| `go-prepare-command` | | Shell commands to run before the Go tests, for example installing a CLI. Append a tool directory to `$GITHUB_PATH` to put it on `PATH`. | +| `go-test-command` | | Replaces the default `go build` and `go test`, for example `encore test ./...` for an Encore app. | | `node-version` | `22` | Node.js version | | `node` | `true` | Update and test the Node project. Turn off for a repo with no frontend to test. | | `node-working-directory` | `.` | Directory that holds `package.json`. Only this project is updated and tested. |