|
1 | 1 | # Contributing
|
2 | 2 |
|
3 |
| -To create a new module, clone this repository and run: |
| 3 | +## Getting started |
| 4 | + |
| 5 | +This repo uses the [Bun runtime](https://bun.sh/) to to run all code and tests. To install Bun, you can run this command on Linux/MacOS: |
| 6 | + |
| 7 | +```shell |
| 8 | +curl -fsSL https://bun.sh/install | bash |
| 9 | +``` |
| 10 | + |
| 11 | +Or this command on Windows: |
| 12 | + |
| 13 | +```shell |
| 14 | +powershell -c "irm bun.sh/install.ps1 | iex" |
| 15 | +``` |
| 16 | + |
| 17 | +Follow the instructions to ensure that Bun is available globally. Once Bun has been installed, clone this repository. From there, run this script to create a new module: |
4 | 18 |
|
5 | 19 | ```shell
|
6 |
| -./new.sh MODULE_NAME |
| 20 | +./new.sh NAME_OF_NEW_MODULE |
7 | 21 | ```
|
8 | 22 |
|
9 | 23 | ## Testing a Module
|
10 | 24 |
|
| 25 | +> **Note:** It is the responsibility of the module author to implement tests for their module. The author must test the module locally before submitting a PR. |
| 26 | +
|
11 | 27 | A suite of test-helpers exists to run `terraform apply` on modules with variables, and test script output against containers.
|
12 | 28 |
|
13 |
| -The testing suite must be able to run docker containers with the `--network=host` flag, which typically requires running the tests on Linux as this flag does not apply to Docker Desktop for MacOS and Windows. MacOS users can work around this by using something like [colima](https://github.com/abiosoft/colima) or [Orbstack](https://orbstack.dev/) instead of Docker Desktop. |
| 29 | +The testing suite must be able to run docker containers with the `--network=host` flag. This typically requires running the tests on Linux as this flag does not apply to Docker Desktop for MacOS and Windows. MacOS users can work around this by using something like [colima](https://github.com/abiosoft/colima) or [Orbstack](https://orbstack.dev/) instead of Docker Desktop. |
14 | 30 |
|
15 |
| -Reference existing `*.test.ts` files for implementation. |
| 31 | +Reference the existing `*.test.ts` files to get an idea for how to set up tests. |
| 32 | + |
| 33 | +You can run all tests in a specific file with this command: |
16 | 34 |
|
17 | 35 | ```shell
|
18 |
| -# Run tests for a specific module! |
19 | 36 | $ bun test -t '<module>'
|
20 | 37 | ```
|
21 | 38 |
|
| 39 | +Or run all tests by running this command: |
| 40 | + |
| 41 | +```shell |
| 42 | +$ bun test |
| 43 | +``` |
| 44 | + |
22 | 45 | You can test a module locally by updating the source as follows
|
23 | 46 |
|
24 | 47 | ```tf
|
25 | 48 | module "example" {
|
26 | 49 | source = "git::https://github.com/<USERNAME>/<REPO>.git//<MODULE-NAME>?ref=<BRANCH-NAME>"
|
27 | 50 | }
|
28 | 51 | ```
|
29 |
| - |
30 |
| -> **Note:** This is the responsibility of the module author to implement tests for their module. and test the module locally before submitting a PR. |
|
0 commit comments