-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (74 loc) · 2.44 KB
/
validate-examples.yml
File metadata and controls
93 lines (74 loc) · 2.44 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
# © 2026 NetApp, Inc. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
# See the NOTICE file in the repo root for trademark and attribution details.
name: Validate Examples
on:
push:
branches: [main]
paths:
- "ansible/**"
- "terraform/**"
pull_request:
branches: [main]
paths:
- "ansible/**"
- "terraform/**"
permissions:
contents: read
jobs:
ansible-lint:
name: Ansible — syntax & lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install Ansible toolchain
run: pip install ansible ansible-lint
- name: Install NetApp ONTAP collection
run: ansible-galaxy collection install -r ansible/requirements.yml
- name: Syntax check playbooks
run: |
for f in ansible/*.yml; do
[ "$(basename "$f")" = "requirements.yml" ] && continue
echo "Checking $f …"
ansible-playbook --syntax-check "$f" -i ansible/inventory/hosts.yml
done
- name: Run ansible-lint
run: ansible-lint ansible/*.yml --exclude ansible/requirements.yml
terraform-validate:
name: Terraform — fmt, validate & lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: hashicorp/setup-terraform@v4
with:
terraform_version: "1.7"
- name: Install tflint
run: |
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
- name: Validate Terraform modules
run: |
ERRORS=0
for dir in terraform/*/; do
echo "=== $(basename "$dir") ==="
echo " fmt check …"
if ! terraform -chdir="$dir" fmt -check; then
echo " FAIL: terraform fmt"
ERRORS=$((ERRORS + 1))
fi
echo " init …"
terraform -chdir="$dir" init -backend=false -input=false > /dev/null 2>&1 || true
echo " validate …"
if ! terraform -chdir="$dir" validate; then
echo " FAIL: terraform validate"
ERRORS=$((ERRORS + 1))
fi
echo " tflint …"
if ! tflint --chdir="$dir" --no-color; then
echo " WARN: tflint reported issues"
fi
echo ""
done
[ "$ERRORS" -eq 0 ] || exit 1