Skip to content

Commit

Permalink
chore (workflows): add make-gen-delta workflow
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jimlambrt committed Oct 1, 2023
1 parent 19375fc commit 2dcf7cf
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 7 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/make-gen-delta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "make-gen-delta"
on:
- workflow_dispatch
- push
- workflow_call

permissions:
contents: read

jobs:
make-gen-delta:
name: "Check for uncommitted changes from make gen"
runs-on: ${{ fromJSON(vars.RUNNER) }}
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: '0'
- name: Determine Go version
id: get-go-version
# We use .go-version as our source of truth for current Go
# version, because "goenv" can react to it automatically.
run: |
echo "Building with Go $(cat .go-version)"
echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: "${{ steps.get-go-version.outputs.go-version }}"
- name: Running go mod tidy
run: |
go mod tidy
- name: Install Dependencies
run: |
make tools
- name: Running make gen
run: |
make gen
- name: Check for changes
run: |
git diff --exit-code
git status --porcelain
test -z "$(git status --porcelain)"
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ tools:

.PHONY: fmt
fmt:
gofumpt -w $$(find . -name '*.go' | grep -v pb.go)
gofumpt -w $$(find . -name '*.go' ! -name '*pb.go')
buf format -w

.PHONY: copywrite
copywrite:
copywrite headers

.PHONY: gen
gen: proto fmt copywrite

.PHONY: test
test:
Expand Down
1 change: 0 additions & 1 deletion clause.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func SetColumns(names []string) []ColumnValue {
// OnConflict specifies how to handle alternative actions to take when an insert
// results in a unique constraint or exclusion constraint error.
type OnConflict struct {

// Target specifies what conflict you want to define a policy for. This can
// be any one of these:
// Columns: the name of a specific column or columns
Expand Down
3 changes: 1 addition & 2 deletions db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ func TestOpen(t *testing.T) {
rows, err := rw.Query(context.Background(), "PRAGMA foreign_keys", nil)
require.NoError(err)
require.True(rows.Next())
type foo struct {
}
type foo struct{}
f := struct {
ForeignKeys int
}{}
Expand Down
2 changes: 1 addition & 1 deletion internal/dbtest/dbtest.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions internal/proto/local/dbtest/storage/v1/dbtest.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ syntax = "proto3";
// are only used for unit tests and are not part of the rest of the domain model

package dbtest.storage.v1;
option go_package = "internal/dbtest;dbtest";

import "google/protobuf/timestamp.proto";

option go_package = "internal/dbtest;dbtest";

// Timestamp for storage messages. We've defined a new local type wrapper
// of google.protobuf.Timestamp so we can implement sql.Scanner and sql.Valuer
// interfaces. See:
Expand Down Expand Up @@ -126,4 +127,4 @@ message StoreTestScooter {

// @inject_tag: `gorm:"-"`
string read_only_field = 6;
}
}
1 change: 1 addition & 0 deletions rw.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ func (rw *RW) clearDefaultNullResourceFields(ctx context.Context, i interface{})
}
return nil
}

func (rw *RW) primaryKeysWhere(ctx context.Context, i interface{}) (string, []interface{}, error) {
const op = "dbw.primaryKeysWhere"
var fieldNames []string
Expand Down

0 comments on commit 2dcf7cf

Please sign in to comment.