|
1 | 1 | #
|
2 |
| -# Copyright (C) 2024 Appvia Ltd <[email protected]> |
3 |
| -# |
4 | 2 | # This program is free software; you can redistribute it and/or
|
5 | 3 | # modify it under the terms of the GNU General Public License
|
6 | 4 | # as published by the Free Software Foundation; either version 2
|
|
14 | 12 | # You should have received a copy of the GNU General Public License
|
15 | 13 | # along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16 | 14 | #
|
17 |
| - |
18 | 15 |
|
19 |
| -.PHONY: all security lint format documentation documentation-examples validate-all validate validate-examples init |
| 16 | +.PHONY: all security lint format documentation validate init commitlint |
20 | 17 |
|
21 | 18 | default: all
|
22 | 19 |
|
|
31 | 28 | documentation:
|
32 | 29 | @echo "--> Generating documentation"
|
33 | 30 | @terraform-docs markdown table --output-file ${PWD}/README.md --output-mode inject .
|
34 |
| - $(MAKE) documentation-examples |
35 |
| - |
36 |
| -documentation-examples: |
37 |
| - @echo "--> Generating documentation examples" |
38 |
| - @find examples -type d -mindepth 1 -maxdepth 1 -exec terraform-docs markdown table --output-file README.md --output-mode inject {} \; |
39 | 31 |
|
40 | 32 | init:
|
41 | 33 | @echo "--> Running terraform init"
|
42 | 34 | @terraform init -backend=false
|
43 | 35 |
|
44 | 36 | security:
|
45 | 37 | @echo "--> Running Security checks"
|
46 |
| - @trivy config . |
47 |
| - $(MAKE) security-examples |
48 |
| - |
49 |
| -security-examples: |
50 |
| - @echo "--> Running Security checks on examples" |
51 |
| - @find examples -type d -mindepth 1 -maxdepth 1 | while read -r dir; do \ |
52 |
| - echo "--> Validating $$dir"; \ |
53 |
| - trivy config $$dir; \ |
54 |
| - done |
55 |
| - |
56 |
| -validate-all: |
57 |
| - @echo "--> Running all validation checks" |
58 |
| - $(MAKE) validate |
59 |
| - $(MAKE) validate-examples |
60 |
| - |
61 |
| -validate: |
62 |
| - @echo "--> Running terraform validate" |
63 |
| - @terraform init -backend=false |
64 |
| - @terraform validate |
65 |
| - $(MAKE) validate-examples |
| 38 | + trivy config --format table --exit-code 1 --severity CRITICAL,HIGH --ignorefile .trivyignore . |
66 | 39 |
|
67 |
| -validate-examples: |
68 |
| - @echo "--> Running terraform validate on examples" |
69 |
| - @find examples -type d -mindepth 1 -maxdepth 1 | while read -r dir; do \ |
70 |
| - echo "--> Validating $$dir"; \ |
71 |
| - terraform -chdir=$$dir init; \ |
72 |
| - terraform -chdir=$$dir validate; \ |
73 |
| - done |
| 40 | +commitlint: |
| 41 | + @echo "--> Running commitlint against the main branch" |
| 42 | + @command -v commitlint >/dev/null 2>&1 || { echo "commitlint is not installed. Please install it by running 'npm install -g commitlint'"; exit 1; } |
| 43 | + @git log --pretty=format:"%s" origin/main..HEAD | commitlint --from=origin/main |
74 | 44 |
|
75 | 45 | lint:
|
76 | 46 | @echo "--> Running tflint"
|
77 | 47 | @tflint --init
|
78 | 48 | @tflint -f compact
|
79 |
| - $(MAKE) lint-examples |
80 |
| - |
81 |
| -lint-examples: |
82 |
| - @echo "--> Running tflint on examples" |
83 |
| - @find examples -type d -mindepth 1 -maxdepth 1 | while read -r dir; do \ |
84 |
| - echo "--> Linting $$dir"; \ |
85 |
| - tflint --chdir=$$dir --init; \ |
86 |
| - tflint --chdir=$$dir -f compact; \ |
87 |
| - done |
88 | 49 |
|
89 | 50 | format:
|
90 | 51 | @echo "--> Running terraform fmt"
|
91 | 52 | @terraform fmt -recursive -write=true
|
92 | 53 |
|
| 54 | +validate: |
| 55 | + @echo "--> Running terraform validate" |
| 56 | + @terraform init -backend=false |
| 57 | + @terraform validate |
| 58 | + $(MAKE) lint |
| 59 | + $(MAKE) commitlint |
| 60 | + $(MAKE) format |
| 61 | + $(MAKE) security |
| 62 | + |
93 | 63 | clean:
|
94 | 64 | @echo "--> Cleaning up"
|
95 | 65 | @find . -type d -name ".terraform" | while read -r dir; do \
|
|
0 commit comments