Compare commits

...

8 Commits

Author SHA1 Message Date
Muhammad Atif Ali 2b4f485d72 docs: update docs and samples to use terraform test; route npm test to terraform runner; no direct pushes to main 2025-08-08 17:44:59 +05:00
Muhammad Atif Ali 673caf2e95 Revert "chore(examples): add MODULE_NAME.tftest.hcl to new module sample and make run.sh optional"
This reverts commit a5edad7f17.
2025-08-08 17:29:11 +05:00
Muhammad Atif Ali ab5ff4b4be Revert "chore(test): add terraform tests for jetbrains, zed, code-server and keep mixed mode"
This reverts commit fb657b875d.
2025-08-08 17:29:11 +05:00
Muhammad Atif Ali f5a68b500b Revert "chore(test): migrate to terraform test and add initial .tftest for zed"
This reverts commit 016d4dc523.
2025-08-08 17:29:11 +05:00
Muhammad Atif Ali a5edad7f17 chore(examples): add MODULE_NAME.tftest.hcl to new module sample and make run.sh optional 2025-08-08 16:36:30 +05:00
Muhammad Atif Ali fb657b875d chore(test): add terraform tests for jetbrains, zed, code-server and keep mixed mode
- Add .tftest.hcl for jetbrains, zed, and code-server
- Remove Bun tests for these migrated modules only
- Keep Bun tests for other modules during transition
- Update contributing guide to mention terraform test
- Include runner script to execute terraform tests across modules
2025-08-08 16:33:35 +05:00
Muhammad Atif Ali 016d4dc523 chore(test): migrate to terraform test and add initial .tftest for zed
Replace Bun-based test runner with Terraform native testing. Adds script to discover and run tests across modules and updates docs/scripts to use terraform test.
2025-08-08 13:31:35 +05:00
Muhammad Atif Ali c8d99cfba3 fix: correct terraform state arg and log typos
- test/test.ts: ensure `-state` is immediately followed by the state file to avoid apply failures
- readmevalidation: fix two logger message typos (processing/processed)
2025-08-08 13:15:52 +05:00
6 changed files with 43 additions and 17 deletions
+16 -11
View File
@@ -24,7 +24,7 @@ The Coder Registry is a collection of Terraform modules and templates for Coder
### Install Dependencies ### Install Dependencies
Install Bun: Install Bun (for formatting and scripts):
```bash ```bash
curl -fsSL https://bun.sh/install | bash curl -fsSL https://bun.sh/install | bash
@@ -124,19 +124,23 @@ This script generates:
- Accurate description and usage examples - Accurate description and usage examples
- Correct icon path (usually `../../../../.icons/your-icon.svg`) - Correct icon path (usually `../../../../.icons/your-icon.svg`)
- Proper tags that describe your module - Proper tags that describe your module
3. **Create `main.test.ts`** to test your module 3. **Create at least one `.tftest.hcl`** to test your module with `terraform test`
4. **Add any scripts** or additional files your module needs 4. **Add any scripts** or additional files your module needs
### 4. Test and Submit ### 4. Test and Submit
```bash ```bash
# Test your module # Test your module (from the module directory)
bun test -t 'module-name' terraform init -upgrade
terraform test -verbose
# Or run all tests in the repo
./scripts/terraform_test_all.sh
# Format code # Format code
bun fmt bun run fmt
# Commit and create PR # Commit and create PR (do not push to main directly)
git add . git add .
git commit -m "Add [module-name] module" git commit -m "Add [module-name] module"
git push origin your-branch git push origin your-branch
@@ -335,11 +339,12 @@ coder templates push test-[template-name] -d .
### 2. Test Your Changes ### 2. Test Your Changes
```bash ```bash
# Test a specific module # Test a specific module (from the module directory)
bun test -t 'module-name' terraform init -upgrade
terraform test -verbose
# Test all modules # Test all modules
bun test ./scripts/terraform_test_all.sh
``` ```
### 3. Maintain Backward Compatibility ### 3. Maintain Backward Compatibility
@@ -388,7 +393,7 @@ Example: `https://github.com/coder/registry/compare/main...your-branch?template=
### Every Module Must Have ### Every Module Must Have
- `main.tf` - Terraform code - `main.tf` - Terraform code
- `main.test.ts` - Working tests - One or more `.tftest.hcl` files - Working tests with `terraform test`
- `README.md` - Documentation with frontmatter - `README.md` - Documentation with frontmatter
### Every Template Must Have ### Every Template Must Have
@@ -488,6 +493,6 @@ When reporting bugs, include:
2. **No tests** or broken tests 2. **No tests** or broken tests
3. **Hardcoded values** instead of variables 3. **Hardcoded values** instead of variables
4. **Breaking changes** without defaults 4. **Breaking changes** without defaults
5. **Not running** `bun fmt` before submitting 5. **Not running** formatting (`bun run fmt`) and tests (`terraform test`) before submitting
Happy contributing! 🚀 Happy contributing! 🚀
+2 -2
View File
@@ -18,9 +18,9 @@ sudo apt install golang-go
Check that PRs have: Check that PRs have:
- [ ] All required files (`main.tf`, `main.test.ts`, `README.md`) - [ ] All required files (`main.tf`, `README.md`, at least one `.tftest.hcl`)
- [ ] Proper frontmatter in README - [ ] Proper frontmatter in README
- [ ] Working tests (`bun test`) - [ ] Working tests (`terraform test`)
- [ ] Formatted code (`bun run fmt`) - [ ] Formatted code (`bun run fmt`)
- [ ] Avatar image for new namespaces (`avatar.png` or `avatar.svg` in `.images/`) - [ ] Avatar image for new namespaces (`avatar.png` or `avatar.svg` in `.images/`)
+2 -2
View File
@@ -336,12 +336,12 @@ func validateAllCoderResourceFilesOfType(resourceType string) error {
return err return err
} }
logger.Info(context.Background(), "rocessing README files", "num_files", len(allReadmeFiles)) logger.Info(context.Background(), "processing README files", "num_files", len(allReadmeFiles))
resources, err := parseCoderResourceReadmeFiles(resourceType, allReadmeFiles) resources, err := parseCoderResourceReadmeFiles(resourceType, allReadmeFiles)
if err != nil { if err != nil {
return err return err
} }
logger.Info(context.Background(), "rocessed README files as valid Coder resources", "num_files", len(resources), "type", resourceType) logger.Info(context.Background(), "processed README files as valid Coder resources", "num_files", len(resources), "type", resourceType)
if err := validateCoderResourceRelativeURLs(resources); err != nil { if err := validateCoderResourceRelativeURLs(resources); err != nil {
return err return err
+21
View File
@@ -0,0 +1,21 @@
run "plan_with_required_vars" {
command = plan
variables {
agent_id = "example-agent-id"
}
}
run "app_url_uses_port" {
command = plan
variables {
agent_id = "example-agent-id"
port = 19999
}
assert {
condition = resource.coder_app.MODULE_NAME.url == "http://localhost:19999"
error_message = "Expected MODULE_NAME app URL to include configured port"
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
"fmt": "bun x prettier --write **/*.sh **/*.ts **/*.md *.md && terraform fmt -recursive -diff", "fmt": "bun x prettier --write **/*.sh **/*.ts **/*.md *.md && terraform fmt -recursive -diff",
"fmt:ci": "bun x prettier --check **/*.sh **/*.ts **/*.md *.md && terraform fmt -check -recursive -diff", "fmt:ci": "bun x prettier --check **/*.sh **/*.ts **/*.md *.md && terraform fmt -check -recursive -diff",
"terraform-validate": "./scripts/terraform_validate.sh", "terraform-validate": "./scripts/terraform_validate.sh",
"test": "bun test", "test": "./scripts/terraform_test_all.sh",
"update-version": "./update-version.sh" "update-version": "./update-version.sh"
}, },
"devDependencies": { "devDependencies": {
+1 -1
View File
@@ -247,8 +247,8 @@ export const runTerraformApply = async <TVars extends TerraformVariables>(
"-compact-warnings", "-compact-warnings",
"-input=false", "-input=false",
"-auto-approve", "-auto-approve",
"-state",
"-no-color", "-no-color",
"-state",
stateFile, stateFile,
], ],
{ {