Skip to content

Commit 78f1739

Browse files
committed
CI stuff for syntax
1 parent 9663f3a commit 78f1739

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

.github/workflows/ci.yml

+35-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Checkout
3232
uses: actions/checkout@v3
3333
with:
34-
submodules: true
34+
fetch-depth: 2 # to be able to check for changes in subfolder res_syntax later
3535

3636
- name: Use OCaml ${{matrix.ocaml_compiler}}
3737
uses: ocaml/setup-ocaml@v2
@@ -40,10 +40,35 @@ jobs:
4040
opam-pin: false
4141
opam-depext: false
4242

43-
- name: Use Node.js
44-
uses: actions/setup-node@v3
45-
with:
46-
node-version: 16
43+
- name: "Check if syntax subfolder has changed"
44+
id: syntax-diff
45+
shell: bash
46+
run: |
47+
if git diff --name-only --exit-code HEAD^ HEAD -- res_syntax; then
48+
echo "syntax_status=unchanged" >> $GITHUB_ENV
49+
else
50+
echo "syntax_status=changed" >> $GITHUB_ENV
51+
fi
52+
53+
- name: "Syntax: install OPAM dependencies"
54+
if: env.syntax_status == 'changed'
55+
run: opam install . --deps-only
56+
working-directory: res_syntax
57+
58+
- name: "Syntax: build CLI"
59+
if: env.syntax_status == 'changed'
60+
run: opam exec -- dune build
61+
working-directory: res_syntax
62+
63+
- name: "Syntax: Run roundtrip tests"
64+
if: ${{ env.syntax_status == 'changed' && runner.os != 'Windows' }}
65+
run: opam exec -- make roundtrip-test
66+
working-directory: res_syntax
67+
68+
- name: "Syntax: Run tests (Windows)"
69+
if: ${{ env.syntax_status == 'changed' && runner.os == 'Windows' }}
70+
run: opam exec -- make test
71+
working-directory: res_syntax
4772

4873
# Required for ninja build
4974
- name: "Windows: Use MSVC"
@@ -55,6 +80,11 @@ jobs:
5580
- name: Build ninja
5681
run: node scripts/buildNinjaBinary.js
5782

83+
- name: Use Node.js
84+
uses: actions/setup-node@v3
85+
with:
86+
node-version: 16
87+
5888
- name: NPM install
5989
run: opam exec -- npm ci
6090
env:

.prettierignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ jscomp/
22
lib/
33
vendor/
44
ninja/
5-
syntax/
5+
res_syntax/
66
_opam
77
CHANGELOG.md
88
README.md

dune

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
(dirs jscomp)
1+
(dirs jscomp res_syntax)

scripts/ninja.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1454,16 +1454,16 @@ function setSortedToStringAsNativeDeps(xs) {
14541454
*/
14551455
function preprocessorNinjaSync() {
14561456
var napkinFiles = fs
1457-
.readdirSync(path.join(jscompDir, "..", "syntax", "src"), "ascii")
1457+
.readdirSync(path.join(jscompDir, "..", "res_syntax", "src"), "ascii")
14581458
.filter(x => x.endsWith(".ml") || x.endsWith(".mli"));
14591459
var napkinCliFiles = fs
1460-
.readdirSync(path.join(jscompDir, "..", "syntax", "cli"), "ascii")
1460+
.readdirSync(path.join(jscompDir, "..", "res_syntax", "cli"), "ascii")
14611461
.filter(x => x.endsWith(".ml") || x.endsWith(".mli"));
14621462
var buildNapkinFiles = napkinFiles
1463-
.map(file => `o napkin/${file} : copy ../syntax/src/${file}`)
1463+
.map(file => `o napkin/${file} : copy ../res_syntax/src/${file}`)
14641464
.join("\n");
14651465
var buildNapkinCliFiles = napkinCliFiles
1466-
.map(file => `o napkin/${file} : copy ../syntax/cli/${file}`)
1466+
.map(file => `o napkin/${file} : copy ../res_syntax/cli/${file}`)
14671467
.join("\n");
14681468
var cppoNative = `
14691469
ocamlopt = ocamlopt.opt
@@ -1569,7 +1569,7 @@ rule copy
15691569
description = $in -> $out
15701570
${buildNapkinFiles}
15711571
${buildNapkinCliFiles}
1572-
o napkin/CHANGELOG.md : copy ../syntax/CHANGELOG.md
1572+
o napkin/CHANGELOG.md : copy ../res_syntax/CHANGELOG.md
15731573
`;
15741574
var cppoNinjaFile = "cppoVendor.ninja";
15751575
writeFileSync(path.join(jscompDir, cppoNinjaFile), cppoNative);

0 commit comments

Comments
 (0)