Skip to content

Commit

Permalink
Make examples to test in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
OJFord committed Feb 3, 2022
1 parent 0e3cb29 commit 104fab4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ jobs:
- name: Terraformat
run: terraform fmt -recursive examples

- name: Check examples
run: make examples

- name: Check docs updated
run: |
curl -L https://github.com/hashicorp/terraform-plugin-docs/releases/download/v0.5.0/tfplugindocs_0.5.0_linux_amd64.zip --output tfplugindocs.zip
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ examples/**/.terraform.lock.hcl
*.tfstate

/terraform-provider-wireguard
/terraformrc
24 changes: 18 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
EXAMPLES := $(wildcard examples/*/*)
.ONESHELL:

default: build

Expand All @@ -8,9 +8,21 @@ build: fmt
fmt:
go fmt

examples: build $(EXAMPLES)
for d in $(EXAMPLES); do \
echo "Applying example $$d" ;\
terraform -chdir="$$d" init;\
terraform -chdir="$$d" apply -auto-approve;\
terraformrc:
cat <<-EOC > $@
provider_installation {
dev_overrides {
"OJFord/wireguard" = "$$PWD"
}
direct {}
}
EOC

examples: build terraformrc
shopt -s globstar
for d in examples/**/versions.tf; do
d="$$(dirname $$d)"
echo "Applying example $$d"
TF_CLI_CONFIG_FILE="$$PWD/terraformrc" terraform -chdir="$$d" init
TF_CLI_CONFIG_FILE="$$PWD/terraformrc" terraform -chdir="$$d" apply -auto-approve
done

0 comments on commit 104fab4

Please sign in to comment.