Created
November 26, 2025 10:53
-
-
Save vdemeester/0e0c639a827a4b64d7446d947ff9ad40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set --noprofile --norc -e -o pipefail | |
| # Test script to validate the detect logic from ci.yaml | |
| echo "Testing detect logic for non-docs and yaml outputs" | |
| echo "===================================================" | |
| echo "" | |
| # Test function | |
| test_scenario() { | |
| local scenario_name="$1" | |
| local changed_files="$2" | |
| echo "Scenario: $scenario_name" | |
| echo "Changed files:" | |
| echo "$changed_files" | sed 's/^/ /' | |
| echo "" | |
| # Test non-docs detection | |
| if [[ -n "${changed_files}" ]]; then | |
| non_docs=$(echo "${changed_files}" | grep -qv '\.md$' && echo 'true') | |
| yaml=$(echo "${changed_files}" | grep -q '\.ya\?ml$' && echo 'true') | |
| else | |
| non_docs="" | |
| yaml="" | |
| fi | |
| echo " non-docs: ${non_docs:-false}" | |
| echo " yaml: ${yaml:-false}" | |
| echo "" | |
| echo "---" | |
| echo "" | |
| } | |
| # Test 1: Only markdown files | |
| test_scenario "Only markdown files" "README.md | |
| docs/guide.md | |
| CONTRIBUTING.md" | |
| # Test 2: Only Go files (non-docs) | |
| test_scenario "Only Go files" "main.go | |
| pkg/handler.go | |
| cmd/app/main.go" | |
| # Test 3: Only YAML files | |
| test_scenario "Only YAML files" "config.yaml | |
| deployment.yml | |
| values.yaml" | |
| # Test 4: Mix of markdown and Go files | |
| test_scenario "Mix of markdown and Go files" "README.md | |
| main.go | |
| docs/api.md | |
| pkg/server.go" | |
| # Test 5: Mix of YAML and Go files | |
| test_scenario "Mix of YAML and Go files" "main.go | |
| config.yaml | |
| pkg/handler.go | |
| deployment.yml" | |
| # Test 6: Mix of markdown, YAML, and Go files | |
| test_scenario "Mix of all types" "README.md | |
| main.go | |
| config.yaml | |
| docs/guide.md | |
| pkg/handler.go | |
| deployment.yml" | |
| # Test 7: GitHub workflow YAML files | |
| test_scenario "GitHub workflow YAML files" ".github/workflows/ci.yaml | |
| .github/workflows/release.yml" | |
| # Test 8: Mix of workflow YAML and other YAML | |
| test_scenario "Mix of workflow and config YAML" ".github/workflows/ci.yaml | |
| config/deployment.yaml | |
| manifests/service.yml" | |
| # Test 9: Only workflow YAML (should yaml=true currently) | |
| test_scenario "Only workflow YAML" ".github/workflows/ci.yaml | |
| .github/workflows/test.yml" | |
| # Test 10: Empty changes | |
| test_scenario "Empty changes" "" | |
| # Test 11: Single markdown file | |
| test_scenario "Single markdown file" "README.md" | |
| # Test 12: Single non-markdown file | |
| test_scenario "Single Go file" "main.go" | |
| # Test 13: YAML with different extensions | |
| test_scenario "YAML variations" "config.yaml | |
| settings.yml | |
| data.YAML | |
| options.YML" | |
| echo "===================================================" | |
| echo "Test completed!" |
Author
vdemeester
commented
Nov 26, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment