Skip to content

Commit 53a866e

Browse files
authored
feat: Add GH checks and templates (antonbabenko#222)
1 parent c920368 commit 53a866e

File tree

8 files changed

+326
-11
lines changed

8 files changed

+326
-11
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
name: Local installation bug report
3+
about: Create a bug report
4+
labels:
5+
- kind/bug
6+
- area/docker
7+
---
8+
9+
<!--
10+
Thank you for helping to improve pre-commit-terraform!
11+
12+
Please be sure to search for open issues before raising a new one. We use issues
13+
for bug reports and feature requests. Please note, this template is for bugs
14+
report, not feature requests.
15+
-->
16+
17+
### Describe the bug
18+
19+
<!--
20+
Please let us know what behavior you expected and how terraform-docs diverged
21+
from that behavior.
22+
-->
23+
24+
25+
### How can we reproduce it?
26+
27+
<!--
28+
Help us to reproduce your bug as succinctly and precisely as possible. Any and
29+
all steps or script that triggers the issue are highly appreciated!
30+
31+
Do you have long logs to share? Please use collapsible sections, that can be created via:
32+
33+
<details><summary>SECTION_NAME</summary>
34+
35+
```bash
36+
YOUR_LOG_HERE
37+
```
38+
39+
</details>
40+
-->
41+
42+
43+
### Environment information
44+
45+
* OS:
46+
47+
<!-- I.e.:
48+
OS: Windows 10
49+
OS: Win10 with Ubuntu 20.04 on WSL2
50+
OS: MacOS
51+
OS: Ubuntu 20.04
52+
-->
53+
54+
* `docker info`:
55+
56+
<details><summary><code>command output</summary>
57+
58+
```bash
59+
INSERT_OUTPUT_HERE
60+
```
61+
62+
</details>
63+
64+
* Docker image tag/git commit:
65+
66+
* Tools versions. Don't forget to specify right tag in command -
67+
`TAG=latest && docker run --entrypoint cat pre-commit:$TAG /usr/bin/tools_versions_info`
68+
69+
```bash
70+
INSERT_OUTPUT_HERE
71+
```
72+
73+
* `.pre-commit-config.yaml`:
74+
75+
<details><summary>file content</summary>
76+
77+
```bash
78+
INSERT_FILE_CONTENT_HERE
79+
```
80+
81+
</details>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
name: Docker bug report
3+
about: Create a bug report
4+
labels:
5+
- kind/bug
6+
- area/local_installation
7+
---
8+
9+
<!--
10+
Thank you for helping to improve pre-commit-terraform!
11+
12+
Please be sure to search for open issues before raising a new one. We use issues
13+
for bug reports and feature requests. Please note, this template is for bugs
14+
report, not feature requests.
15+
-->
16+
17+
### Describe the bug
18+
19+
<!--
20+
Please let us know what behavior you expected and how terraform-docs diverged
21+
from that behavior.
22+
-->
23+
24+
25+
### How can we reproduce it?
26+
27+
<!--
28+
Help us to reproduce your bug as succinctly and precisely as possible. Any and
29+
all steps or script that triggers the issue are highly appreciated!
30+
31+
Do you have long logs to share? Please use collapsible sections, that can be created via:
32+
33+
<details><summary>SECTION_NAME</summary>
34+
35+
```bash
36+
YOUR_LOG_HERE
37+
```
38+
39+
</details>
40+
-->
41+
42+
43+
### Environment information
44+
45+
* OS:
46+
<!-- I.e.:
47+
OS: Windows 10
48+
OS: Win10 with Ubuntu 20.04 on WSL2
49+
OS: MacOS
50+
OS: Ubuntu 20.04
51+
-->
52+
53+
* `uname -a` and/or `systeminfo | Select-String "^OS"` output:
54+
55+
```bash
56+
INSERT_OUTPUT_HERE
57+
```
58+
59+
<!-- I.e.:
60+
```bash
61+
PS C:\Users\vm> systeminfo | Select-String "^OS"
62+
63+
OS Name: Microsoft Windows 10 Pro
64+
OS Version: 10.0.19043 N/A Build 19043
65+
OS Manufacturer: Microsoft Corporation
66+
OS Configuration: Standalone Workstation
67+
OS Build Type: Multiprocessor Free
68+
69+
$ uname -a
70+
Linux DESKTOP-C7315EF 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
71+
```
72+
-->
73+
74+
* Tools availability and versions:
75+
76+
<!-- For check all needed version run next script:
77+
78+
$0 << EOF
79+
pre-commit --version 2>/dev/null || echo "pre-commit SKIPPED"
80+
terraform --version | head -n 1 2>/dev/null || echo "terraform SKIPPED"
81+
python --version 2>/dev/null || echo "python SKIPPED"
82+
python3 --version 2>/dev/null || echo "python3 SKIPPED"
83+
echo -n "checkov " && checkov --version 2>/dev/null || echo "checkov SKIPPED"
84+
terraform-docs --version 2>/dev/null || echo "terraform-docs SKIPPED"
85+
terragrunt --version 2>/dev/null || echo "terragrunt SKIPPED"
86+
echo -n "terrascan " && terrascan version 2>/dev/null || echo "terrascan SKIPPED"
87+
tflint --version 2>/dev/null || echo "tflint SKIPPED"
88+
echo -n "tfsec " && tfsec --version 2>/dev/null || echo "tfsec SKIPPED"
89+
EOF
90+
91+
-->
92+
93+
```bash
94+
INSERT_TOOLS_VERSIONS_HERE
95+
```
96+
97+
98+
* `.pre-commit-config.yaml`:
99+
100+
<details><summary>file content</summary>
101+
102+
```bash
103+
INSERT_FILE_CONTENT_HERE
104+
```
105+
106+
</details>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
labels:
5+
- kind/feature
6+
---
7+
8+
<!--
9+
Thank you for helping to improve pre-commit-terraform!
10+
11+
Please be sure to search for open issues before raising a new one. We use issues
12+
for bug reports and feature requests. Please note, this template is for feature
13+
requests, not bugs report.
14+
-->
15+
16+
### What problem are you facing?
17+
18+
<!--
19+
Please tell us a little about your use case - it's okay if it's hypothetical!
20+
Leading with this context helps frame the feature request so we can ensure we
21+
implement it sensibly.
22+
--->
23+
24+
25+
### How could pre-commit-terraform help solve your problem?
26+
27+
<!--
28+
Let us know how you think pre-commit-terraform could help with your use case.
29+
-->

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!--
2+
Thank you for helping to improve pre-commit-terraform!
3+
-->
4+
5+
Put an `x` into the box if that apply:
6+
7+
- [ ] This PR introduces breaking change.
8+
- [ ] This PR fixes a bug.
9+
- [ ] This PR adds new functionality.
10+
- [ ] This PR enhances existing functionality.
11+
12+
### Description of your changes
13+
14+
<!--
15+
Briefly describe what this pull request does. Be sure to direct your reviewers'
16+
attention to anything that needs special consideration.
17+
18+
We love pull requests that resolve an open pre-commit-terraform issue. If yours does, you
19+
can uncomment the below line to indicate which issue your PR fixes, for example
20+
"Fixes #123":
21+
-->
22+
23+
<!-- Fixes # -->
24+
25+
### How has this code been tested
26+
27+
<!--
28+
Before reviewers can be confident in the correctness of this pull request, it
29+
needs to tested and shown to be correct. Briefly describe the testing that has
30+
already been done or which is planned for this change.
31+
-->

.github/workflows/pre-commit.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Common issues check
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
pre-commit:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- run: |
11+
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
12+
- name: Get changed files
13+
id: file_changes
14+
run: |
15+
export DIFF=$(git diff --name-only origin/${{ github.base_ref }} ${{ github.sha }})
16+
echo "Diff between ${{ github.base_ref }} and ${{ github.sha }}"
17+
echo "::set-output name=files::$( echo "$DIFF" | xargs echo )"
18+
- uses: actions/setup-python@v2
19+
with:
20+
python-version: '3.9'
21+
- name: Execute pre-commit
22+
uses: pre-commit/[email protected]
23+
env:
24+
SKIP: no-commit-to-branch
25+
with:
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
extra_args: --color=always --show-diff-on-failure --files ${{ steps.file_changes.outputs.files }}

.github/workflows/stale-actions.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "Mark or close stale issues and PRs"
2+
on:
3+
schedule:
4+
- cron: "0 0 * * *"
5+
6+
jobs:
7+
stale:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/stale@v3
11+
with:
12+
repo-token: ${{ secrets.GITHUB_TOKEN }}
13+
# Staling issues and PR's
14+
days-before-stale: 30
15+
stale-issue-label: lifecycle/stale
16+
stale-pr-label: lifecycle/stale
17+
stale-issue-message: |
18+
This issue has been automatically marked as stale because it has been open 30 days
19+
with no activity. Remove stale label or comment or this issue will be closed in 10 days
20+
stale-pr-message: |
21+
This PR has been automatically marked as stale because it has been open 30 days
22+
with no activity. Remove stale label or comment or this PR will be closed in 10 days
23+
# Not stale if have this labels
24+
exempt-issue-labels: kind/bug,lifecycle/active,lifecycle/frozen
25+
exempt-pr-labels: kind/bug,lifecycle/active,lifecycle/frozen
26+
# If unstale
27+
labels-to-remove-when-unstale: lifecycle/stale
28+
# Close issue operations
29+
# Label will be automatically removed if the issues are no longer closed nor locked.
30+
days-before-close: 10
31+
close-issue-label: lifecycle/rotten
32+
delete-branch: true
33+
close-issue-message: This issue was automatically closed because of stale in 10 days
34+
close-pr-message: This PR was automatically closed because of stale in 10 days

Dockerfile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,18 @@ RUN . /.env && \
123123
) && chmod +x tfsec \
124124
; fi
125125

126-
# Checking binaries versions
126+
# Checking binaries versions and write it to debug file
127127
RUN . /.env && \
128-
echo "\n\n" && \
129-
pre-commit --version && \
130-
terraform --version | head -n 1 && \
131-
(if [ "$CHECKOV_VERSION" != "false" ]; then echo -n "checkov " && checkov --version; else echo "checkov SKIPPED" ; fi) && \
132-
(if [ "$TERRAFORM_DOCS_VERSION" != "false" ]; then ./terraform-docs --version; else echo "terraform-docs SKIPPED"; fi) && \
133-
(if [ "$TERRAGRUNT_VERSION" != "false" ]; then ./terragrunt --version; else echo "terragrunt SKIPPED" ; fi) && \
134-
(if [ "$TERRASCAN_VERSION" != "false" ]; then echo -n "terrascan " && ./terrascan version; else echo "terrascan SKIPPED" ; fi) && \
135-
(if [ "$TFLINT_VERSION" != "false" ]; then ./tflint --version; else echo "tflint SKIPPED" ; fi) && \
136-
(if [ "$TFSEC_VERSION" != "false" ]; then echo -n "tfsec " && ./tfsec --version; else echo "tfsec SKIPPED" ; fi) && \
137-
echo "\n\n"
128+
F=tools_versions_info && \
129+
pre-commit --version >> $F && \
130+
terraform --version | head -n 1 >> $F && \
131+
(if [ "$CHECKOV_VERSION" != "false" ]; then echo "checkov $(checkov --version)" >> $F; else echo "checkov SKIPPED" >> $F ; fi) && \
132+
(if [ "$TERRAFORM_DOCS_VERSION" != "false" ]; then ./terraform-docs --version >> $F; else echo "terraform-docs SKIPPED" >> $F; fi) && \
133+
(if [ "$TERRAGRUNT_VERSION" != "false" ]; then ./terragrunt --version >> $F; else echo "terragrunt SKIPPED" >> $F ; fi) && \
134+
(if [ "$TERRASCAN_VERSION" != "false" ]; then echo "terrascan $(./terrascan version)" >> $F; else echo "terrascan SKIPPED" >> $F ; fi) && \
135+
(if [ "$TFLINT_VERSION" != "false" ]; then ./tflint --version >> $F; else echo "tflint SKIPPED" >> $F ; fi) && \
136+
(if [ "$TFSEC_VERSION" != "false" ]; then echo "tfsec $(./tfsec --version)" >> $F; else echo "tfsec SKIPPED" >> $F ; fi) && \
137+
echo "\n\n" && cat $F && echo "\n\n"
138138

139139
# based on debian:buster-slim
140140
# https://github.com/docker-library/python/blob/master/3.9/buster/slim/Dockerfile

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
</sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub><br><br>
3838
* [`checkov`](https://github.com/bridgecrewio/checkov) required for `checkov` hook.
3939
* [`terraform-docs`](https://github.com/terraform-docs/terraform-docs) required for `terraform_docs` hooks.
40+
* [`terragrunt`](https://terragrunt.gruntwork.io/docs/getting-started/install/) required for `terragrunt_validate` hook.
4041
* [`terrascan`](https://github.com/accurics/terrascan) required for `terrascan` hook.
4142
* [`TFLint`](https://github.com/terraform-linters/tflint) required for `terraform_tflint` hook.
4243
* [`TFSec`](https://github.com/liamg/tfsec) required for `terraform_tfsec` hook.
@@ -163,6 +164,12 @@ Docker:
163164
docker run -v $(pwd):/lint -w /lint pre-commit run -a
164165
```
165166

167+
> You be able list tools versions when needed
168+
>
169+
> ```bash
170+
> TAG=latest && docker run --entrypoint cat pre-commit:$TAG /usr/bin/tools_versions_info
171+
> ```
172+
166173
## Available Hooks
167174
168175
There are several [pre-commit](https://pre-commit.com/) hooks to keep Terraform configurations (both `*.tf` and `*.tfvars`) and Terragrunt configurations (`*.hcl`) in a good shape:

0 commit comments

Comments
 (0)