|
1 | | -# How to become a contributor and submit your own code |
| 1 | +# Contributing |
2 | 2 |
|
3 | | -## Contributor License Agreements |
| 3 | +This document provides guidelines for contributing to the module. |
4 | 4 |
|
5 | | -We'd love to accept your sample apps and patches! Before we can take them, we |
6 | | -have to jump a couple of legal hurdles. |
| 5 | +## Dependencies |
7 | 6 |
|
8 | | -Please fill out either the individual or corporate Contributor License |
9 | | -Agreement (CLA). |
| 7 | +The following dependencies must be installed on the development system: |
10 | 8 |
|
11 | | - * If you are an individual writing original source code and you're sure you |
12 | | - own the intellectual property, then you'll need to sign an [individual CLA](https://developers.google.com/open-source/cla/individual). |
13 | | - * If you work for a company that wants to allow you to contribute your work, |
14 | | - then you'll need to sign a [corporate CLA](https://developers.google.com/open-source/cla/corporate). |
| 9 | +- [Docker Engine][docker-engine] |
| 10 | +- [Google Cloud SDK][google-cloud-sdk] |
| 11 | +- [make] |
15 | 12 |
|
16 | | -Follow either of the two links above to access the appropriate CLA and |
17 | | -instructions for how to sign and return it. Once we receive it, we'll |
18 | | -be able to accept your pull requests. |
| 13 | +## Generating Documentation for Inputs and Outputs |
19 | 14 |
|
20 | | -## Contributing A Patch |
| 15 | +The Inputs and Outputs tables in the READMEs of the root module, |
| 16 | +submodules, and example modules are automatically generated based on |
| 17 | +the `variables` and `outputs` of the respective modules. These tables |
| 18 | +must be refreshed if the module interfaces are changed. |
21 | 19 |
|
22 | | -1. Submit an issue describing your proposed change to the repo in question. |
23 | | -1. The repo owner will respond to your issue promptly. |
24 | | -1. If your proposed change is accepted, and you haven't already done so, sign a |
25 | | - Contributor License Agreement (see details above). |
26 | | -1. Fork the desired repo, develop and test your code changes. |
27 | | -1. Ensure that your code adheres to the existing style in the sample to which |
28 | | - you are contributing. |
29 | | -1. Ensure that your code has an appropriate set of unit tests which all pass. |
30 | | -1. Submit a pull request. |
| 20 | +### Execution |
31 | 21 |
|
32 | | -## Style |
| 22 | +Run `make generate_docs` to generate new Inputs and Outputs tables. |
33 | 23 |
|
34 | | -Format your HCL code according to the [Hashicorp guidelines](https://github.com/hashicorp/hcl). |
35 | | -You can lint your terraform code by running `make check_terraform` and lint the entire repo by running `make`. Note: `make` lints and generates docs. |
| 24 | +## Integration Testing |
| 25 | + |
| 26 | +Integration tests are used to verify the behaviour of the root module, |
| 27 | +submodules, and example modules. Additions, changes, and fixes should |
| 28 | +be accompanied with tests. |
| 29 | + |
| 30 | +The integration tests are run using [Kitchen][kitchen], |
| 31 | +[Kitchen-Terraform][kitchen-terraform], and [InSpec][inspec]. These |
| 32 | +tools are packaged within a Docker image for convenience. |
| 33 | + |
| 34 | +The general strategy for these tests is to verify the behaviour of the |
| 35 | +[example modules](./examples/), thus ensuring that the root module, |
| 36 | +submodules, and example modules are all functionally correct. |
| 37 | + |
| 38 | +### Test Environment |
| 39 | +The easiest way to test the module is in an isolated test project. The setup for such a project is defined in [test/setup](./test/setup/) directory. |
| 40 | + |
| 41 | +To use this setup, you need a service account with Project Creator access on a folder. Export the Service Account credentials to your environment like so: |
| 42 | + |
| 43 | +``` |
| 44 | +export SERVICE_ACCOUNT_JSON=$(< credentials.json) |
| 45 | +``` |
| 46 | + |
| 47 | +You will also need to set a few environment variables: |
| 48 | +``` |
| 49 | +export TF_VAR_org_id="your_org_id" |
| 50 | +export TF_VAR_folder_id="your_folder_id" |
| 51 | +export TF_VAR_billing_account="your_billing_account_id" |
| 52 | +``` |
| 53 | + |
| 54 | +With these settings in place, you can prepare a test project using Docker: |
| 55 | +``` |
| 56 | +make docker_test_prepare |
| 57 | +``` |
| 58 | + |
| 59 | +### Noninteractive Execution |
| 60 | + |
| 61 | +Run `make docker_test_integration` to test all of the example modules |
| 62 | +noninteractively, using the prepared test project. |
| 63 | + |
| 64 | +### Interactive Execution |
| 65 | + |
| 66 | +1. Run `make docker_run` to start the testing Docker container in |
| 67 | + interactive mode. |
| 68 | + |
| 69 | +1. Run `kitchen_do create <EXAMPLE_NAME>` to initialize the working |
| 70 | + directory for an example module. |
| 71 | + |
| 72 | +1. Run `kitchen_do converge <EXAMPLE_NAME>` to apply the example module. |
| 73 | + |
| 74 | +1. Run `kitchen_do verify <EXAMPLE_NAME>` to test the example module. |
| 75 | + |
| 76 | +1. Run `kitchen_do destroy <EXAMPLE_NAME>` to destroy the example module |
| 77 | + state. |
| 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 | +### Execution |
| 85 | + |
| 86 | +Run `make docker_test_lint`. |
| 87 | + |
| 88 | +[docker-engine]: https://www.docker.com/products/docker-engine |
| 89 | +[flake8]: http://flake8.pycqa.org/en/latest/ |
| 90 | +[gofmt]: https://golang.org/cmd/gofmt/ |
| 91 | +[google-cloud-sdk]: https://cloud.google.com/sdk/install |
| 92 | +[hadolint]: https://github.com/hadolint/hadolint |
| 93 | +[inspec]: https://inspec.io/ |
| 94 | +[kitchen-terraform]: https://github.com/newcontext-oss/kitchen-terraform |
| 95 | +[kitchen]: https://kitchen.ci/ |
| 96 | +[make]: https://en.wikipedia.org/wiki/Make_(software) |
| 97 | +[shellcheck]: https://www.shellcheck.net/ |
| 98 | +[terraform-docs]: https://github.com/segmentio/terraform-docs |
| 99 | +[terraform]: https://terraform.io/ |
0 commit comments