forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made breaking change detector own its own setup and build process (Go…
…ogleCloudPlatform#8705) * Made breaking change detector own its own setup and build process * Moved breaking change detector unit tests to github action * Corrected breaking change detector unit test setup * Added back package name updates for tpgb new * made unit tests use a shallow clone * Limit breaking change detector unit tests to runs that modify the tool Co-authored-by: Scott Suarez <[email protected]> * Update .ci/scripts/go-plus/github-differ/generate_comment.sh Co-authored-by: Scott Suarez <[email protected]> * Minor Cleanup * Intentionally broke breaking change detector * Revert "Intentionally broke breaking change detector" This reverts commit bcb6ba8. * Intentionally caused panic in breaking change detector at runtime * Made a breaking change * Added additional logging * Removed export in generate_comment.sh export hides the exit code of the command being run; assignment on its own does not. Export is not required in the context of a shell script * Made failure get set to 1 instead of $? * Added bin/ cleanup * Revert "Intentionally caused panic in breaking change detector at runtime" This reverts commit a16c0cd. * Fixed package name replacement for google-beta * Re-added export of TPG/TPGB BREAKING * Added comment explaining the export location * Revert "Made a breaking change" This reverts commit 2deecd7. --------- Co-authored-by: Scott Suarez <[email protected]>
- Loading branch information
Showing
9 changed files
with
305 additions
and
673 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: unit-tests-breaking-change-detector | ||
|
||
permissions: read-all | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'tools/breaking-change-detector/**' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '^1.19.1' | ||
|
||
- name: Build | ||
run: | | ||
cd tools/breaking-change-detector | ||
make clone OWNER_REPO=hashicorp/terraform-provider-google DEPTH=1 | ||
make build OLD_REF=main NEW_REF=main | ||
- name: Test | ||
run: | | ||
cd tools/breaking-change-detector | ||
go test -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
old | ||
new | ||
bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,58 @@ | ||
localsetup: | ||
sed -i bak -E "s~google/provider/(.*)/([0-9A-Za-z-]*)~google/provider/\1/$(PROVIDER_VERSION)~" comparison.go | ||
clone: | ||
ifndef OWNER_REPO | ||
$(error OWNER_REPO is undefined) | ||
endif | ||
rm -rf ./old ./new | ||
ifdef DEPTH | ||
git clone --depth=$(DEPTH) https://github.com/$(OWNER_REPO).git old | ||
else | ||
git clone https://github.com/$(OWNER_REPO).git old | ||
endif | ||
cp -r old/ new/ | ||
|
||
ifneq ($(REPLACE_OLD),) | ||
go mod edit -replace google/provider/old=$(realpath ${REPLACE_OLD}) | ||
clean: | ||
cd old/; \ | ||
rm -rf google/ google-beta; \ | ||
git checkout -- .; \ | ||
git clean -f . | ||
cd new/; \ | ||
rm -rf google/ google-beta; \ | ||
git checkout -- .; \ | ||
git clean -f . | ||
rm -rf bin/ | ||
|
||
build: | ||
ifndef OLD_REF | ||
$(error OLD_REF is undefined) | ||
endif | ||
ifndef NEW_REF | ||
$(error NEW_REF is undefined) | ||
endif | ||
ifneq ($(REPLACE_NEW),) | ||
go mod edit -replace google/provider/new=$(realpath ${REPLACE_NEW}) | ||
endif | ||
$(MAKE) clean | ||
cd old/; \ | ||
git checkout $(OLD_REF); \ | ||
real_package_name=github.com/hashicorp/terraform-provider-google; \ | ||
real_folder_name=google; \ | ||
fake_package_name=google/provider/old; \ | ||
if [ -d "google-beta" ]; then \ | ||
mv google-beta google; \ | ||
real_package_name=github.com/hashicorp/terraform-provider-google-beta; \ | ||
real_folder_name=google-beta; \ | ||
fi; \ | ||
find . -type f -name "*.go" -exec sed -i.bak "s~$$real_package_name/$$real_folder_name~$$fake_package_name/google~g" {} +; \ | ||
sed -i.bak "s|$$real_package_name|$$fake_package_name|g" go.mod | ||
cd new/; \ | ||
git checkout $(NEW_REF); \ | ||
real_package_name=github.com/hashicorp/terraform-provider-google; \ | ||
real_folder_name=google; \ | ||
fake_package_name=google/provider/new; \ | ||
if [ -d "google-beta" ]; then \ | ||
mv google-beta google; \ | ||
real_package_name=github.com/hashicorp/terraform-provider-google-beta; \ | ||
real_folder_name=google-beta; \ | ||
fi; \ | ||
find . -type f -name "*.go" -exec sed -i.bak "s~$$real_package_name/$$real_folder_name~$$fake_package_name/google~g" {} +; \ | ||
sed -i.bak "s|$$real_package_name|$$fake_package_name|g" go.mod | ||
go mod tidy | ||
mkdir -p bin/ | ||
go build -o ./bin/ . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,24 @@ | ||
# Breaking change detector | ||
|
||
## Purpose | ||
Detects breaking changes between provider versions. | ||
|
||
Specifically protects customer expectations between [minor version](https://www.terraform.io/plugin/sdkv2/best-practices/versioning#example-minor-number-increments). | ||
|
||
|
||
## Execution of | ||
## Run | ||
|
||
### Program:mode-default | ||
```bash | ||
go run . | ||
``` | ||
# set up old / new dirs | ||
make clone OWNER_REPO=modular-magician/terraform-provider-google | ||
|
||
### Tests | ||
```bash | ||
go test ./... | ||
``` | ||
# build based on old / new dirs | ||
make build OLD_REF=branch_or_commit NEW_REF=branch_or_commit | ||
|
||
# Run the binary | ||
bin/breaking-change-detector | ||
``` | ||
|
||
## Misc | ||
## Test | ||
```bash | ||
# getting the go version label from git log | ||
TZ=UTC0 git log --since="jan 1 2019" --format=%cd-%H --date=format-local:%Y%m%d%H%M%S | sed -E "s/(.*-.{12}).*/\1/" | ||
go test ./... | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.