Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 53 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,70 @@ on: [push, pull_request]

jobs:

# Changes that only touch the README or the .github directory can't affect the build or test
# results. This job detects that situation so the expensive build and test steps below can be
# skipped. Note that the "Build and Test" job itself always runs to completion (reporting success)
# even when there's nothing to build, because it's a required status check and a skipped required
# check blocks pull requests from merging.
detect-changes:
name: Detect relevant changes
runs-on: ubuntu-latest
outputs:
run: ${{ steps.filter.outputs.run }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Check whether any files outside README / .github changed
id: filter
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
base="${{ github.event.pull_request.base.sha }}"
head="${{ github.event.pull_request.head.sha }}"
else
base="${{ github.event.before }}"
head="${{ github.sha }}"
fi
# If the base commit isn't available (e.g. a brand new branch), build to be safe.
if ! git cat-file -e "$base" 2>/dev/null; then
echo "Base commit unavailable; running the build."
echo "run=true" >> "$GITHUB_OUTPUT"
exit 0
fi
changed="$(git diff --name-only "$base" "$head")"
echo "Changed files:"
echo "$changed"
relevant="$(echo "$changed" | grep -vE '^(README\.md|\.github/)' || true)"
if [ -n "$relevant" ]; then
echo "Relevant changes found; running the build."
echo "run=true" >> "$GITHUB_OUTPUT"
else
echo "Only README / .github changes found; skipping the build."
echo "run=false" >> "$GITHUB_OUTPUT"
fi

build-and-test:
name: Build and Test
runs-on: ubuntu-latest
needs: detect-changes
if: ${{ github.event_name == 'pull_request' || github.actor != 'Copilot' }}
steps:
- uses: actions/checkout@master
- uses: Bogdanp/setup-racket@v1.5
- if: needs.detect-changes.outputs.run == 'true'
uses: actions/checkout@master
- if: needs.detect-changes.outputs.run == 'true'
uses: Bogdanp/setup-racket@v1.5
with:
version: stable
- run: raco pkg install --batch --auto --link --name resyntax
- run: raco test --drdr --package resyntax
- if: needs.detect-changes.outputs.run == 'true'
run: raco pkg install --batch --auto --link --name resyntax
- if: needs.detect-changes.outputs.run == 'true'
run: raco test --drdr --package resyntax

code-coverage:
name: Code Coverage
runs-on: ubuntu-latest
needs: detect-changes
if: needs.detect-changes.outputs.run == 'true'
steps:
- uses: actions/checkout@master
- uses: Bogdanp/setup-racket@v1.5
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/resyntax-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ on:
- reopened
- synchronize
- ready_for_review
# Analyzing changed files requires installing and building the package, so there's no point
# running this for pull requests that only touch the README or the .github directory. Unlike the
# "Build and Test" check, this workflow isn't a required status check, so skipping it entirely is
# safe and won't block merges.
paths-ignore:
- README.md
- .github/**

jobs:
analyze:
Expand Down