name: c
on:
  push:
    branches:
      - main
    tags:
      - v*
  pull_request:
  workflow_dispatch:

permissions:
  contents: read

jobs:
  build_test:
    name: build (rust ${{ matrix.rust_toolchain.label }}, ${{ matrix.build.runner }})
    runs-on: ${{ matrix.build.runner }}

    strategy:
      matrix:
        rust_toolchain:
          - version: 1.95.0
            label: latest

        build:
          - triple: x86_64-unknown-linux-gnu
            runner: linux-x86_64-16cpu
          - triple: aarch64-unknown-linux-gnu
            runner: linux-arm64-16cpu
          - triple: x86_64-pc-windows-gnu
            runner: windows-8vcpu
          # macos uses clang, not working yet
          # - triple: aarch64-apple-darwin
          #        runner: macos-26

    defaults:
      run:
        working-directory: ts_ffi

    steps:
      - name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3

      - name: Setup rust
        id: setup-rust
        uses: ./.github/actions/setup-rust
        with:
          toolchain-version: ${{ matrix.rust_toolchain.version }}
          builder-triple: ${{ matrix.build.triple }}

      - name: Build examples
        run: make -C examples
