-
Notifications
You must be signed in to change notification settings - Fork 4
120 lines (99 loc) · 3.64 KB
/
pre-commit.yaml
File metadata and controls
120 lines (99 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
name: Pre-Commit
on:
merge_group:
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
push:
branches:
- main
schedule:
# Run once a week (see https://crontab.guru)
- cron: "0 0 * * 0"
workflow_dispatch:
# Cancel any in-progress job when a new workflow is triggered
concurrency:
cancel-in-progress: true
group: pre-commit-${{ github.workflow }}-${{ github.ref }}
permissions:
contents: read
env:
GO_VERSION: "1.26.2"
PYTHON_VERSION: "3.14.3"
TFD_VERSION: "v0.22.0"
jobs:
pre-commit:
name: Update pre-commit hooks and run pre-commit
runs-on: ubuntu-latest
steps:
- name: Checkout git repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: '.hooks/requirements.txt'
- name: Install dependencies
run: |
python3 -m pip install -r .hooks/requirements.txt
- name: Install Ansible collections
run: |
ansible-galaxy collection install -r ansible/requirements.yml --force
- name: Build and install collection locally
working-directory: ansible
run: |
ansible-galaxy collection build --force
ansible-galaxy collection install dreadnode-goad-*.tar.gz -p ~/.ansible/collections --force --pre
- name: Set up Terraform
uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85 # v4
with:
terraform_version: "1.9.7"
- name: Set up Terragrunt
run: |
TG_VERSION="v0.69.1"
curl -fsSL -o /tmp/terragrunt \
"https://github.com/gruntwork-io/terragrunt/releases/download/${TG_VERSION}/terragrunt_linux_amd64"
sudo install -m 0755 /tmp/terragrunt /usr/local/bin/terragrunt
terragrunt --version
- name: Set up TFLint
uses: terraform-linters/setup-tflint@b480b8fcdaa6f2c577f8e4fa799e89e756bb7c93 # v6
with:
tflint_version: v0.61.0
- name: Init TFLint
run: tflint --init --config .hooks/linters/.tflint.hcl
- name: Set up terraform-docs
run: |
curl -fsSL -o /tmp/terraform-docs.tar.gz \
"https://github.com/terraform-docs/terraform-docs/releases/download/${TFD_VERSION}/terraform-docs-${TFD_VERSION}-linux-amd64.tar.gz"
tar -xzf /tmp/terraform-docs.tar.gz -C /tmp terraform-docs
sudo install -m 0755 /tmp/terraform-docs /usr/local/bin/terraform-docs
terraform-docs --version
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version: ${{ env.GO_VERSION }}
- name: Install Go tools
run: |
# Install shfmt
go install mvdan.cc/sh/v3/cmd/shfmt@v3.13.1
# Install goimports
go install golang.org/x/tools/cmd/goimports@v0.44.0
# Install gocyclo
go install github.com/fzipp/gocyclo/cmd/gocyclo@v0.6.0
# Install gocritic
go install github.com/go-critic/go-critic/cmd/gocritic@v0.14.3
# Add Go bin directory to PATH
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
- name: Install golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
install-only: true
- name: Run pre-commit
run: |
pre-commit run --show-diff-on-failure --color=always --all-files