Skip to content

Commit 2b4f485

Browse files
committed
docs: update docs and samples to use terraform test; route npm test to terraform runner; no direct pushes to main
1 parent 673caf2 commit 2b4f485

File tree

4 files changed

+40
-14
lines changed

4 files changed

+40
-14
lines changed

CONTRIBUTING.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The Coder Registry is a collection of Terraform modules and templates for Coder
2424

2525
### Install Dependencies
2626

27-
Install Bun:
27+
Install Bun (for formatting and scripts):
2828

2929
```bash
3030
curl -fsSL https://bun.sh/install | bash
@@ -124,19 +124,23 @@ This script generates:
124124
- Accurate description and usage examples
125125
- Correct icon path (usually `../../../../.icons/your-icon.svg`)
126126
- Proper tags that describe your module
127-
3. **Create `main.test.ts`** to test your module
127+
3. **Create at least one `.tftest.hcl`** to test your module with `terraform test`
128128
4. **Add any scripts** or additional files your module needs
129129

130130
### 4. Test and Submit
131131

132132
```bash
133-
# Test your module
134-
bun test -t 'module-name'
133+
# Test your module (from the module directory)
134+
terraform init -upgrade
135+
terraform test -verbose
136+
137+
# Or run all tests in the repo
138+
./scripts/terraform_test_all.sh
135139

136140
# Format code
137-
bun fmt
141+
bun run fmt
138142

139-
# Commit and create PR
143+
# Commit and create PR (do not push to main directly)
140144
git add .
141145
git commit -m "Add [module-name] module"
142146
git push origin your-branch
@@ -335,11 +339,12 @@ coder templates push test-[template-name] -d .
335339
### 2. Test Your Changes
336340

337341
```bash
338-
# Test a specific module
339-
bun test -t 'module-name'
342+
# Test a specific module (from the module directory)
343+
terraform init -upgrade
344+
terraform test -verbose
340345

341346
# Test all modules
342-
bun test
347+
./scripts/terraform_test_all.sh
343348
```
344349

345350
### 3. Maintain Backward Compatibility
@@ -388,7 +393,7 @@ Example: `https://github.com/coder/registry/compare/main...your-branch?template=
388393
### Every Module Must Have
389394

390395
- `main.tf` - Terraform code
391-
- `main.test.ts` - Working tests
396+
- One or more `.tftest.hcl` files - Working tests with `terraform test`
392397
- `README.md` - Documentation with frontmatter
393398

394399
### Every Template Must Have
@@ -488,6 +493,6 @@ When reporting bugs, include:
488493
2. **No tests** or broken tests
489494
3. **Hardcoded values** instead of variables
490495
4. **Breaking changes** without defaults
491-
5. **Not running** `bun fmt` before submitting
496+
5. **Not running** formatting (`bun run fmt`) and tests (`terraform test`) before submitting
492497

493498
Happy contributing! 🚀

MAINTAINER.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ sudo apt install golang-go
1818

1919
Check that PRs have:
2020

21-
- [ ] All required files (`main.tf`, `main.test.ts`, `README.md`)
21+
- [ ] All required files (`main.tf`, `README.md`, at least one `.tftest.hcl`)
2222
- [ ] Proper frontmatter in README
23-
- [ ] Working tests (`bun test`)
23+
- [ ] Working tests (`terraform test`)
2424
- [ ] Formatted code (`bun run fmt`)
2525
- [ ] Avatar image for new namespaces (`avatar.png` or `avatar.svg` in `.images/`)
2626

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
run "plan_with_required_vars" {
2+
command = plan
3+
4+
variables {
5+
agent_id = "example-agent-id"
6+
}
7+
}
8+
9+
run "app_url_uses_port" {
10+
command = plan
11+
12+
variables {
13+
agent_id = "example-agent-id"
14+
port = 19999
15+
}
16+
17+
assert {
18+
condition = resource.coder_app.MODULE_NAME.url == "http://localhost:19999"
19+
error_message = "Expected MODULE_NAME app URL to include configured port"
20+
}
21+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"fmt": "bun x prettier --write **/*.sh **/*.ts **/*.md *.md && terraform fmt -recursive -diff",
55
"fmt:ci": "bun x prettier --check **/*.sh **/*.ts **/*.md *.md && terraform fmt -check -recursive -diff",
66
"terraform-validate": "./scripts/terraform_validate.sh",
7-
"test": "bun test",
7+
"test": "./scripts/terraform_test_all.sh",
88
"update-version": "./update-version.sh"
99
},
1010
"devDependencies": {

0 commit comments

Comments
 (0)