From 104fab4dc6cb6eda93f688abe326b0b1e1eb3e1f Mon Sep 17 00:00:00 2001 From: Oliver Ford Date: Thu, 13 Jan 2022 13:50:02 +0000 Subject: [PATCH] Make examples to test in CI --- .github/workflows/check.yml | 3 +++ .gitignore | 1 + Makefile | 24 ++++++++++++++++++------ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index c231d0a..ab87c8d 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -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 diff --git a/.gitignore b/.gitignore index ab08045..20208dc 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ examples/**/.terraform.lock.hcl *.tfstate /terraform-provider-wireguard +/terraformrc diff --git a/Makefile b/Makefile index aa45823..30319e1 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -EXAMPLES := $(wildcard examples/*/*) +.ONESHELL: default: build @@ -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