From 82d06f95216aaa8eb13bf5212e0fae9b1923ca9e Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Mon, 25 Aug 2025 15:44:35 +0000 Subject: [PATCH 1/7] docs: update contribution guidelines for both module testing procedures --- CONTRIBUTING.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 97a33d9f7..6ecd2c4d5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -124,18 +124,27 @@ This script generates: - Accurate description and usage examples - Correct icon path (usually `../../../../.icons/your-icon.svg`) - Proper tags that describe your module -3. **Create at least one `.tftest.hcl`** to test your module with `terraform test` +3. **Create tests for your module:** + - **New modules**: Create `.tftest.hcl` files and test with `terraform test` + - **Existing modules**: Keep `main.test.ts` files and test with `bun test` + - **Both approaches** are supported 4. **Add any scripts** or additional files your module needs ### 4. Test and Submit ```bash -# Test your module (from the module directory) +# Test your module +# For new modules with .tftest.hcl: +cd registry/[namespace]/modules/[module-name] terraform init -upgrade terraform test -verbose -# Or run all tests in the repo -./scripts/terraform_test_all.sh +# For existing modules with main.test.ts: +bun test registry/[namespace]/modules/[module-name] + +# Run all tests in the repo +bun test # All TypeScript tests +./scripts/terraform_test_all.sh # All Terraform tests # Format code bun run fmt @@ -393,7 +402,9 @@ Example: `https://github.com/coder/registry/compare/main...your-branch?template= ### Every Module Must Have - `main.tf` - Terraform code -- One or more `.tftest.hcl` files - Working tests with `terraform test` +- **Tests** (choose one): + - `.tftest.hcl` files with `terraform test` (preferred for new modules) + - `main.test.ts` file with `bun test` (existing modules) - `README.md` - Documentation with frontmatter ### Every Template Must Have @@ -493,6 +504,6 @@ When reporting bugs, include: 2. **No tests** or broken tests 3. **Hardcoded values** instead of variables 4. **Breaking changes** without defaults -5. **Not running** formatting (`bun run fmt`) and tests (`terraform test`) before submitting +5. **Not running** formatting (`bun run fmt`) and tests (`bun test` or `terraform test`) before submitting Happy contributing! 🚀 From 7469a6ee7c32d4d9c5676c359871428b0d2e1f7b Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Mon, 25 Aug 2025 15:44:49 +0000 Subject: [PATCH 2/7] ci: add Terraform tests to CI workflow --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 53b912bff..597f8ccf1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,6 +28,8 @@ jobs: run: bun install - name: Run TypeScript tests run: bun test + - name: Run Terraform tests + run: ./scripts/terraform_test_all.sh - name: Run Terraform Validate run: bun terraform-validate validate-style: From a7bad95258a0ea008800f37c183434ce958a7f88 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Mon, 25 Aug 2025 15:46:13 +0000 Subject: [PATCH 3/7] chore: bun run fmt --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6ecd2c4d5..f61b1c527 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -143,8 +143,8 @@ terraform test -verbose bun test registry/[namespace]/modules/[module-name] # Run all tests in the repo -bun test # All TypeScript tests -./scripts/terraform_test_all.sh # All Terraform tests +bun test # All TypeScript tests +./scripts/terraform_test_all.sh # All Terraform tests # Format code bun run fmt From 37cde4548a344f6c6b6430d53474e46ddd833864 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Mon, 25 Aug 2025 16:09:51 +0000 Subject: [PATCH 4/7] chore: clarify module requirements --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f61b1c527..c04cf98ef 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -402,7 +402,7 @@ Example: `https://github.com/coder/registry/compare/main...your-branch?template= ### Every Module Must Have - `main.tf` - Terraform code -- **Tests** (choose one): +- **Tests**: - `.tftest.hcl` files with `terraform test` (preferred for new modules) - `main.test.ts` file with `bun test` (existing modules) - `README.md` - Documentation with frontmatter From 2a78dc8ef098e9a40d8d3dc5269156d1d14d35a4 Mon Sep 17 00:00:00 2001 From: DevCats Date: Mon, 25 Aug 2025 13:43:43 -0500 Subject: [PATCH 5/7] chore: add wildcard to tftest.hcl Co-authored-by: Atif Ali --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c04cf98ef..c764e492e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -403,8 +403,8 @@ Example: `https://github.com/coder/registry/compare/main...your-branch?template= - `main.tf` - Terraform code - **Tests**: - - `.tftest.hcl` files with `terraform test` (preferred for new modules) - - `main.test.ts` file with `bun test` (existing modules) + - `*.tftest.hcl` files with `terraform test` (to test terraform specific logoc) + - `main.test.ts` file with `bun test` (to test business logic, i.e., `coder_script` to install a package.) - `README.md` - Documentation with frontmatter ### Every Template Must Have From 6a98f831c31df7cd8abba110f5e66cc9c9dd7f09 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Mon, 25 Aug 2025 20:18:09 +0000 Subject: [PATCH 6/7] docs(contributing): clarify testing procedures and requirements --- CONTRIBUTING.md | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c764e492e..d2a8b6a36 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -125,8 +125,8 @@ This script generates: - Correct icon path (usually `../../../../.icons/your-icon.svg`) - Proper tags that describe your module 3. **Create tests for your module:** - - **New modules**: Create `.tftest.hcl` files and test with `terraform test` - - **Existing modules**: Keep `main.test.ts` files and test with `bun test` + - **New modules**: Create `*.tftest.hcl` files and test with `terraform test` + - **TypeScript tests**: Create `main.test.ts` files if your module runs scripts or has business logic that Terraform tests can't cover - **Both approaches** are supported 4. **Add any scripts** or additional files your module needs @@ -134,17 +134,14 @@ This script generates: ```bash # Test your module -# For new modules with .tftest.hcl: cd registry/[namespace]/modules/[module-name] + +# Required: Test Terraform functionality terraform init -upgrade terraform test -verbose -# For existing modules with main.test.ts: -bun test registry/[namespace]/modules/[module-name] - -# Run all tests in the repo -bun test # All TypeScript tests -./scripts/terraform_test_all.sh # All Terraform tests +# Optional: Test TypeScript files if you have main.test.ts +bun test main.test.ts # Format code bun run fmt @@ -352,8 +349,8 @@ coder templates push test-[template-name] -d . terraform init -upgrade terraform test -verbose -# Test all modules -./scripts/terraform_test_all.sh +# Optional: If you have TypeScript tests +bun test main.test.ts ``` ### 3. Maintain Backward Compatibility @@ -403,7 +400,7 @@ Example: `https://github.com/coder/registry/compare/main...your-branch?template= - `main.tf` - Terraform code - **Tests**: - - `*.tftest.hcl` files with `terraform test` (to test terraform specific logoc) + - `*.tftest.hcl` files with `terraform test` (to test terraform specific logic) - `main.test.ts` file with `bun test` (to test business logic, i.e., `coder_script` to install a package.) - `README.md` - Documentation with frontmatter @@ -504,6 +501,6 @@ When reporting bugs, include: 2. **No tests** or broken tests 3. **Hardcoded values** instead of variables 4. **Breaking changes** without defaults -5. **Not running** formatting (`bun run fmt`) and tests (`bun test` or `terraform test`) before submitting +5. **Not running** formatting (`bun run fmt`) and tests (`terraform test`, and `bun test main.test.ts` if applicable) before submitting Happy contributing! 🚀 From 7cd49699e92597554a4c97d3d0e344544683219b Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Tue, 26 Aug 2025 12:46:16 +0500 Subject: [PATCH 7/7] Apply suggestion from @matifali --- CONTRIBUTING.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d2a8b6a36..71c256bc8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -125,9 +125,8 @@ This script generates: - Correct icon path (usually `../../../../.icons/your-icon.svg`) - Proper tags that describe your module 3. **Create tests for your module:** - - **New modules**: Create `*.tftest.hcl` files and test with `terraform test` - - **TypeScript tests**: Create `main.test.ts` files if your module runs scripts or has business logic that Terraform tests can't cover - - **Both approaches** are supported + - **Terraform tests**: Create a `*.tftest.hcl` file and test with `terraform test` + - **TypeScript tests**: Create `main.test.ts` file if your module runs scripts or has business logic that Terraform tests can't cover 4. **Add any scripts** or additional files your module needs ### 4. Test and Submit