name: CI

on:
  push:
    branches: [main]
  pull_request:

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 tests
        uses: tree-sitter/parser-test-action@v2
        with:
          test-rust: ${{runner.os == 'Linux'}}
      - name: Parse examples
        id: examples
        continue-on-error: true
        uses: tree-sitter/parse-action@v4
        with:
          files: examples/*
      - uses: actions/upload-artifact@v4
        if: steps.examples.outputs.failures != ''
        with:
          name: failures-${{matrix.os}}
          path: ${{steps.examples.outputs.failures}}

