mirror of
https://github.com/lukaszraczylo/shared-actions.git
synced 2026-10-17 05:37:45 +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
|
required: false
|
||||||
type: string
|
type: string
|
||||||
default: "22"
|
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:
|
node:
|
||||||
description: "Update and test the Node project. Turn off for a repo with no frontend to test."
|
description: "Update and test the Node project. Turn off for a repo with no frontend to test."
|
||||||
required: false
|
required: false
|
||||||
@@ -314,15 +324,30 @@ jobs:
|
|||||||
cache: true
|
cache: true
|
||||||
cache-dependency-path: ${{ inputs.go-working-directory }}/go.sum
|
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
|
- name: Build and test Go
|
||||||
if: steps.merge.outputs.skip != 'true' && steps.detect.outputs.go == 'true'
|
if: steps.merge.outputs.skip != 'true' && steps.detect.outputs.go == 'true'
|
||||||
working-directory: ${{ inputs.go-working-directory }}
|
working-directory: ${{ inputs.go-working-directory }}
|
||||||
|
env:
|
||||||
|
GO_TEST_COMMAND: ${{ inputs.go-test-command }}
|
||||||
run: |
|
run: |
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
{
|
{
|
||||||
go mod verify
|
go mod verify
|
||||||
go build ./...
|
if [ -n "$GO_TEST_COMMAND" ]; then
|
||||||
go test -race -cover ./...
|
bash -c "$GO_TEST_COMMAND"
|
||||||
|
else
|
||||||
|
go build ./...
|
||||||
|
go test -race -cover ./...
|
||||||
|
fi
|
||||||
} 2>&1 | tee -a "$RUNNER_TEMP/test-output.log"
|
} 2>&1 | tee -a "$RUNNER_TEMP/test-output.log"
|
||||||
|
|
||||||
- name: Setup Node.js
|
- 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-version` | `>=1.24` | Go version |
|
||||||
| `go` | `true` | Update and test the Go module. Turn off for a repo with no Go code. |
|
| `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-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-version` | `22` | Node.js version |
|
||||||
| `node` | `true` | Update and test the Node project. Turn off for a repo with no frontend to test. |
|
| `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. |
|
| `node-working-directory` | `.` | Directory that holds `package.json`. Only this project is updated and tested. |
|
||||||
|
|||||||
Reference in New Issue
Block a user