Skip to content

Commit

Permalink
ci: use upstream workflows where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
ObserverOfTime committed Jul 29, 2024
1 parent 6436e74 commit b34b709
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 106 deletions.
86 changes: 61 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,70 @@ name: Build

on:
push:
branches:
- main
branches: [main]
paths:
- grammar.js
- src/**
- test/**
- bindings/**
- binding.gyp
pull_request:
workflow_dispatch:
paths:
- grammar.js
- src/**
- test/**
- bindings/**
- binding.gyp

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
test:
name: Test parser
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-14]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: npm ci
- name: Set up PATH
uses: actions/github-script@v7
with:
script: core.addPath(process.cwd() + '/node_modules/.bin')
- name: Run parser and binding tests
uses: tree-sitter/parser-test-action@v2
with:
test-rust: true
generate: ${{ runner.os == 'Linux' }}
- name: Output generated file size
if: runner.os == 'Linux'
run: du -sh src/*.json src/parser.c | sort -rh
- name: Parse sample files
uses: tree-sitter/parse-action@v4
with:
files: examples/Logger.kt
fuzz:
name: Fuzz scanner
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
- name: Checkout repository
uses: actions/checkout@v4
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Generate parser
run: npm run generate
- name: Verify that generated parser matches the repository
run: |
diff=`git diff HEAD -- src`
echo "$diff"
test -z "$diff"
- name: Output parser size
run: du -sh src/* | sort -h
- name: Run tests
run: npm test
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Build and test crate
run: cargo test
fetch-depth: 2
- name: Check for scanner changes
id: scanner-check
run: |-
if git diff --quiet HEAD^ -- src/scanner.c; then
printf 'changed=false\n' >> "$GITHUB_OUTPUT"
else
printf 'changed=true\n' >> "$GITHUB_OUTPUT"
fi
- name: Run the fuzzer
uses: tree-sitter/fuzz-action@v4
if: steps.scanner-check.outputs.changed == 'true'
23 changes: 0 additions & 23 deletions .github/workflows/deploy-to-crates-io.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/deploy-to-npm.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
name: Deploy to GitHub
name: Deploy Releases

on:
push:
tags:
- '*'
tags: ["*"]

jobs:
deploy:
npm:
uses: tree-sitter/workflows/.github/workflows/package-npm.yml@main
secrets:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
crates:
uses: tree-sitter/workflows/.github/workflows/package-crates.yml@main
secrets:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
github:
runs-on: ubuntu-latest
env:
EMSCRIPTEN_VERSION: '3.1.55'
EMSCRIPTEN_VERSION: "3.1.55"
steps:
- uses: actions/checkout@v4
- name: Clone main branch
uses: actions/checkout@v4
- name: Clone gh-pages branch into nested directory
uses: actions/checkout@v4
with:
Expand All @@ -20,49 +29,37 @@ jobs:
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Get tag name
id: tag
run: |
tag=$(basename "${{ github.ref }}")
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install Emscripten
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{ env.EMSCRIPTEN_VERSION }}
- name: Install dependencies
run: npm install
run: npm ci
- name: Compile grammar
run: npm run generate
run: npm x -- tree-sitter generate --no-bindings
- name: Build Wasm binary
run: npm run build-wasm
run: npm x -- tree-sitter build --wasm
- name: Deploy to GitHub Releases
run: |
tag="${{ steps.tag.outputs.tag }}"
gh release create "$tag" --title "$tag"
gh release upload "$tag" tree-sitter-kotlin.wasm
run: gh release create "$GITHUB_REF_NAME" tree-sitter-kotlin.wasm
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
- name: Deploy to GitHub Pages
run: |
sha="$(git rev-parse --short HEAD)"
tag="${{ steps.tag.outputs.tag }}"
tag="$GITHUB_REF_NAME"
echo "==> Replacing Wasm binary..."
echo '==> Replacing Wasm binary...'
rm -rf gh-pages/assets/tree-sitter-kotlin*
mkdir -p "gh-pages/assets/tree-sitter-kotlin-$tag"
cp tree-sitter-kotlin.wasm "gh-pages/assets/tree-sitter-kotlin-$tag"
tree gh-pages/assets
echo "==> Updating version on website..."
echo '==> Updating version on website...'
sed -i "s|\(LANGUAGE_BASE_URL = \"\)[^\"]*\(\"\)|\1assets/tree-sitter-kotlin-$tag\2|g" gh-pages/index.html
sed -i "s|\(<span class=\"version\">\)[^<]*\(</span>\)|\1$tag\2|g" gh-pages/index.html
echo "==> Committing and pushing gh-pages branch..."
echo '==> Committing and pushing gh-pages branch...'
cd gh-pages
git add .
git commit -m "Deploy tree-sitter-kotlin $tag ($sha)"
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/regenerate-parser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v4
- name: Configure Git user
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Generate parser
run: npm run generate
run: npm ci
- name: Compile grammar
run: npm x -- tree-sitter generate --no-bindings
- name: Commit the updated parser
run: |
git add src
Expand Down

0 comments on commit b34b709

Please sign in to comment.