-
Notifications
You must be signed in to change notification settings - Fork 11
80 lines (75 loc) · 3.05 KB
/
Copy pathci.yml
File metadata and controls
80 lines (75 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: CI
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:
- 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
- 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
with:
version: stable
- run: raco pkg install --batch --auto cover cover-coveralls
- run: raco pkg install --batch --auto --link --name resyntax
- run: raco cover --format coveralls --suppress-log-execution --package resyntax
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}