Skip to content

Commit

Permalink
ci: rework workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed May 11, 2024
1 parent 2c5c1d2 commit e93de5f
Show file tree
Hide file tree
Showing 8 changed files with 1,901 additions and 312 deletions.
138 changes: 40 additions & 98 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,116 +1,58 @@
name: Build/test
name: CI

on:
push:
branches: [master]
paths:
- grammar.js
- src/**
- test/**
- bindings/**
- binding.gyp
pull_request:
branches:
- master
jobs:
changedfiles:
runs-on: ubuntu-latest
outputs:
all: ${{ steps.changes.outputs.all}}
c: ${{ steps.changes.outputs.c }}
gen: ${{ steps.changes.outputs.gen }}
steps:
- name: checkout tree-sitter-scala
uses: actions/checkout@v4
with:
fetch-depth: 10
paths:
- grammar.js
- src/**
- test/**
- bindings/**
- binding.gyp

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

- name: Get changed files
id: changes
run: |
echo "all=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | xargs)" >> $GITHUB_OUTPUT
echo "c=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '\.\(c\|h\)$' | xargs)" >> $GITHUB_OUTPUT
# Generated C code
echo "gen=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '\.\(c\|h\)$' | grep -v 'src/scanner.c' | xargs)" >> $GITHUB_OUTPUT
jobs:
test:
runs-on: ${{ matrix.os }}
needs: changedfiles
name: Test parser
runs-on: ${{matrix.os}}
strategy:
fail-fast: true
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, windows-latest, macos-14]
steps:
- name: checkout tree-sitter-scala
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 10

- name: checkout scala/scala
if: ${{ runner.os == 'Linux' }}
- name: Set up tree-sitter
uses: tree-sitter/setup-action/cli@v1
- name: Clone scala
uses: actions/checkout@v4
with:
repository: scala/scala
path: examples/scala
ref: v2.13.10
path: scala_scala

- name: checkout lampepfl/dotty
if: ${{ runner.os == 'Linux' }}
- name: Clone scala3
uses: actions/checkout@v4
with:
repository: lampepfl/dotty
repository: scala/scala3
path: examples/scala3
ref: 3.3.0
path: dotty

- name: checkout nvim-treesitter/nvim-treesitter
if: ${{ runner.os == 'Linux' }}
uses: actions/checkout@v4
with:
repository: nvim-treesitter/nvim-treesitter
path: nvim_treesitter

- uses: actions/setup-node@v4
- name: Run tests
uses: tree-sitter/parser-test-action@v2
with:
node-version: 20

- name: Test C stack code
run: gcc test/test-stack.c -o a.out && ./a.out

- name: Generate parser from scratch and test it
if: ${{ runner.os == 'Linux' || needs.changedfiles.outputs.c }}
shell: bash
run: |
npm install
npm run build
npm test
- name: Check fidelity of checked-in C code
if: ${{ runner.os == 'Linux' && needs.changedfiles.outputs.gen }}
shell: bash
run: |
# `git diff --quiet` doesn't seem to work on Github Actions
changes=$(git diff --name-only --diff-filter=ACMRT | xargs)
if [ ! -z "$changes" ]; then
echo "::error file=grammar.js::Generated $changes differs from the checked in version"
git diff --exit-code
exit 1
fi
- name: Smoke test
if: ${{ runner.os == 'Linux' }}
shell: bash
env:
SCALA_SCALA_DIR: scala_scala
DOTTY_DIR: dotty
run: script/smoke_test.sh

- name: copy nvim-treesitter queries
if: ${{ runner.os == 'Linux' }}
shell: bash
run: cp ./nvim_treesitter/queries/scala/*.scm ./queries/

- name: Check if queries are out of sync with nvim-treesitter
if: ${{ runner.os == 'Linux' }}
uses: tj-actions/verify-changed-files@v19
id: verify-changed-files
test-rust: ${{runner.os == 'Linux'}}
- name: Parse examples
id: examples
uses: tree-sitter/parse-action@v4
with:
files: |
queries/scala/*.scm
- name: Test quries if out of sync with nvim-treesitter
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
echo "::warning Queries in ${{ steps.verify-changed-files.outputs.changed_files }} in this repo are out of sync with nvim-treesitter"
git diff queries/scala/
npm run test
files: examples/**/*.scala
invalid-files-list: test/invalid-files.txt
24 changes: 9 additions & 15 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
name: Fuzz parser
name: Fuzz Parser

# Run this workflow on changes to the external scanner
on:
workflow_dispatch:
push:
branches: [master]
paths:
- src/scanner.c
- src/stack.h
- src/scanner.c
pull_request:
paths:
- src/scanner.c
- src/stack.h
- src/scanner.c

jobs:
test:
name: Parser fuzzing
fuzz:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: vigoux/tree-sitter-fuzz-action@v1
with:
language: scala
external-scanner: src/scanner.c
time: 60
- name: Checkout repository
uses: actions/checkout@v4
- name: Run fuzzer
uses: tree-sitter/fuzz-action@v4
23 changes: 23 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish package

on:
push:
tags: ["*"]

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

jobs:
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.CARGO_REGISTRY_TOKEN}}
pypi:
uses: tree-sitter/workflows/.github/workflows/package-pypi.yml@main
secrets:
PYPI_API_TOKEN: ${{secrets.PYPI_API_TOKEN}}
64 changes: 0 additions & 64 deletions .github/workflows/sync.yml

This file was deleted.

4 changes: 0 additions & 4 deletions script/parse-with-scalac

This file was deleted.

85 changes: 0 additions & 85 deletions script/smoke_test.sh

This file was deleted.

Loading

0 comments on commit e93de5f

Please sign in to comment.