|
| 1 | +# Contributing |
| 2 | + |
| 3 | +This document provides guidelines for contributing to the module. |
| 4 | + |
| 5 | +## Generating Documentation for Inputs and Outputs |
| 6 | + |
| 7 | +The Inputs and Outputs tables in the READMEs of the root module, |
| 8 | +submodules, and example modules are automatically generated based on |
| 9 | +the `variables` and `outputs` of the respective modules. These tables |
| 10 | +must be refreshed if the module interfaces are changed. |
| 11 | + |
| 12 | +### Dependencies |
| 13 | + |
| 14 | +The following dependencies must be installed on the development system: |
| 15 | + |
| 16 | +- [make] |
| 17 | +- [terraform-docs] v0.6.0 |
| 18 | + |
| 19 | +### Execution |
| 20 | + |
| 21 | +Run `make generate_docs` to generate new Inputs and Outputs tables. |
| 22 | + |
| 23 | +## Integration Testing |
| 24 | + |
| 25 | +Integration tests are used to verify the behaviour of the root module, |
| 26 | +submodules, and example modules. Additions, changes, and fixes should |
| 27 | +be accompanied with tests. |
| 28 | + |
| 29 | +The integration tests are run using [Kitchen][kitchen], |
| 30 | +[Kitchen-Terraform][kitchen-terraform], and [InSpec][inspec]. These |
| 31 | +tools are packaged within a Docker image for convenience. |
| 32 | + |
| 33 | +The general strategy for these tests is to verify the behaviour of the |
| 34 | +[example modules](./examples), thus ensuring that the root module, |
| 35 | +submodules, and example modules are all functionally correct. |
| 36 | + |
| 37 | +### Dependencies |
| 38 | + |
| 39 | +The following dependencies must be installed on the development system: |
| 40 | + |
| 41 | +- [Docker Engine][docker-engine] |
| 42 | +- [Google Cloud SDK][google-cloud-sdk] |
| 43 | +- [make] |
| 44 | + |
| 45 | +### Inputs |
| 46 | + |
| 47 | +Test instances are defined in the |
| 48 | +[Kitchen configuration file](./kitchen.yml). The inputs of each Kitchen |
| 49 | +instance may be configured with the `driver.variables` key in a |
| 50 | +local Kitchen configuration file located at `./kitchen.local.yml` or in |
| 51 | +a Terraform variables file located at |
| 52 | +`./test/fixtures/<instance>/variables.tfvars`. |
| 53 | + |
| 54 | +### Credentials |
| 55 | + |
| 56 | +Download the key of a Service Account with the |
| 57 | +[required roles][required-roles] to `./credentials.json`. |
| 58 | + |
| 59 | +### Interactive Execution |
| 60 | + |
| 61 | +1. Run `make docker_run` to start the testing Docker container in |
| 62 | + interactive mode. |
| 63 | + |
| 64 | +1. Run `kitchen create <EXAMPLE_NAME>` to initialize the working |
| 65 | + directory for an example module. |
| 66 | + |
| 67 | +1. Run `kitchen converge <EXAMPLE_NAME>` to apply the example module. |
| 68 | + |
| 69 | +1. Run `kitchen verify <EXAMPLE_NAME>` to test the example module. |
| 70 | + |
| 71 | +1. Run `kitchen destroy <EXAMPLE_NAME>` to destroy the example module |
| 72 | + state. |
| 73 | + |
| 74 | +### Noninteractive Execution |
| 75 | + |
| 76 | +Run `make test_integration_docker` to test all of the example modules |
| 77 | +noninteractively. |
| 78 | + |
| 79 | +## Linting and Formatting |
| 80 | + |
| 81 | +Many of the files in the repository can be linted or formatted to |
| 82 | +maintain a standard of quality. |
| 83 | + |
| 84 | +### Dependencies |
| 85 | + |
| 86 | +The following dependencies must be installed on the development system: |
| 87 | + |
| 88 | +- [flake8] |
| 89 | +- [gofmt] |
| 90 | +- [hadolint] |
| 91 | +- [make] |
| 92 | +- [shellcheck] |
| 93 | +- [Terraform][terraform] v0.11 |
| 94 | + |
| 95 | +### Execution |
| 96 | + |
| 97 | +Run `make check`. |
| 98 | + |
| 99 | +[docker-engine]: https://www.docker.com/products/docker-engine |
| 100 | +[flake8]: http://flake8.pycqa.org/en/latest/ |
| 101 | +[gofmt]: https://golang.org/cmd/gofmt/ |
| 102 | +[google-cloud-sdk]: https://cloud.google.com/sdk/install |
| 103 | +[hadolint]: https://github.com/hadolint/hadolint |
| 104 | +[inspec]: https://inspec.io/ |
| 105 | +[kitchen-terraform]: https://github.com/newcontext-oss/kitchen-terraform |
| 106 | +[kitchen]: https://kitchen.ci/ |
| 107 | +[make]: https://en.wikipedia.org/wiki/Make_(software) |
| 108 | +[shellcheck]: https://www.shellcheck.net/ |
| 109 | +[terraform-docs]: https://github.com/segmentio/terraform-docs |
| 110 | +[terraform]: https://terraform.io/ |
0 commit comments