5
5
branches :
6
6
- master
7
7
jobs :
8
+ changedfiles :
9
+ runs-on : ubuntu-20.04
10
+ outputs :
11
+ all : ${{ steps.changes.outputs.all}}
12
+ c : ${{ steps.changes.outputs.c }}
13
+ steps :
14
+ - name : checkout tree-sitter-scala
15
+ uses : actions/checkout@v3
16
+ with :
17
+ fetch-depth : 10
18
+
19
+ - name : Get changed files
20
+ id : changes
21
+ run : |
22
+ echo "all=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | xargs)" >> $GITHUB_OUTPUT
23
+ echo "c=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '.\(c\|h\)$' | xargs)" >> $GITHUB_OUTPUT
24
+
8
25
test :
9
26
runs-on : ${{ matrix.os }}
27
+ needs : changedfiles
10
28
strategy :
11
29
fail-fast : true
12
30
matrix :
13
- os : [macos-latest, ubuntu-20.04, windows-2019]
31
+ os : [ubuntu-20.04, macos-latest , windows-2019]
14
32
env :
15
33
SCALA_SCALA_DIR : /home/runner/work/tree-sitter-scala/tree-sitter-scala/scala_scala
16
34
DOTTY_DIR : /home/runner/work/tree-sitter-scala/tree-sitter-scala/dotty
17
35
steps :
18
36
- name : checkout tree-sitter-scala
19
37
uses : actions/checkout@v3
38
+ with :
39
+ fetch-depth : 10
20
40
21
41
- name : checkout scala/scala
42
+ if : ${{ runner.os == 'Linux' }}
22
43
uses : actions/checkout@v3
23
44
with :
24
45
repository : scala/scala
25
46
ref : v2.13.10
26
47
path : scala_scala
27
48
28
49
- name : checkout lampepfl/dotty
50
+ if : ${{ runner.os == 'Linux' }}
29
51
uses : actions/checkout@v3
30
52
with :
31
53
repository : lampepfl/dotty
@@ -39,15 +61,26 @@ jobs:
39
61
- name : Test C stack code
40
62
run : gcc test/test-stack.c -o a.out && ./a.out
41
63
42
- - name : Generate and check parser
64
+ - name : Generate parser
43
65
if : ${{ runner.os == 'Linux' }}
66
+ shell : bash
67
+ run : npm install && npm run build
68
+
69
+ - name : Check parser (Linux)
70
+ if : ${{ runner.os == 'Linux' && needs.changedfiles.outputs.c }}
71
+ shell : bash
44
72
run : |
45
- npm install && npm run build
46
- git diff --quiet || (echo "::error file=grammar.js::Generated parser differs from the checked in version" && exit 1)
73
+ # `git diff --quiet` doesn't seem to work on Github Actions
74
+ changes=$(git diff --name-only --diff-filter=ACMRT | xargs)
75
+ if [ ! "$changes" ]; then
76
+ echo "::error file=grammar.js::Generated parser differs from the checked in version"
77
+ exit 1
78
+ fi
47
79
48
80
- name : Parser tests
81
+ if : ${{ runner.os == 'Linux' || needs.changedfiles.outputs.c }}
49
82
shell : bash
50
- run : npm install && npm run test
83
+ run : npm run test
51
84
52
85
- name : Smoke test
53
86
if : ${{ runner.os == 'Linux' }}
0 commit comments