mirror of
https://github.com/agresdominik/ci-pipelines.git
synced 2026-07-21 23:30:55 +00:00
53 lines
1.1 KiB
YAML
53 lines
1.1 KiB
YAML
name: Go Format
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
go-version-file:
|
|
description: "Path to go.mod for version resolution"
|
|
type: string
|
|
default: "go.mod"
|
|
run-vet:
|
|
description: "Also run go vet"
|
|
type: boolean
|
|
default: true
|
|
|
|
jobs:
|
|
fmt:
|
|
name: gofmt
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
|
|
- name: Check formatting
|
|
run: |
|
|
unformatted=$(gofmt -l .)
|
|
if [ -n "$unformatted" ]; then
|
|
echo "::error::The following files are not gofmt-formatted:"
|
|
echo "$unformatted"
|
|
echo ""
|
|
echo "Run: gofmt -w ."
|
|
exit 1
|
|
fi
|
|
|
|
vet:
|
|
name: go vet
|
|
runs-on: ubuntu-latest
|
|
needs: fmt
|
|
if: ${{ inputs.run-vet }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
|
|
- name: go vet
|
|
run: go vet ./...
|