Skip to content

Commit

Permalink
internal/keyvaluetags: Use build constraint with custom implementatio…
Browse files Browse the repository at this point in the history
…n files, add gencheck Makefile target and add to CI (#11638)

* Move custom service-specific functions to own package.
This ensures that `make gen` succeeds.

* Add 'gen' to 'test' and 'testacc' targets.

* Revert "Add 'gen' to 'test' and 'testacc' targets."

This reverts commit 2e6008bbe4c1e33ad6ed4dc08019e207cd29939e.

* Revert "Move custom service-specific functions to own package."

This reverts commit 2d050db0cf29919336f9b1b1898856601763403b.

* Use build constraints to prevent 'go generate' errors with custom keyvaluetags implementations.

* Add 'gencheck' build target.

If there are differences we get an error like:

% make gencheck
==> Checking generated source code...
rm -f aws/internal/keyvaluetags/*_gen.go
go generate ./...
 GNUmakefile | 6 ++++++
 1 file changed, 6 insertions(+)

Unexpected difference in directories after code generation. Run 'make gen' command and commit.
make: *** [gencheck] Error 1

If there are no differences:

% make gencheck
==> Checking generated source code...
rm -f aws/internal/keyvaluetags/*_gen.go
go generate ./...

* Run 'make gencheck' during Travis Code UnitTest pass.
  • Loading branch information
Kit Ewbank authored Feb 5, 2020
1 parent e425d3e commit 4681395
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ matrix:
script: make lint
- go: "1.13.x"
name: "Code UnitTest"
script: make test
script:
- make test
- make gencheck
- go: "1.13.x"
name: "Dependencies"
script: make depscheck
Expand Down
6 changes: 6 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ fmt:
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"

gencheck:
@echo "==> Checking generated source code..."
@$(MAKE) gen
@git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'make gen' command and commit."; exit 1)

websitefmtcheck:
@sh -c "'$(CURDIR)/scripts/websitefmtcheck.sh'"

Expand Down
2 changes: 2 additions & 0 deletions aws/internal/keyvaluetags/iam_tags.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !generate

package keyvaluetags

import (
Expand Down
6 changes: 3 additions & 3 deletions aws/internal/keyvaluetags/key_value_tags.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:generate go run generators/servicetags/main.go
//go:generate go run generators/listtags/main.go
//go:generate go run generators/updatetags/main.go
//go:generate go run -tags generate generators/servicetags/main.go
//go:generate go run -tags generate generators/listtags/main.go
//go:generate go run -tags generate generators/updatetags/main.go

package keyvaluetags

Expand Down

0 comments on commit 4681395

Please sign in to comment.