Commit 5568f56
committed
terraform: don't run zip if building provider binary failed
If we build the terraform provider binaries, then change one of them so
that it fails to build and try running `make -C terraform` without
running `make -C clean` we might miss the build failure.
For example:
```
make: Entering directory '/home/rfonseca/prjs/upstream/openshift/installer/terraform'
cd providers/google; \
if [ -f main.go ]; then path="."; else path=./vendor/`grep _ tools.go|awk '{ print $2 }'|sed 's|"||g'`; fi; \
go build -gcflags "" -ldflags "-s -w" -o ../../bin/linux_amd64/terraform-provider-google "$path"; \
zip -1j ../../bin/linux_amd64/terraform-provider-google.zip ../../bin/linux_amd64/terraform-provider-google;
vendor/github.com/hashicorp/terraform-provider-google/google/resource_storage_bucket.go:1063:37: cannot convert condition.Age (variable of type *int64) to type int
vendor/github.com/hashicorp/terraform-provider-google/google/resource_storage_bucket.go:1226:21: cannot use int64(v.(int)) (value of type int64) as type *int64 in assignment
updating: terraform-provider-google (deflated 66%)
make: Leaving directory '/home/rfonseca/prjs/upstream/openshift/installer/terraform'
+ copy_terraform_to_mirror
```
That is not a problem in CI since we always build with a blank slate:
```
# github.com/hashicorp/terraform-provider-google/google
vendor/github.com/hashicorp/terraform-provider-google/google/resource_storage_bucket.go:1063:37: cannot convert condition.Age (variable of type *int64) to type int
vendor/github.com/hashicorp/terraform-provider-google/google/resource_storage_bucket.go:1226:21: cannot use int64(v.(int)) (value of type int64) as type *int64 in assignment
zip warning: name not matched: ../../bin/linux_amd64/terraform-provider-google
zip error: Nothing to do! (../../bin/linux_amd64/terraform-provider-google.zip)
```
but it can happen locally as we move branches and rebuild the project.
So instead of just using a list of commands with the `;` bash operator,
let's use a conditional `&&` so that `zip` won't execute unless the
build is successful.1 parent 101f544 commit 5568f56
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
0 commit comments