Skip to content

Commit fbd9bf3

Browse files
authored
Merge pull request #7 from tomarv2/develop
Develop
2 parents 4119560 + c099eb8 commit fbd9bf3

File tree

8 files changed

+260
-23
lines changed

8 files changed

+260
-23
lines changed

.github/workflows/pre-commit.yml

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ on:
44
pull_request:
55
push:
66
branches:
7-
- main
87
- develop
8+
- main
99

1010
jobs:
11-
# Min Terraform version(s)
1211
getDirectories:
1312
name: Get root directories
1413
runs-on: ubuntu-latest
@@ -25,13 +24,13 @@ jobs:
2524
- name: Build matrix
2625
id: matrix
2726
run: |
28-
DIRS=$(python -c "import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))")
27+
DIRS=$(python -c "import json; import glob; print(json.dumps([x.replace('/providers.tf', '') for x in glob.glob('./**/providers.tf', recursive=True)]))")
2928
echo "::set-output name=directories::$DIRS"
3029
outputs:
3130
directories: ${{ steps.matrix.outputs.directories }}
3231

3332
preCommitMinVersions:
34-
name: Min TF validate
33+
name: Min validate
3534
needs: getDirectories
3635
runs-on: ubuntu-latest
3736
strategy:
@@ -58,11 +57,9 @@ jobs:
5857
with:
5958
terraform_version: ${{ steps.minMax.outputs.minVersion }}
6059

61-
- name: Install pre-commit dependencies
60+
- name: Install pre-commit
6261
run: pip install pre-commit
6362

64-
65-
# Max Terraform version
6663
getBaseVersion:
6764
name: Module max TF version
6865
runs-on: ubuntu-latest
@@ -78,7 +75,7 @@ jobs:
7875
maxVersion: ${{ steps.minMax.outputs.maxVersion }}
7976

