Skip to content

Testing

Testing #4

Workflow file for this run

name: PR Checks
# ─────────────────────────────────────────────────────────────
# TASK CREATOR CHECKLIST:
# 1. Copy this file into your task repo at the same path.
# 2. No changes needed — all task logic is in run_tests.sh.
# ─────────────────────────────────────────────────────────────
on:
pull_request_target:
branches: [main]
types: [opened, synchronize, reopened]
permissions:
contents: read
jobs:
run-tests:
name: Run Tests
runs-on: ubuntu-latest
outputs:
passed: ${{ steps.tests.outputs.passed }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Run test suite
id: tests
run: |
chmod +x tests/run_tests.sh
if bash tests/run_tests.sh; then
echo "passed=true" >> "$GITHUB_OUTPUT"
else
echo "passed=false" >> "$GITHUB_OUTPUT"
exit 1
fi
check-readonly:
name: Read-Only Files
runs-on: ubuntu-latest
outputs:
passed: ${{ steps.check.outputs.passed }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Check for read-only violations
id: check
run: |
git fetch origin main --depth=1
VIOLATIONS=""
while IFS= read -r entry; do
# Strip Windows-style CR if the file has CRLF line endings
entry="${entry%$'\r'}"
[[ -z "$entry" || "$entry" == \#* ]] && continue
if ! git diff --quiet origin/main \
"${{ github.event.pull_request.head.sha }}" \
-- "$entry" 2>/dev/null; then
VIOLATIONS="$VIOLATIONS\n - $entry"
fi
done < .readonly-files
if [[ -n "$VIOLATIONS" ]]; then
printf '%b\n' "$VIOLATIONS"
echo "passed=false" >> "$GITHUB_OUTPUT"
exit 1
fi
echo "passed=true" >> "$GITHUB_OUTPUT"
save-meta:
name: Save PR Metadata
runs-on: ubuntu-latest
steps:
- name: Write metadata artifact
run: |
mkdir pr-meta
echo "${{ github.event.number }}" > pr-meta/pr-number.txt
echo "${{ github.event.pull_request.user.login }}" > pr-meta/pr-author.txt
echo "${{ github.event.pull_request.head.sha }}" > pr-meta/head-sha.txt
echo "${{ github.event.pull_request.commits }}" > pr-meta/commit-count.txt
- uses: actions/upload-artifact@v4
with:
name: pr-meta
path: pr-meta/
retention-days: 1