mirror of
https://github.com/agresdominik/ci-pipelines.git
synced 2026-07-21 21:20:54 +00:00
feat(languages): go fmt pipeline
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
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: ${{ inputs.go-version-file }}
|
||||
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: ${{ inputs.go-version-file }}
|
||||
cache: true
|
||||
|
||||
- name: go vet
|
||||
run: go vet ./...
|
||||
Reference in New Issue
Block a user