Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Feature/zig cross compilation workflow #43

Feature/zig cross compilation workflow

Feature/zig cross compilation workflow #43

name: Build and Test on Multiple Platforms
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# macOS x86-64 (Intel)
- os: macos-13
arch: x86_64
name: macOS-x86_64
# macOS arm64 (Apple Silicon)
- os: macos-latest
arch: arm64
name: macOS-arm64
# Linux x86-64
- os: ubuntu-latest
arch: x86_64
name: Linux-x86_64
# Linux ARM64 (Raspberry Pi)
- os: ubuntu-latest
arch: arm64
name: Linux-arm64
# Windows x86-64
- os: windows-latest
arch: x86_64
name: Windows-x86_64
name: Build ${{ matrix.name }}
steps:
- uses: actions/checkout@v4
- name: Set up QEMU (for ARM64 emulation)
if: matrix.arch == 'arm64' && runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Setup cross-compilation for ARM64 (Linux)
if: matrix.arch == 'arm64' && runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Setup MSVC (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Install Make (Windows)
if: runner.os == 'Windows'
run: choco install make
- name: Build (Unix - x86_64)
if: runner.os != 'Windows' && matrix.arch == 'x86_64'
run: |
make clean
make
- name: Build (Linux - ARM64 cross-compile)
if: matrix.arch == 'arm64' && runner.os == 'Linux'
run: |
make clean
make CC=aarch64-linux-gnu-gcc
- name: Build (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
if not exist obj mkdir obj
if not exist build mkdir build
cl.exe /W3 /O2 /Iinclude /c src\csv_reader.c /Foobj\csv_reader.obj
cl.exe /W3 /O2 /Iinclude /c src\evaluator.c /Foobj\evaluator.obj
cl.exe /W3 /O2 /Iinclude /c src\main.c /Foobj\main.obj
cl.exe /W3 /O2 /Iinclude /c src\parser.c /Foobj\parser.obj
cl.exe /W3 /O2 /Iinclude /c src\tokenizer.c /Foobj\tokenizer.obj
cl.exe /W3 /O2 /Iinclude /c src\utils.c /Foobj\utils.obj
link.exe obj\*.obj /OUT:build\cq.exe
- name: Run Tests (Unix)
if: runner.os != 'Windows' && matrix.arch == 'x86_64'
run: make test
- name: Run Tests (Linux ARM64)
if: matrix.arch == 'arm64' && runner.os == 'Linux'
run: |
echo "ARM64 cross-compiled binary - skipping tests (requires ARM64 runner or emulation)"
file build/cq || true
- name: Run Tests (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
echo "Windows tests - skipping for now (test framework needs porting)"
./build/cq.exe -q "SELECT 1 AS test" -p || echo "Basic test completed"
- name: Show Binary Info
shell: bash
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
file build/cq.exe || echo "file command not available"
ls -lh build/cq.exe
else
file build/cq
ls -lh build/cq
if [ "$RUNNER_OS" == "Darwin" ]; then
lipo -info build/cq
fi
fi
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: cq-${{ matrix.name }}
path: |
build/cq
build/cq.exe
if-no-files-found: ignore