Skip to content

Commit 12501b1

Browse files
committed
chore (workflows): add make-gen-delta workflow
This workflow is intended to catch changes which should have been add from running "make gen". This includes changes from: make proto make fmt go mod tidy
1 parent 19375fc commit 12501b1

File tree

8 files changed

+70
-13
lines changed

8 files changed

+70
-13
lines changed

.github/workflows/make-gen-delta.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "make-gen-delta"
2+
on:
3+
- workflow_dispatch
4+
- push
5+
- workflow_call
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
make-gen-delta:
12+
name: "Check for uncommitted changes from make gen"
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
16+
with:
17+
fetch-depth: '0'
18+
- name: Determine Go version
19+
id: get-go-version
20+
# We use .go-version as our source of truth for current Go
21+
# version, because "goenv" can react to it automatically.
22+
run: |
23+
echo "Building with Go $(cat .go-version)"
24+
echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT"
25+
- name: Set up Go
26+
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
27+
with:
28+
go-version: "${{ steps.get-go-version.outputs.go-version }}"
29+
- name: Running go mod tidy
30+
run: |
31+
go mod tidy
32+
- name: Install Dependencies
33+
run: |
34+
make tools
35+
- name: Running make gen
36+
run: |
37+
make gen
38+
- name: Check for changes
39+
run: |
40+
git diff --exit-code
41+
git status --porcelain
42+
test -z "$(git status --porcelain)"

Makefile

+12-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,20 @@ REPO_PATH := github.com/hashicorp/dbw
99
.PHONY: tools
1010
tools:
1111
go generate -tags tools tools/tools.go
12+
go install github.com/bufbuild/buf/cmd/buf@v1.15.1
13+
go install github.com/hashicorp/copywrite@v0.15.0
1214

1315
.PHONY: fmt
1416
fmt:
15-
gofumpt -w $$(find . -name '*.go' | grep -v pb.go)
17+
gofumpt -w $$(find . -name '*.go' ! -name '*pb.go')
18+
buf format -w
19+
20+
.PHONY: copywrite
21+
copywrite:
22+
copywrite headers
23+
24+
.PHONY: gen
25+
gen: proto fmt copywrite
1626

1727
.PHONY: test
1828
test:
@@ -39,11 +49,7 @@ proto: protolint protobuild
3949

4050
.PHONY: protobuild
4151
protobuild:
42-
protoc \
43-
./internal/proto/local/dbtest/storage/v1/dbtest.proto \
44-
--proto_path=internal/proto/local \
45-
--go_out=:.
46-
52+
buf generate
4753
@protoc-go-inject-tag -input=./internal/dbtest/dbtest.pb.go
4854

4955
.PHONY: protolint

buf.gen.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) HashiCorp, Inc.
2+
# SPDX-License-Identifier: BUSL-1.1
3+
4+
version: v1
5+
plugins:
6+
- name: go
7+
out: .
8+
opt:
9+
- paths=import

clause.go

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ func SetColumns(names []string) []ColumnValue {
101101
// OnConflict specifies how to handle alternative actions to take when an insert
102102
// results in a unique constraint or exclusion constraint error.
103103
type OnConflict struct {
104-
105104
// Target specifies what conflict you want to define a policy for. This can
106105
// be any one of these:
107106
// Columns: the name of a specific column or columns

db_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ func TestOpen(t *testing.T) {
119119
rows, err := rw.Query(context.Background(), "PRAGMA foreign_keys", nil)
120120
require.NoError(err)
121121
require.True(rows.Next())
122-
type foo struct {
123-
}
122+
type foo struct{}
124123
f := struct {
125124
ForeignKeys int
126125
}{}

internal/dbtest/dbtest.pb.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/proto/local/dbtest/storage/v1/dbtest.proto

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ syntax = "proto3";
77
// are only used for unit tests and are not part of the rest of the domain model
88

99
package dbtest.storage.v1;
10-
option go_package = "internal/dbtest;dbtest";
1110

1211
import "google/protobuf/timestamp.proto";
1312

13+
option go_package = "internal/dbtest;dbtest";
14+
1415
// Timestamp for storage messages. We've defined a new local type wrapper
1516
// of google.protobuf.Timestamp so we can implement sql.Scanner and sql.Valuer
1617
// interfaces. See:
@@ -126,4 +127,4 @@ message StoreTestScooter {
126127

127128
// @inject_tag: `gorm:"-"`
128129
string read_only_field = 6;
129-
}
130+
}

rw.go

+1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ func (rw *RW) clearDefaultNullResourceFields(ctx context.Context, i interface{})
238238
}
239239
return nil
240240
}
241+
241242
func (rw *RW) primaryKeysWhere(ctx context.Context, i interface{}) (string, []interface{}, error) {
242243
const op = "dbw.primaryKeysWhere"
243244
var fieldNames []string

0 commit comments

Comments
 (0)