File tree Expand file tree Collapse file tree 3 files changed +42
-3
lines changed
Expand file tree Collapse file tree 3 files changed +42
-3
lines changed Original file line number Diff line number Diff line change 3838 bun-version : latest
3939 - name : Install dependencies
4040 run : bun install
41- - name : Run tests
41+ - name : Run TypeScript tests
4242 run : bun test
43+ - name : Run Terraform Validate
44+ run : bun terraform-validate
Original file line number Diff line number Diff line change 22 "name" : " modules" ,
33 "scripts" : {
44 "test" : " bun test" ,
5+ "terraform-validate" : " ./scripts/terraform_validate.sh" ,
56 "fmt" : " bun x prettier -w **/*.sh .sample/run.sh new.sh **/*.ts **/*.md *.md && terraform fmt **/*.tf .sample/main.tf" ,
6- "fmt:ci" : " bun x prettier --check **/*.sh .sample/run.sh new.sh **/*.ts **/*.md *.md && terraform fmt -check **/*.tf .sample/main.tf" ,
7- "update-version" : " ./update-version.sh"
7+ "fmt:ci" : " bun x prettier --check **/*.sh .sample/run.sh new.sh **/*.ts **/*.md *.md && terraform fmt -check **/*.tf .sample/main.tf"
88 },
99 "devDependencies" : {
1010 "@types/bun" : " ^1.2.9" ,
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -euo pipefail
4+
5+ validate_terraform_directory () {
6+ local dir=" $1 "
7+ echo " Running \` terraform validate\` in $dir "
8+ pushd " $dir "
9+ terraform init -upgrade
10+ terraform validate
11+ popd
12+ }
13+
14+ main () {
15+ # Get the directory of the script
16+ local script_dir=$( dirname " $( readlink -f " $0 " ) " )
17+
18+ # Code assumes that registry directory will always be in same position
19+ # relative to the main script directory
20+ local registry_dir=" $script_dir /../registry"
21+
22+ # Get all subdirectories in the registry directory. Code assumes that
23+ # Terraform directories won't begin to appear until three levels deep into
24+ # the registry (e.g., registry/coder/modules/coder-login, which will then
25+ # have a main.tf file inside it)
26+ local subdirs=$( find " $registry_dir " -mindepth 3 -type d | sort)
27+
28+ for dir in $subdirs ; do
29+ # Skip over any directories that obviously don't have the necessary
30+ # files
31+ if test -f " $dir /main.tf" ; then
32+ validate_terraform_directory " $dir "
33+ fi
34+ done
35+ }
36+
37+ main
You can’t perform that action at this time.
0 commit comments