Skip to content

Commit

Permalink
Fix tree-sitter-xpath CI build and test
Browse files Browse the repository at this point in the history
- Includes necessary build artifacts in cache for testing to proceed
- Fixes shell compatibility issue with typegen
  • Loading branch information
eyelidlessness committed Oct 12, 2023
1 parent 2b77882 commit 85fffa8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
33 changes: 29 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ run-name: 'ODK Web Forms CI'
on:
workflow_dispatch:
push:
branches:
- main
merge_group:
pull_request:
paths-ignore:
Expand Down Expand Up @@ -79,9 +77,19 @@ jobs:
- uses: 'actions/cache@v3'
id: cache-build
with:
# Note: the tree-sitter-xpath .js and .wasm paths are standard for
# tree-sitter's build output. They also litter a bunch of other files
# in various build phases, several under `src` (which is why the
# grammar's TypeScript source is not there).
path: |
examples/*/dist
packages/*/dist
packages/tree-sitter-xpath/grammar.js
packages/tree-sitter-xpath/src/grammar.json
packages/tree-sitter-xpath/src/parser.c
packages/tree-sitter-xpath/src/tree_sitter/parser.h
packages/tree-sitter-xpath/tree-sitter-xpath.wasm
packages/tree-sitter-xpath/types
key: build-${{ matrix.node-version }}-${{ github.sha }}

- if: steps.cache-install.outputs.cache-hit != 'true' && matrix.node-version != '20.8.0'
Expand All @@ -90,8 +98,7 @@ jobs:
- if: steps.cache-install.outputs.cache-hit != 'true' && matrix.node-version == '20.8.0'
run: 'yarn install --frozen-lockfile && yarn playwright install chromium firefox webkit'

- if: steps.cache-install.outputs.cache-hit == 'true'
run: 'yarn build'
- run: 'yarn build'

lint:
needs: ['install-and-build', 'changes']
Expand Down Expand Up @@ -125,6 +132,12 @@ jobs:
path: |
examples/*/dist
packages/*/dist
packages/tree-sitter-xpath/grammar.js
packages/tree-sitter-xpath/src/grammar.json
packages/tree-sitter-xpath/src/parser.c
packages/tree-sitter-xpath/src/tree_sitter/parser.h
packages/tree-sitter-xpath/tree-sitter-xpath.wasm
packages/tree-sitter-xpath/types
key: build-${{ matrix.node-version }}-${{ github.sha }}
fail-on-cache-miss: true

Expand Down Expand Up @@ -163,6 +176,12 @@ jobs:
path: |
examples/*/dist
packages/*/dist
packages/tree-sitter-xpath/grammar.js
packages/tree-sitter-xpath/src/grammar.json
packages/tree-sitter-xpath/src/parser.c
packages/tree-sitter-xpath/src/tree_sitter/parser.h
packages/tree-sitter-xpath/tree-sitter-xpath.wasm
packages/tree-sitter-xpath/types
key: build-${{ matrix.node-version }}-${{ github.sha }}
fail-on-cache-miss: true

Expand Down Expand Up @@ -201,6 +220,12 @@ jobs:
path: |
examples/*/dist
packages/*/dist
packages/tree-sitter-xpath/grammar.js
packages/tree-sitter-xpath/src/grammar.json
packages/tree-sitter-xpath/src/parser.c
packages/tree-sitter-xpath/src/tree_sitter/parser.h
packages/tree-sitter-xpath/tree-sitter-xpath.wasm
packages/tree-sitter-xpath/types
key: build-${{ matrix.node-version }}-${{ github.sha }}
fail-on-cache-miss: true

Expand Down
3 changes: 2 additions & 1 deletion packages/tree-sitter-xpath/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@
"resolutions": {
"**/tree-sitter": "^0.20.5",
"@asgerf/dts-tree-sitter/tree-sitter": "^0.20.5"
}
},
"main": "bindings/node"
}
5 changes: 3 additions & 2 deletions packages/tree-sitter-xpath/scripts/build/parser-types
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env sh

mkdir -p ./types
node ../../node_modules/@asgerf/dts-tree-sitter . > ./types/tree-sitter-xpath-parser.d.ts

echo -e "declare module 'tree-sitter-xpath/parser' {\n$(cat ./types/tree-sitter-xpath-parser.d.ts)\n}" > ./types/tree-sitter-xpath-parser.d.ts
echo "declare module 'tree-sitter-xpath/parser' {" > ./types/tree-sitter-xpath-parser.d.ts
node ../../node_modules/@asgerf/dts-tree-sitter . >> ./types/tree-sitter-xpath-parser.d.ts
echo "}" >> ./types/tree-sitter-xpath-parser.d.ts

0 comments on commit 85fffa8

Please sign in to comment.