Skip to content

Commit

Permalink
Validate that generated files are up to date
Browse files Browse the repository at this point in the history
  • Loading branch information
fionera committed Sep 2, 2023
1 parent 0c5d4ad commit 704c028
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
31 changes: 23 additions & 8 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
on: [push]

jobs:
lint:
Expand All @@ -29,6 +22,28 @@ jobs:
- name: Build
run: go build -v ./...

generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: Run go generate
run: |
go install golang.org/x/tools/cmd/stringer
go generate ./...
git diff --exit-code || (echo "Generated files have changed. Please run 'go generate' and commit the changes." && exit 1)
- name: Validate
run: |
go mod tidy
git diff --exit-code || (echo "go.mod or go.sum have changed. Please run 'go mod tidy' and commit the changes." && exit 1)
test:
runs-on: ubuntu-latest
steps:
Expand Down
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
module github.com/fionera/haproxy-go

go 1.20

require golang.org/x/tools v0.12.0

require (
golang.org/x/mod v0.12.0 // indirect
golang.org/x/sys v0.11.0 // indirect
)
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss=
golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
7 changes: 7 additions & 0 deletions tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build tools

package haproxy_go

import (
_ "golang.org/x/tools/cmd/stringer"
)

0 comments on commit 704c028

Please sign in to comment.