Skip to content

Commit 12e5de2

Browse files
committed
chore: Accept coderabbit suggestion
1 parent f35d066 commit 12e5de2

File tree

1 file changed

+63
-8
lines changed

1 file changed

+63
-8
lines changed

.github/workflows/build-image.yaml

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jobs:
7979
env:
8080
IMAGE_TAGS: ${{ steps.meta.outputs.tags }}
8181
run: |
82+
set -euo pipefail
8283
IMAGE_TAG=$(echo "$IMAGE_TAGS" | head -n1)
8384
echo "Testing tools image: $IMAGE_TAG"
8485
@@ -87,17 +88,71 @@ jobs:
8788
docker run --rm "$IMAGE_TAG" terraform-docs --version
8889
docker run --rm "$IMAGE_TAG" tflint --version
8990
90-
# Functional tests
91-
echo "Testing basic functionality..."
91+
# Optional extra versions (quick smoke)
92+
docker run --rm "$IMAGE_TAG" checkov --version || true
93+
docker run --rm "$IMAGE_TAG" trivy --version || true
94+
95+
# Create a minimal, self-contained Terraform module for functional tests
96+
TMP_DIR="$(mktemp -d)"
97+
trap 'rm -rf "$TMP_DIR"' EXIT
98+
cat > "$TMP_DIR/main.tf" << 'EOF'
99+
terraform {
100+
required_version = ">= 1.3.0"
101+
}
102+
variable "example_var" {
103+
description = "An example variable"
104+
type = string
105+
default = "test"
106+
}
107+
output "example_output" {
108+
description = "An example output"
109+
value = var.example_var
110+
}
111+
EOF
112+
echo "# Test Module" > "$TMP_DIR/README.md"
113+
114+
echo "Testing terraform fmt..."
115+
116+
docker run --rm \
117+
-v "$TMP_DIR:/workspace" \
118+
-w /workspace \
119+
"$IMAGE_TAG" \
120+
terraform fmt -check -diff
121+
122+
echo "Testing terraform init/validate..."
123+
124+
docker run --rm \
125+
-v "$TMP_DIR:/workspace" \
126+
-w /workspace \
127+
"$IMAGE_TAG" \
128+
terraform init -backend=false
129+
92130
docker run --rm \
93-
-v "$(pwd)/tests:/workspace" \
131+
-v "$TMP_DIR:/workspace" \
94132
-w /workspace \
95133
"$IMAGE_TAG" \
96-
terraform init -backend=false \
97-
|| echo "terraform init test passed"
134+
terraform validate
135+
136+
echo "Testing terraform-docs..."
137+
138+
docker run --rm \
139+
-v "$TMP_DIR:/workspace" \
140+
-w /workspace \
141+
"$IMAGE_TAG" \
142+
terraform-docs markdown table . --output-file README.md
143+
144+
echo "Testing tflint..."
145+
146+
docker run --rm \
147+
-v "$TMP_DIR:/workspace" \
148+
-w /workspace \
149+
"$IMAGE_TAG" \
150+
tflint --init
151+
98152
docker run --rm \
99-
-v "$(pwd):/workspace" \
153+
-v "$TMP_DIR:/workspace" \
100154
-w /workspace \
101155
"$IMAGE_TAG" \
102-
terraform fmt -check -diff \
103-
|| echo "terraform fmt test completed"
156+
tflint
157+
158+
echo "All functional tests passed!"

0 commit comments

Comments
 (0)