Skip to content

Commit b23ab8f

Browse files
authored
Merge pull request #15 from RoseSecurity/add-tests
chore: add tests
2 parents 9d4325b + 389066f commit b23ab8f

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/test.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Test Terrafetch
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions: {}
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Harden the runner (Audit all outbound calls)
16+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
17+
with:
18+
egress-policy: audit
19+
20+
- name: Checkout repository
21+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
23+
- name: Setup Terraform
24+
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
25+
26+
- name: Setup Go
27+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
28+
with:
29+
go-version-file: "go.mod"
30+
cache: false
31+
32+
- name: Build and test Terrafetch
33+
run: |
34+
echo "Building Terrafetch..."
35+
make build
36+
37+
echo "Running Terrafetch..."
38+
build/terrafetch > output.txt
39+
40+
# Validate that expected elements are present
41+
echo "Validating output..."
42+
grep -q "Terraform Files:" output.txt || { echo "Missing Terraform Files count"; exit 1; }
43+
grep -q "Resources:" output.txt || { echo "Missing Resources count"; exit 1; }
44+
grep -q "Variables:" output.txt || { echo "Missing Variables count"; exit 1; }
45+
46+
echo "✅ Validation passed: Output contains expected elements"
47+

0 commit comments

Comments
 (0)