go-test.yml: allow for setting custom action #1
This file contains 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
name: Lint & Test Go | |
on: | |
workflow_call: | |
inputs: | |
try-build: | |
description: "Attempt to build the project" | |
type: boolean | |
required: false | |
default: true | |
go-test-setup: | |
description: Runs the specified action before the test job | |
type: string | |
required: false | |
default: "" | |
jobs: | |
test: | |
strategy: | |
matrix: | |
go-version: [1.22, 1.23] | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Configure Git # required for golangci-lint on Windows | |
if: startsWith(matrix.os, 'windows') | |
shell: bash | |
run: git config --global core.autocrlf false | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Test Setup # optional test setup step | |
uses: ${{ inputs.go-test-setup }} | |
if: ${{ inputs.go-test-setup != '' }} | |
- uses: SiaFoundation/workflows/.github/actions/go-test@master | |
- name: Build | |
if: ${{ inputs.try-build }} | |
shell: bash | |
run: | | |
go mod download | |
go build -o bin/ ./... | |
success: # Use in branch rulesets to ensure all matrix jobs completed successfully | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo "Success!" |