Skip to content

Commit 3c2f1b2

Browse files
committed
fix: resolve yq version compatibility in dependency resolver
- Fix get_all_services function to handle different yq output formats - Add fallback logic for yq -r flag and comment filtering - Resolves false positive circular dependency detection in CI - CI was using yq version that includes YAML comments in output - Local uses different yq that outputs clean JSON arrays The debug output revealed that CI yq was outputting: # Database service (no dependencies) - mariadb Which contaminated service parsing. Now filters out comment lines. Fixes test 53: detect_circular_dependencies_should_find_circular_refs
1 parent 37bb464 commit 3c2f1b2

2 files changed

Lines changed: 3 additions & 32 deletions

File tree

scripts/dependency_resolver.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ get_all_services() {
2626
return 1
2727
fi
2828

29-
yq '.services | keys[]' "$SERVICES_CONFIG" | tr -d '"'
29+
# Use -r flag for raw output and filter out any lines starting with # (comments)
30+
yq -r '.services | keys[]' "$SERVICES_CONFIG" 2>/dev/null | grep -v '^#' | tr -d '"' || \
31+
yq '.services | keys[]' "$SERVICES_CONFIG" | grep -v '^#' | tr -d '"'
3032
}
3133

3234
# Function: get_service_dependencies

tests/unit/scripts/dependency_resolver_test.bats

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -160,38 +160,7 @@ teardown() {
160160

161161
@test "detect_circular_dependencies_should_find_circular_refs" {
162162
# Test circular dependency detection
163-
164-
# Debug: Show the services.yaml content for debugging
165-
SERVICES_CONFIG_PATH="$PROJECT_ROOT/config/services.yaml"
166-
echo "DEBUG: Using SERVICES_CONFIG path: $SERVICES_CONFIG_PATH"
167-
echo "DEBUG: PROJECT_ROOT: $PROJECT_ROOT"
168-
echo "DEBUG: Services config content:"
169-
cat "$SERVICES_CONFIG_PATH"
170-
echo ""
171-
172-
# Debug: Show available services
173-
echo "DEBUG: Available services:"
174-
yq '.services | keys' "$SERVICES_CONFIG_PATH"
175-
echo ""
176-
177-
# Debug: Show circular-a dependencies
178-
echo "DEBUG: circular-a dependencies:"
179-
yq '.services."circular-a".depends_on // []' "$SERVICES_CONFIG_PATH"
180-
echo ""
181-
182-
# Debug: Show circular-b dependencies
183-
echo "DEBUG: circular-b dependencies:"
184-
yq '.services."circular-b".depends_on // []' "$SERVICES_CONFIG_PATH"
185-
echo ""
186-
187163
run detect_circular_dependencies
188-
189-
# Debug: Show function output and exit code
190-
echo "DEBUG: detect_circular_dependencies exit code: $status"
191-
echo "DEBUG: detect_circular_dependencies output:"
192-
echo "$output"
193-
echo ""
194-
195164
[ "$status" -eq 1 ] # Should fail with circular dependency
196165
[[ "$output" == *"Circular dependency detected"* ]]
197166
# Should mention at least one of the circular services

0 commit comments

Comments
 (0)