-
Notifications
You must be signed in to change notification settings - Fork 0
195 lines (169 loc) · 6.41 KB
/
Copy pathci.yml
File metadata and controls
195 lines (169 loc) · 6.41 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
---
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
format:
name: Format Check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup OpenTofu
uses: opentofu/setup-opentofu@a1320f892987e89d278cc92dc5adc984fb93aca4 # v2.0.2
with:
tofu_version_file: .opentofu-version
- name: Check formatting
run: tofu fmt -check -recursive
validate:
name: Validate
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
environment:
- modules/libvirt-vm
- modules/talos-cluster
- environments/lab
- environments/production
- environments/talos-lab
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup OpenTofu
uses: opentofu/setup-opentofu@a1320f892987e89d278cc92dc5adc984fb93aca4 # v2.0.2
with:
tofu_version_file: .opentofu-version
- name: Initialize (${{ matrix.environment }})
run: tofu init -backend=false
working-directory: ${{ matrix.environment }}
- name: Validate (${{ matrix.environment }})
run: tofu validate
working-directory: ${{ matrix.environment }}
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
# Pinned: tflint v0.61.0+ panics (nil pointer in sigstore-go's Bundle.TlogEntries,
# inside tflint's plugin signature verification) when installing the pinned
# terraform ruleset plugin from .tflint.hcl. Reproduced locally: v0.59.1 installs
# cleanly, v0.61.0/v0.62.1/v0.63.1 (latest) all crash identically. Likely tied to
# tflint enabling plugin keyless verification by default around this version range.
# Revisit this pin once upstream fixes it; check https://github.com/terraform-linters/tflint/issues
# for the sigstore-go TlogEntries panic before bumping.
- name: Setup TFLint
uses: terraform-linters/setup-tflint@6e1e0642c0289bd619021bf6b34e3c08ed1e005a # v6.3.0
with:
tflint_version: v0.59.1
# GITHUB_TOKEN lifts the unauthenticated GitHub API rate limit so the
# pinned terraform ruleset (.tflint.hcl) downloads reliably.
- name: Initialize TFLint
run: tflint --init
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run TFLint
run: tflint --recursive
security:
name: Security Scan (Trivy)
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Run Trivy IaC misconfiguration scan
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
scan-type: config
scan-ref: .
severity: HIGH,CRITICAL
exit-code: "1"
ignore-unfixed: true
skip-dirs: "**/.terraform"
format: sarif
output: trivy.sarif
- name: Upload Trivy SARIF to GitHub Security
if: always()
uses: github/codeql-action/upload-sarif@84498526a009a99c875e83ef4821a8ba52de7c22 # codeql-bundle-v2.25.5
with:
sarif_file: trivy.sarif
category: trivy-config
secret-scan:
name: Secret Scan (gitleaks)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
# Full working-tree secret scan, server-side. The gitleaks pre-commit
# hook only scans STAGED changes (a no-op in a clean CI checkout), so
# this dedicated job is what actually enforces detection on every push/PR.
# Pinned by immutable image digest (matching the action SHA-pins above and
# the companion repos); the digest is gitleaks v8.30.1, the same version as
# the pre-commit hook. Bump the digest and the version comment together.
- name: Run gitleaks (full working-tree scan)
run: |
docker run --rm -v "${{ github.workspace }}:/repo" \
ghcr.io/gitleaks/gitleaks@sha256:c00b6bd0aeb3071cbcb79009cb16a60dd9e0a7c60e2be9ab65d25e6bc8abbb7f \
dir /repo --redact --no-banner # gitleaks v8.30.1
pre-commit:
name: Pre-commit (hygiene + EditorConfig)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.14"
# terraform_* hooks already run as dedicated jobs above; skip them
# here so this job stays fast and doesn't double-report.
- name: Run hygiene hooks
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
env:
SKIP: terraform_fmt,terraform_validate,terraform_tflint,terraform_trivy
test:
name: Module Tests
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
# Each module's suite mocks its providers (mock_provider), so neither
# libvirtd, talosctl, nor a real cluster is required. talos-cluster
# mocks BOTH libvirt and talos.
module:
- modules/libvirt-vm
- modules/talos-cluster
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup OpenTofu
uses: opentofu/setup-opentofu@a1320f892987e89d278cc92dc5adc984fb93aca4 # v2.0.2
with:
tofu_version_file: .opentofu-version
# tofu init -backend=false downloads the provider schemas the mocks
# derive their shape from.
- name: Initialize (${{ matrix.module }})
run: tofu init -backend=false
working-directory: ${{ matrix.module }}
- name: Run module tests (${{ matrix.module }})
run: tofu test
working-directory: ${{ matrix.module }}