name: CI

on:
  push:
    branches: [ main ]
    paths:
      - 'src/**'
      - 'test/**'
      - '!test/e2e/**'
      - 'pkg/adapters/**'
      - 'pkg/tree-sitter-zx/**'
      - 'pkg/tree-sitter-mdzx/**'
      - 'vendor/**'
      - 'build.zig'
      - 'build.zig.zon'
  pull_request:
    branches: [ main ]
    paths:
      - 'src/**'
      - 'test/**'
      - '!test/e2e/**'
      - 'pkg/adapters/**'
      - 'pkg/tree-sitter-zx/**'
      - 'pkg/tree-sitter-mdzx/**'
      - 'vendor/**'
      - 'build.zig'
      - 'build.zig.zon'

jobs:
  build:
    name: Build (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
    
    steps:
    - name: Checkout code
      uses: actions/checkout@v4
      
    - name: Setup Zig
      uses: mlugg/setup-zig@v2
      with:
        version: 0.15.2
          
    - name: Build project
      run: zig build
      
    - name: Verify executable
      run: |
        ./zig-out/bin/zx --help || echo "Executable built successfully"
      shell: bash

  test:
    name: Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
    
    steps:
    - name: Checkout code
      uses: actions/checkout@v4
      
    - name: Setup Zig
      uses: mlugg/setup-zig@v2
      with:
        version: 0.15.2

    - name: Run tests
      run: zig build test
      env:
        E2E: 1
