Skip to content

Commit fa5b7e9

Browse files
committed
test: Add support for linting layers with dynamic deps
Layers with dynamic dependencies will fail the bulk lint all test unless the appropriate variable(s) are set in the env when the test runs. Add support for that, so a layer file can be linted with a defined env by sourcing a file matching the basename of the layer file. Files to seed the env can be put in test/layer/env/dist/ and must have a .env suffix.
1 parent 6d9a1b6 commit fa5b7e9

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

test/layer/env/dist/.empty

Whitespace-only changes.

test/layer/run-tests.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,11 +578,28 @@ run_test "bulk-lint-all-yaml" '
578578
579579
# 2) lint each file
580580
for f in "${files[@]}"; do
581-
if ig metadata --lint "$f" >/dev/null 2>&1; then
582-
((pass++))
581+
filename=$(basename "$f")
582+
583+
# Look for corresponding env file
584+
env_file="${IGTOP}/test/layer/env/dist/${filename}.env"
585+
586+
# Run lint in a subshell with environment variables loaded
587+
if [[ -f "$env_file" ]]; then
588+
echo "Loading environment from: $env_file"
589+
if ( set -a; . "$env_file" && ig metadata --lint "$f" >/dev/null 2>&1 ); then
590+
((pass++))
591+
else
592+
((fail++))
593+
failed+=("$f")
594+
fi
583595
else
584-
((fail++))
585-
failed+=("$f")
596+
# No env file, run normally
597+
if ig metadata --lint "$f" >/dev/null 2>&1; then
598+
((pass++))
599+
else
600+
((fail++))
601+
failed+=("$f")
602+
fi
586603
fi
587604
done
588605

0 commit comments

Comments
 (0)