mirror of https://github.com/Wilfred/difftastic/
115 lines
3.3 KiB
YAML
115 lines
3.3 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
paths:
|
|
- grammar.js
|
|
- src/**
|
|
- test/**
|
|
- bindings/**
|
|
- binding.gyp
|
|
pull_request:
|
|
paths:
|
|
- grammar.js
|
|
- src/**
|
|
- test/**
|
|
- bindings/**
|
|
- binding.gyp
|
|
|
|
concurrency:
|
|
group: ${{github.workflow}}-${{github.ref}}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
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: Set up tree-sitter
|
|
uses: tree-sitter/setup-action/cli@v1
|
|
- name: Run parser and binding tests
|
|
uses: tree-sitter/parser-test-action@v2
|
|
with:
|
|
generate: true
|
|
- name: Parse sample files
|
|
uses: tree-sitter/parse-action@v4
|
|
id: parse-files
|
|
with:
|
|
files: examples/**
|
|
- name: Upload failures artifact
|
|
uses: actions/upload-artifact@v4
|
|
if: "!cancelled() && steps.parse-files.outcome == 'failure'"
|
|
with:
|
|
name: failures-${{runner.os}}
|
|
path: ${{steps.parse-files.outputs.failures}}
|
|
fuzz:
|
|
name: Fuzz scanner
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
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: Set up tree-sitter
|
|
uses: tree-sitter/setup-action/cli@v1
|
|
if: steps.scanner-check.outputs.changed == 'true'
|
|
- name: Run parser and binding tests
|
|
uses: tree-sitter/parser-test-action@v2
|
|
with:
|
|
generate: true
|
|
if: steps.scanner-check.outputs.changed == 'true'
|
|
- name: Run the fuzzer
|
|
uses: tree-sitter/fuzz-action@v4
|
|
if: steps.scanner-check.outputs.changed == 'true'
|
|
size:
|
|
name: Check grammar size
|
|
runs-on: ubuntu-latest
|
|
if: github.ref != 'refs/heads/master'
|
|
steps:
|
|
- name: Checkout old version
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: main
|
|
path: old
|
|
- name: Checkout new version
|
|
uses: actions/checkout@v4
|
|
with:
|
|
path: new
|
|
- name: Set up tree-sitter
|
|
uses: tree-sitter/setup-action/cli@v1
|
|
- name: Generate parser.c for old version
|
|
run: tree-sitter generate --no-bindings
|
|
working-directory: old
|
|
- name: Generate parser.c for new version
|
|
run: tree-sitter generate --no-bindings
|
|
working-directory: new
|
|
- name: Check LARGE_STATE_COUNT
|
|
run: |
|
|
old_size=$(cat old/src/parser.c | grep '#define LARGE_STATE_COUNT' | sed 's/#define LARGE_STATE_COUNT //g')
|
|
new_size=$(cat new/src/parser.c | grep '#define LARGE_STATE_COUNT' | sed 's/#define LARGE_STATE_COUNT //g')
|
|
|
|
echo "Checking LARGE_STATE_COUNT"
|
|
echo "Old: $old_size"
|
|
echo "New: $new_size"
|
|
max_size=$(echo "$old_size" "1.2" | awk '{print $1 * $2}' | cut -d "." -f 1)
|
|
|
|
if (( $new_size > $max_size )); then
|
|
echo "LARGE_STATE_COUNT increased by more than 20%"
|
|
exit 1
|
|
fi
|