mirror of
https://github.com/lukaszraczylo/shared-actions.git
synced 2026-10-13 04:58:51 +00:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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. |
|
||||
|
||||
Reference in New Issue
Block a user