From 7f8cbff0798623a545e526e6799a218c9abd0dce Mon Sep 17 00:00:00 2001 From: gbprod Date: Wed, 26 Jun 2024 09:38:07 +0200 Subject: [PATCH] chore: update ci workflow --- .github/workflows/ci.yml | 83 ++++++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8000947..d9d12ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,40 +1,75 @@ name: CI on: - pull_request: - branches: - - '**' push: branches: - - 'main' + - main + paths: + - grammar.js + - src/** + - test/** + - bindings/** + - binding.gyp + pull_request: + paths: + - grammar.js + - src/** + - test/** + - bindings/** + - binding.gyp concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ${{github.workflow}}-${{github.ref}} cancel-in-progress: true jobs: test: - name: Run validation tests - runs-on: ${{ matrix.os }} + name: Test parser + runs-on: ${{matrix.os}} + if: >- + !github.event.repository.is_template && + github.event.head_commit.message != 'Initial commit' strategy: - fail-fast: true + fail-fast: false matrix: - os: [macos-latest, ubuntu-latest, windows-latest] + os: [ubuntu-latest, windows-latest, macos-14] steps: - name: Checkout repository - uses: actions/checkout@v3 - - name: Install Node.js - uses: actions/setup-node@v3 + uses: actions/checkout@v4 + - name: Set up tree-sitter + uses: tree-sitter/setup-action/cli@v1 + - name: Check for scanner changes + id: scanner-check + shell: sh + run: |- + { + test -f src/scanner.c && ! git diff --quiet HEAD^ -- "$_" && + printf 'changed=true\n' || printf 'changed=false\n' + } >> "$GITHUB_OUTPUT" + - name: Fuzz scanner + uses: tree-sitter/fuzz-action@v4 + if: steps.scanner-check.outputs.changed == 'true' + - name: Run tests + uses: tree-sitter/parser-test-action@v2 with: - node-version: '20.10.x' - registry-url: 'https://registry.npmjs.org' - - name: Install dependencies - run: npm ci - - name: Run tree-sitter tests - run: npm test - - name: Ensure generated parser files are up-to-date - # On Windows and Macos, tree-sitter generate results in a diff, not sure why - if: runner.os != 'Windows' && runner.os != 'macOS' - run: | - git status - test -z "$(git status --porcelain)" + test-rust: ${{runner.os == 'Linux'}} + fuzz: + name: Fuzz scanner + runs-on: ubuntu-latest + if: >- + !github.event.repository.is_template && + github.event.head_commit.message != 'Initial commit' + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Check for scanner changes + id: scanner-check + shell: sh + run: |- + { + test -f src/scanner.c && ! git diff --quiet HEAD^ -- "$_" && + printf 'changed=true\n' || printf 'changed=false\n' + } >> "$GITHUB_OUTPUT" + - name: Run fuzzer + uses: tree-sitter/fuzz-action@v4 + if: steps.scanner-check.outputs.changed == 'true'