Skip to content

Commit

Permalink
Merge pull request #580 from bash-lsp/upgrade-tree-sitter-workflow
Browse files Browse the repository at this point in the history
Upgrade tree-sitter GitHub workflow
  • Loading branch information
skovhus authored Nov 28, 2022
2 parents a7eeb09 + 787b3fe commit a190a71
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 11 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/upgrade-tree-sitter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
on:
schedule:
- cron: '0 12 * * 2'

jobs:
upgrade_tree_sitter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Use Node.js 12
uses: actions/setup-node@v3
with:
node-version: 12

- name: Install dependencies
run: yarn install

- name: Upgrade tree-sitter wasm
run: sh scripts/upgrade-tree-sitter.sh

- name: Verify changes
run: yarn verify:bail

- name: Verify file changes
uses: tj-actions/verify-changed-files@v12
id: verify-changed-files
with:
files: |
server/parser.info
server/tree-sitter-bash.wasm
- name: Create pull request
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: peter-evans/create-pull-request@v4
with:
add-paths: server
reviewers: skovhus
title: Auto upgrade tree-sitter-bash parser
14 changes: 14 additions & 0 deletions scripts/upgrade-tree-sitter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -euox pipefail

cd server
yarn add web-tree-sitter
yarn add --dev tree-sitter-cli https://github.com/tree-sitter/tree-sitter-bash
npx tree-sitter build-wasm node_modules/tree-sitter-bash

curl 'https://api.github.com/repos/tree-sitter/tree-sitter-bash/commits/master' | jq .commit.url > parser.info
echo "tree-sitter-cli $(cat package.json | jq '.devDependencies["tree-sitter-cli"]')" >> parser.info

yarn remove tree-sitter-cli tree-sitter-bash

12 changes: 1 addition & 11 deletions server/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,7 @@ export async function initializeParser(): Promise<Parser> {
* See https://github.com/tree-sitter/tree-sitter/tree/master/lib/binding_web#generate-wasm-language-files
*
* To compile and use a new tree-sitter-bash version:
* cd server
* yarn add web-tree-sitter
* yarn add --dev tree-sitter-bash tree-sitter-cli
* npx tree-sitter build-wasm node_modules/tree-sitter-bash
*
* Note down the versions (from the package.json) below and then run
* yarn remove tree-sitter-bash tree-sitter-cli
*
* The current files was compiled with:
* "tree-sitter-bash": "^0.19.0",
* "tree-sitter-cli": "^0.20.0"
* sh scripts/upgrade-tree-sitter.sh
*/
const lang = await Parser.Language.load(`${__dirname}/../tree-sitter-bash.wasm`)

Expand Down

0 comments on commit a190a71

Please sign in to comment.