Skip to content

Updates from 2026-07-10 #185

Updates from 2026-07-10

Updates from 2026-07-10 #185

name: Source line linting
on: # yamllint disable-line rule:truthy
pull_request:
paths:
- 'anti-spam/**/*.yml'
- 'anti-spam/**/*.yaml'
- 'general/**/*.yml'
- 'general/**/*.yaml'
- 'subreddit_specific/**/*.yml'
- 'subreddit_specific/**/*.yaml'
jobs:
check-yaml-srcaaaa:
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v6
with:
fetch-depth: 0 # Required to fetch base branch properly
- name: Fail if .yml files exist in monitored paths
run: |
bad_files=$(find anti-spam general subreddit_specific -type f -name "*.yml")
if [ -n "$bad_files" ]; then
echo "❌ The following .yml files exist in monitored paths (must be .yaml instead):"
echo "$bad_files"
exit 1
else
echo "✅ No .yml files found in monitored paths."
fi
- name: Fetch base branch
run: git fetch origin ${{ github.base_ref }}
- name: Find changed YAML files
id: changed_files
run: |
files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E '^(anti-spam|general|subreddit_specific)/.*\.ya?ml$' || true)
echo "files<<EOF" >> "$GITHUB_OUTPUT"
echo "$files" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Src github link validation (line 3)
run: |
failed=0
while IFS= read -r file; do
if [ -z "$file" ]; then
continue
fi
if [ ! -f "$file" ]; then
echo "⚠️ Skipping missing file: $file"
continue
fi
line3=$(sed -n '3p' "$file")
if [[ ! "$line3" =~ ^#\ src:\ https://raw.githubusercontent.com/KanchiMoe/Reddit-AutoModerator-rules/master/.*$ ]]; then
echo "❌ $file: Invalid or missing 'src' comment on line 3"
failed=1
else
echo "✅ $file: Valid 'src' link"
fi
done <<< "${{ steps.changed_files.outputs.files }}"
if [ $failed -ne 0 ]; then
echo "❗ One or more YAML files failed validation."
exit 1
fi
- name: Src line matches actual path (line 3)
run: |
failed=0
repo_url_prefix="https://raw.githubusercontent.com/KanchiMoe/Reddit-AutoModerator-rules/master/"
while IFS= read -r file; do
if [ -z "$file" ]; then
continue
fi
if [ ! -f "$file" ]; then
echo "⚠️ Skipping missing file: $file"
continue
fi
line3=$(sed -n '3p' "$file")
expected_src="# src: ${repo_url_prefix}${file}"
if [[ "$line3" != "$expected_src" ]]; then
echo "❌ $file: Expected line 3 to be:"
echo " $expected_src"
echo " But found:"
echo " $line3"
failed=1
else
echo "✅ $file: Path matches src line"
fi
done <<< "${{ steps.changed_files.outputs.files }}"
if [ $failed -ne 0 ]; then
echo "❗ One or more YAML files failed src validation."
exit 1
fi