8077
preCommitMaxVersion:
81-
name: Max TF pre-commit
78+
name: Max pre-commit
8279
runs-on: ubuntu-latest
8380
needs: getBaseVersion
8481
strategy:
@@ -105,10 +102,59 @@ jobs:
105102
run: |
106103
pip install pre-commit
107104
pip install checkov
108-
curl -L "$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E "https://.+?-v1.0.1-linux-amd64" | head -n1)" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/
109105
curl -L "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/
110106
111107
- name: Execute pre-commit
112-
# Run all pre-commit checks on max version supported
113-
if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}
114-
run: pre-commit run --color=always --show-diff-on-failure --all-files
108+
continue-on-error: true # To avoid pre-commit failure
109+
run: |
110+
pre-commit run --color=always --show-diff-on-failure --all-files
111+
112+
- name: Get current branch name
113+
id: vars
114+
run: |
115+
echo ::set-output name=branch_name::${GITHUB_REF##*/}
116+
117+
- name: "Get branch name and save to env"
118+
env:
119+
IS_PR: ${{ github.EVENT_NAME == 'pull_request' }}
120+
run: |
121+
if ${IS_PR}; then
122+
BRANCH_NAME="${GITHUB_HEAD_REF}"
123+
else
124+
BRANCH_NAME="${GITHUB_REF##*/}"
125+
fi
126+
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
127+
128+
- uses: actions/checkout@v2
129+
with:
130+
ref: ${{ github.event.pull_request.head.ref }}
131+
132+
- name: Render terraform docs and commit changes
133+
if: ${{ env.BRANCH_NAME }} == 'develop'
134+
uses: terraform-docs/gh-actions@main
135+
with:
136+
working-dir: .
137+
output-file: README.md
138+
output-method: inject
139+
git-push: "true"
140+
141+
- name: Commit pre-commit modified files
142+
if: ${{ env.BRANCH_NAME }} == 'develop'
143+
run: |
144+
git config --local user.email "terraform+github-actions[bot]@users.noreply.github.com"
145+
git config --local user.name "github-actions[bot]"
146+
git diff-index --quiet HEAD || (git add -A && git commit -m'[bot] update files' --allow-empty && git push -f)
147+
148+
- uses: actions/checkout@v2
149+
- name: Create PR
150+
continue-on-error: true
151+
uses: repo-sync/pull-request@v2
152+
if: ${{ env.BRANCH_NAME }} == 'develop'
153+
with:
154+
source_branch: "develop"
155+
destination_branch: "main"
156+
pr_title: "Pulling ${{ github.ref }} into main"
157+
pr_body: ":crown: *Automated PR*"
158+
pr_label: "auto-pr"
159+
pr_allow_empty: false
160+
github_token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: "Mark or close stale issues and PRs"
2+
on:
3+
schedule:
4+
- cron: "0 0 10 * *"
5+
6+
jobs:
7+
stale:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/stale@v4
11+
with:
12+
repo-token: ${{ secrets.GITHUB_TOKEN }}
13+
# Staling issues and PR's
14+
days-before-stale: 30
15+
stale-issue-label: stale
16+
stale-pr-label: 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 or part of milestone
24+
exempt-issue-labels: bug,wip,on-hold
25+
exempt-pr-labels: bug,wip,on-hold
26+
exempt-all-milestones: true
27+
# Close issue operations
28+
# Label will be automatically removed if the issues are no longer closed nor locked.
29+
days-before-close: 10
30+
delete-branch: false
31+
close-issue-message: This issue was automatically closed because of stale in 10 days
32+
close-pr-message: This PR was automatically closed because of stale in 10 days
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Bump version
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Bump version and push tag
12+
id: tag_version
13+
uses: mathieudutour/[email protected]
14+
with:
15+
github_token: ${{ secrets.GITHUB_TOKEN }}
16+
17+
- name: Create a GitHub release
18+
uses: ncipollo/release-action@v1
19+
with:
20+
tag: ${{ steps.tag_version.outputs.new_tag }}
21+
name: Release ${{ steps.tag_version.outputs.new_tag }}
22+
body: ${{ steps.tag_version.outputs.changelog }}

.gitignore

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,136 @@ _testmain.go
7979
/test/run.out
8080
/test/times.out
8181

82+
# Python
83+
# Editors
84+
.vscode/
85+
.idea/
86+
87+
# Vagrant
88+
.vagrant/
89+
90+
# Mac/OSX
91+
.DS_Store
92+
93+
# Windows
94+
Thumbs.db
95+
96+
# Source for the following rules: https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore
97+
# Byte-compiled / optimized / DLL files
98+
__pycache__/
99+
*.py[cod]
100+
*$py.class
101+
102+
# C extensions
103+
*.so
104+
105+
# Distribution / packaging
106+
.Python
107+
build/
108+
develop-eggs/
109+
dist/
110+
downloads/
111+
eggs/
112+
.eggs/
113+
lib/
114+
lib64/
115+
parts/
116+
sdist/
117+
var/
118+
wheels/
119+
*.egg-info/
120+
.installed.cfg
121+
*.egg
122+
MANIFEST
123+
124+
# PyInstaller
125+
# Usually these files are written by a python script from a template
126+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
127+
*.manifest
128+
*.spec
129+
130+
# Installer logs
131+
pip-log.txt
132+
pip-delete-this-directory.txt
133+
134+
# Unit test / coverage reports
135+
htmlcov/
136+
.tox/
137+
.nox/
138+
.coverage
139+
.coverage.*
140+
.cache
141+
nosetests.xml
142+
coverage.xml
143+
*.cover
144+
.hypothesis/
145+
.pytest_cache/
146+
147+
# Translations
148+
*.mo
149+
*.pot
150+
151+
# Django stuff:
152+
*.log
153+
local_settings.py
154+
db.sqlite3
155+
156+
# Flask stuff:
157+
instance/
158+
.webassets-cache
159+
160+
# Scrapy stuff:
161+
.scrapy
162+
163+
# Sphinx documentation
164+
docs/_build/
165+
166+
# PyBuilder
167+
target/
168+
169+
# Jupyter Notebook
170+
.ipynb_checkpoints
171+
172+
# IPython
173+
profile_default/
174+
ipython_config.py
175+
176+
# pyenv
177+
.python-version
178+
179+
# celery beat schedule file
180+
celerybeat-schedule
181+
182+
# SageMath parsed files
183+
*.sage.py
184+
185+
# Environments
186+
.env
187+
.venv
188+
env/
189+
venv/
190+
ENV/
191+
env.bak/
192+
venv.bak/
193+
194+
# Spyder project settings
195+
.spyderproject
196+
.spyproject
197+
198+
# Rope project settings
199+
.ropeproject
200+
201+
# mkdocs documentation
202+
/site
203+
204+
# mypy
205+
.mypy_cache/
206+
.dmypy.json
207+
dmypy.json
208+
82209
# ignore test related file(s)
83210
**/test**
84211
**.
212+
213+
# ignore terraform external modules
85214
**/.external_modules

.pre-commit-config.yaml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,38 @@
11
repos:
2-
- repo: git://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.48.0
2+
- repo: https://github.com/antonbabenko/pre-commit-terraform
3+
rev: v1.64.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_tflint
77
args:
88
- '--args=--only=terraform_deprecated_interpolation'
99
- '--args=--only=terraform_deprecated_index'
10+
- '--args=--only=terraform_unused_declarations'
1011
- '--args=--only=terraform_comment_syntax'
1112
- '--args=--only=terraform_documented_outputs'
1213
- '--args=--only=terraform_documented_variables'
1314
- '--args=--only=terraform_typed_variables'
14-
- '--args=--only=terraform_module_pinned_source'
15+
#- '--args=--only=terraform_module_pinned_source'
1516
- '--args=--only=terraform_naming_convention'
1617
- '--args=--only=terraform_required_providers'
18+
- '--args=--only=terraform_standard_module_structure'
1719
- '--args=--only=terraform_workspace_remote'
1820

1921
- repo: https://github.com/pre-commit/pre-commit-hooks
20-
rev: v3.4.0
22+
rev: v4.1.0
2123
hooks:
2224
- id: trailing-whitespace
23-
- id: check-merge-conflict
2425
- id: end-of-file-fixer
26+
- id: check-docstring-first
2527
- id: check-yaml
28+
- id: debug-statements
29+
- id: double-quote-string-fixer
30+
- id: name-tests-test
31+
- id: requirements-txt-fixer
2632

2733
- repo: https://github.com/bridgecrewio/checkov.git
28-
rev: '2.0.531'
34+
rev: '2.0.914'
2935
hooks:
3036
- id: checkov
3137
verbose: true
32-
args: [-d, '.', --framework, 'terraform', --download-external-modules, 'True']
38+
args: [-d, '.', --framework,'terraform']

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Please refer to examples directory [link](examples) for references.
110110

111111
##### - Terraform module for [Databricks AWS Workspace](https://github.com/tomarv2/terraform-databricks-aws-workspace)
112112

113+
<!-- BEGIN_TF_DOCS -->
113114
## Requirements
114115

115116
| Name | Version |
@@ -124,11 +125,11 @@ Please refer to examples directory [link](examples) for references.
124125

125126
| Name | Version |
126127
|------|---------|
127-
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | 2.94.0 |
128+
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | ~> 2.94 |
128129
| <a name="provider_databricks"></a> [databricks](#provider\_databricks) | 0.3.5 |
129130
| <a name="provider_databricks.created_workspace"></a> [databricks.created\_workspace](#provider\_databricks.created\_workspace) | 0.3.5 |
130-
| <a name="provider_external"></a> [external](#provider\_external) | 2.2.0 |
131-
| <a name="provider_random"></a> [random](#provider\_random) | 3.1.0 |
131+
| <a name="provider_external"></a> [external](#provider\_external) | ~> 2.2 |
132+
| <a name="provider_random"></a> [random](#provider\_random) | ~> 3.1 |
132133

133134
## Modules
134135

@@ -180,3 +181,4 @@ Please refer to examples directory [link](examples) for references.
180181
| <a name="output_managed_resource_group_name"></a> [managed\_resource\_group\_name](#output\_managed\_resource\_group\_name) | databricks managed resource group name |
181182
| <a name="output_nonsensitive_databricks_token"></a> [nonsensitive\_databricks\_token](#output\_nonsensitive\_databricks\_token) | Value of the newly-created token |
182183
| <a name="output_resource_group_name"></a> [resource\_group\_name](#output\_resource\_group\_name) | databricks resource group name |
184+
<!-- END_TF_DOCS -->

examples/azure_databricks/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ output "sensitive_databricks_token" {
3030
}
3131

3232
output "databricks_token" {
33-
description = "Value of the newly-created token (nonsensitive)"
33+
description = "Value of the newly created token (nonsensitive)"
3434
value = module.azure_databricks.nonsensitive_databricks_token
3535
}
3636

File renamed without changes.

0 commit comments

Comments
 (0)