-
-
Notifications
You must be signed in to change notification settings - Fork 93
/
pr.ci.yml
68 lines (56 loc) · 2.77 KB
/
pr.ci.yml
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
# This workflow will do a clean install of the dependencies and run tests across different versions
#
# Replace <track> with the track name
# Replace <image-name> with an image to run the jobs on
# Replace <action to setup tooling> with a github action to setup tooling on the image
# Replace <install dependencies> with a cli command to install the dependencies
# Replace <code-extensions> with file extensions that should trigger the workflow
#
# Requires scripts:
# - scripts/pr-check path/to/changed/file path/to/changed/file
# - scripts/pr path/to/changed/file path/to/changed/file
name: <track> / pr
on: pull_request
jobs:
precheck:
runs-on: <image-name>
steps:
- name: Checkout PR
uses: actions/checkout@v2
- name: Use Node.js LTS (12.x)
uses: <action to setup tooling>
with:
# Here, use the LTS/stable version of the track's tooling, e.g.:
# node-version: 12.x
- name: Install project dependencies
run: <install dependencies>
# Replace <code-extensions> with file extensions that should trigger this check. Replace with .* to allow anything.
- name: Run exercism/<track> ci pre-check (stub files, config integrity) for changed exercises
run: |
PULL_REQUEST_URL=$(jq -r ".pull_request.url" "$GITHUB_EVENT_PATH")
curl --url $"${PULL_REQUEST_URL}/files" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | \
jq -c '.[] | select(.status == "added" or .status == "modified") | select(.filename | match("\\.(<code-extensions>|md|json)$")) | .filename' | \
xargs -r scripts/pr-check
ci:
runs-on: <image-name>
strategy:
matrix:
# Here, add all SUPPORTED versions only, e.g.:
# version: [10.x, 12.x, 14.x]
# Optionally, add more matrix variables, such as os or arch
steps:
- uses: actions/checkout@v2
- name: Use <setup tooling> ${{ matrix.version }}
uses: <action to setup tooling>
with:
# Use the ${{ matrix.x }} format to inject variables into commands
# node-version: ${{ matrix.version }}
- name: Install project dependencies
run: <install dependencies>
# Replace <code-extensions> with file extensions that should trigger running tests. Replace with .* to allow anything.
- name: Run exercism/<track> ci (runs tests) for changed/added exercises
run: |
PULL_REQUEST_URL=$(jq -r ".pull_request.url" "$GITHUB_EVENT_PATH")
curl --url $"${PULL_REQUEST_URL}/files" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | \
jq -c '.[] | select(.status == "added" or .status == "modified") | select(.filename | match("\\.(<code-extensions>|md|json)$")) | .filename' | \
xargs -r scripts/pr