Skip to content

Instantly share code, notes, and snippets.

@vdemeester
Created November 26, 2025 10:53
Show Gist options
  • Select an option

  • Save vdemeester/0e0c639a827a4b64d7446d947ff9ad40 to your computer and use it in GitHub Desktop.

Select an option

Save vdemeester/0e0c639a827a4b64d7446d947ff9ad40 to your computer and use it in GitHub Desktop.
#!/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!"
@vdemeester
Copy link
Author

Testing detect logic for non-docs and yaml outputs
===================================================

Scenario: Only markdown files
Changed files:
  README.md
  docs/guide.md
  CONTRIBUTING.md

  non-docs: false
  yaml: false

---

Scenario: Only Go files
Changed files:
  main.go
  pkg/handler.go
  cmd/app/main.go

  non-docs: true
  yaml: false

---

Scenario: Only YAML files
Changed files:
  config.yaml
  deployment.yml
  values.yaml

  non-docs: true
  yaml: true

---

Scenario: Mix of markdown and Go files
Changed files:
  README.md
  main.go
  docs/api.md
  pkg/server.go

  non-docs: true
  yaml: false

---

Scenario: Mix of YAML and Go files
Changed files:
  main.go
  config.yaml
  pkg/handler.go
  deployment.yml

  non-docs: true
  yaml: true

---

Scenario: Mix of all types
Changed files:
  README.md
  main.go
  config.yaml
  docs/guide.md
  pkg/handler.go
  deployment.yml

  non-docs: true
  yaml: true

---

Scenario: GitHub workflow YAML files
Changed files:
  .github/workflows/ci.yaml
  .github/workflows/release.yml

  non-docs: true
  yaml: true

---

Scenario: Mix of workflow and config YAML
Changed files:
  .github/workflows/ci.yaml
  config/deployment.yaml
  manifests/service.yml

  non-docs: true
  yaml: true

---

Scenario: Only workflow YAML
Changed files:
  .github/workflows/ci.yaml
  .github/workflows/test.yml

  non-docs: true
  yaml: true

---

Scenario: Empty changes
Changed files:
  

  non-docs: false
  yaml: false

---

Scenario: Single markdown file
Changed files:
  README.md

  non-docs: false
  yaml: false

---

Scenario: Single Go file
Changed files:
  main.go

  non-docs: true
  yaml: false

---

Scenario: YAML variations
Changed files:
  config.yaml
  settings.yml
  data.YAML
  options.YML

  non-docs: true
  yaml: true

---

===================================================
Test completed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment