cgo 0.5.0

A library for build scripts to compile custom Go code
Documentation
name: ci

on:
  pull_request:
    branches: ["main"]

env:
  CROSS_VERSION: "0.2.5"
  GO_VERSION: "1.26.2"
  RUST_VERSION: "1.95.0"

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 1

      - name: Set up Rust
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ env.RUST_VERSION }}
          components: clippy, rustfmt

      - name: Format
        run: cargo fmt --all -- --check
  
      - name: Clippy
        run: cargo clippy -- -D warnings

      - name: Test
        run: cargo test

  build:
    runs-on: ${{ matrix.os }}
    env:
      CARGO: cargo
    strategy:
      matrix:
        include:
          - target: aarch64-apple-darwin
            os: macos-latest
            no_run: --no-run
          - target: x86_64-apple-darwin
            os: macos-latest
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
          - target: x86_64-pc-windows-gnu
            os: windows-latest
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            no_run: --no-run
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 1

      - name: Set up Rust
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ env.RUST_VERSION }}
          target: ${{ matrix.target }}
          components: clippy, rustfmt

      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version: ${{ env.GO_VERSION }}

      - name: Install cross-compilation toolchain (aarch64)
        if: matrix.target == 'aarch64-unknown-linux-gnu'
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
          echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV

      - name: Set up MinGW for Windows
        if: runner.os == 'Windows'
        run: echo "C:\msys64\mingw64\bin" | Out-File -Append -FilePath $env:GITHUB_PATH

      - name: Integration tests
        run: cargo test ${{ matrix.no_run }} --manifest-path cgo-test/Cargo.toml --target ${{ matrix.target }}

      - name: Build
        run: cargo build --target ${{ matrix.target }}