Skip to content

Commit

Permalink
AZ-989: Update all common files and pre-commit configs
Browse files Browse the repository at this point in the history
  • Loading branch information
Shr3ps committed Feb 17, 2023
1 parent b413033 commit 6ba3478
Show file tree
Hide file tree
Showing 9 changed files with 211 additions and 20 deletions.
54 changes: 54 additions & 0 deletions .config/terraform-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
# This file is automatically maintained within this module repository -- DO NOT EDIT
formatter: "markdown"

settings:
anchor: false
lockfile: false

output:
file: "README.md"

sections:
hide: [requirements]

content: |-
## Global versioning rule for Claranet Azure modules
| Module version | Terraform version | AzureRM version |
| -------------- | ----------------- | --------------- |
| >= 7.x.x | 1.3.x | >= 3.0 |
| >= 6.x.x | 1.x | >= 3.0 |
| >= 5.x.x | 0.15.x | >= 2.0 |
| >= 4.x.x | 0.13.x / 0.14.x | >= 2.0 |
| >= 3.x.x | 0.12.x | >= 2.0 |
| >= 2.x.x | 0.12.x | < 2.0 |
| < 2.x.x | 0.11.x | < 2.0 |
## Contributing
If you want to contribute to this repository, feel free to use our [pre-commit](https://pre-commit.com/) git hook configuration
which will help you automatically update and format some files for you by enforcing our Terraform code module best-practices.
More details are available in the [CONTRIBUTING.md](./CONTRIBUTING.md#pull-request-process) file.
## Usage
This module is optimized to work with the [Claranet terraform-wrapper](https://github.com/claranet/terraform-wrapper) tool
which set some terraform variables in the environment needed by this module.
More details about variables set by the `terraform-wrapper` available in the [documentation](https://github.com/claranet/terraform-wrapper#environment).
```hcl
{{ include "examples/main/modules.tf" }}
```
{{ .Providers }}
{{ .Modules }}
{{ .Resources }}
{{ .Inputs }}
{{ .Outputs }}
...
66 changes: 66 additions & 0 deletions .config/tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
plugin "azurerm" {
enabled = true
source = "github.com/terraform-linters/tflint-ruleset-azurerm"
version = "0.20.0"
}

config {
module = true
force = false
disabled_by_default = false

varfile = ["terraform.tfvars.ci"]
}

rule "terraform_deprecated_interpolation" {
enabled = true
}

rule "terraform_deprecated_index" {
enabled = true
}

rule "terraform_unused_declarations" {
enabled = true
}

rule "terraform_comment_syntax" {
enabled = true
}

rule "terraform_documented_outputs" {
enabled = true
}

rule "terraform_documented_variables" {
enabled = true
}

rule "terraform_typed_variables" {
enabled = true
}

rule "terraform_module_pinned_source" {
enabled = true
}

rule "terraform_naming_convention" {
enabled = true
}

rule "terraform_required_version" {
enabled = true
}

rule "terraform_required_providers" {
enabled = true
}

rule "terraform_unused_required_providers" {
enabled = true
}

# Disabled since we have files like "variables-xxxx.tf" instead of a single "variables.tf"
rule "terraform_standard_module_structure" {
enabled = false
}
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @bzspi @shr3ps @rossifumax @jmapro @maxpoullain
5 changes: 5 additions & 0 deletions .github/workflows/github-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: CI
on: [push]
jobs:
ci:
uses: claranet/terraform-modules-ci/.github/workflows/ci-modules.yaml@main
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-yaml
args:
- --unsafe
- id: check-symlinks
- id: check-added-large-files
- id: detect-private-key

- repo: https://github.com/antonbabenko/pre-commit-terraform.git
rev: v1.77.1
hooks:
- id: terraform_fmt
- id: terraform_docs
args:
- --args=--config=.config/terraform-docs.yml
- id: terraform_validate
exclude: ^examples
- id: terraform_tflint
exclude: ^examples
args:
- --args=--config=__GIT_WORKING_DIR__/.config/tflint.hcl
- --env-vars=TFLINT_LOG="info"
- id: terraform_tfsec
64 changes: 47 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,50 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make via issue,
email, or any other method with the owners of this repository before making a change.
When contributing to this repository, please first discuss the change you wish to make via an issue,
an email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

## Pull Request Process

1. Ensure any install or build dependencies are removed before the end of the layer when doing a
build.
2. Update the README.md with details of changes to the interface, this includes new environment
variables, exposed ports, useful file locations and container parameters.
3. Increase the version numbers in any examples files and the README.md to the new version that this
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
do not have permission to do that, you may request the second reviewer to merge it for you.
1. Ensure any installed or built dependencies are removed before the end of the layer when doing a
Pull Request. Ensure also that your code is clean and production ready.
2. Update the [README.md](./README.md) with details of changes to the module, including variables, outputs
or changes to [examples](./examples).
3. Update the [CHANGELOG.md](./CHANGELOG.md) with a new entry block starting with `# Unreleased`
followed by a description of your new feature, bug fix or change.
4. The Github Actions CI must pass. It ensures that our Terraform module codestyle rules are followed.
5. Please wait for maintainers to review your code, they will merge and release your changes once every
discussions or implementation details are satisfied.

### Pre-commit usage

We recommend using `pre-commit` ([the famous python git hooks tool](https://pre-commit.com/#intro))
when you start a contribution. It will automatically trigger hooks which ensure our codestyle rules are followed,
files are formatted and linted, and that your README.md file is proprerly generated and updated.

Installation on your local system:
```bash
$ pipx install pre-commit
```
or
```bash
$ pip3 install pre-commit --user
```

and then, configure and enable our hooks:
```bash
$ cd path_to_the_git_cloned_module/
$ pre-commit install
```

Do your changes as usual, hooks will be triggered by `pre-commit` every time you use the `git commit` command.

To have all `pre-commit` hooks working you will have to setup thoses dependencies locally:
- latest version of [terraform](https://releases.hashicorp.com/terraform/)
- [tfdocs](https://github.com/terraform-docs/terraform-docs)
- [tflint](https://github.com/terraform-linters/tflint)
- [tfsec](https://github.com/aquasecurity/tfsec)

## Code of Conduct

Expand All @@ -29,18 +59,18 @@ orientation.

### Our Standards

Examples of behavior that contributes to creating a positive environment
Examples of behavior that contribute to creating a positive environment
include:

* Using welcoming and inclusive language
* Using a welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
* The use of sexualized language or imagery and unwelcome sexual attentions or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
Expand All @@ -52,13 +82,13 @@ advances
### Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
behavior and are expected to take appropriate and fair corrective actions in
response to any instance of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
that are not aligned to this Code of Conduct, to temporarily or permanently
ban any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

### Scope
Expand Down
3 changes: 1 addition & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright (c) 2018 Claranet
Copyright (c) 2018-2023 Claranet

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -199,4 +199,3 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2018-2019 Claranet
Copyright (c) 2018-2023 Claranet

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ This module must be used within a [Virtual Network](https://docs.microsoft.com/e
| >= 2.x.x | 0.12.x | < 2.0 |
| < 2.x.x | 0.11.x | < 2.0 |

## Contributing

If you want to contribute to this repository, feel free to use our [pre-commit](https://pre-commit.com/) git hook configuration
which will help you automatically update and format some files for you by enforcing our Terraform code module best-practices.

More details are available in the [CONTRIBUTING.md](./CONTRIBUTING.md#pull-request-process) file.

## Usage

This module is optimized to work with the [Claranet terraform-wrapper](https://github.com/claranet/terraform-wrapper) tool
Expand Down

0 comments on commit 6ba3478

Please sign in to comment.