Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade tree-sitter-bash GitHub workflow #580

Merged
merged 3 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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