Skip to content

feat: Support buffers as an input in server mode #980

feat: Support buffers as an input in server mode

feat: Support buffers as an input in server mode #980

Workflow file for this run

name: Build
on:
pull_request:
push:
branches:
- main
tags:
- "v*.*.*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v2
with:
version: 0.15.2
- name: Install nasm
run: |
sudo apt-get update
sudo apt-get install -y nasm
- name: Cross-compile for all targets
run: |
zig build -Doptimize=ReleaseFast ci --verbose
- name: Prepare binaries as artifacts
run: |
mkdir binaries
cp zig-out/x86_64-linux/odiff binaries/odiff-linux-x64
cp zig-out/aarch64-linux/odiff binaries/odiff-linux-arm64
cp zig-out/riscv64-linux/odiff binaries/odiff-linux-riscv64
cp zig-out/riscv64-linux-rva23/odiff binaries/odiff-linux-riscv64-rva23
cp zig-out/x86_64-windows/odiff.exe binaries/odiff-windows-x64.exe
cp zig-out/aarch64-windows/odiff.exe binaries/odiff-windows-arm64.exe
cp zig-out/x86_64-macos/odiff binaries/odiff-macos-x64
cp zig-out/aarch64-macos/odiff binaries/odiff-macos-arm64
- name: Upload x86_64-linux artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-linux-x64
path: binaries/odiff-linux-x64
retention-days: 14
- name: Upload aarch64-linux artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-linux-arm64
path: binaries/odiff-linux-arm64
retention-days: 14
- name: Upload riscv64-linux artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-linux-riscv64
path: binaries/odiff-linux-riscv64
retention-days: 14
- name: Upload riscv64-linux rva23 artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-linux-riscv64-rva23
path: binaries/odiff-linux-riscv64-rva23
retention-days: 14
- name: Upload x86_64-windows artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-windows-x64.exe
path: binaries/odiff-windows-x64.exe
retention-days: 14
- name: Upload aarch64-windows artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-windows-arm64.exe
path: binaries/odiff-windows-arm64.exe
retention-days: 14
- name: Upload x86_64-macos artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-macos-x64
path: binaries/odiff-macos-x64
retention-days: 14
- name: Upload aarch64-macos artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-macos-arm64
path: binaries/odiff-macos-arm64
retention-days: 14
test:
name: Run Tests (all targets)
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-linux-gnu
os: ubuntu-latest
run_tests: true
- target: x86_64-windows-gnu
os: windows-latest
run_tests: true
- target: aarch64-macos
os: macos-latest
run_tests: true
- target: riscv64-linux-gnu
os: ubuntu-latest
run_tests: false
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v2
with:
version: 0.15.2
- name: Install nasm for x86 targets (Linux)
if: contains(matrix.target, 'x86_64') && runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y nasm
- name: Install nasm for x86 targets (macOS)
if: contains(matrix.target, 'x86_64') && runner.os == 'macOS'
run: |
brew install nasm
- name: Install nasm for x86 targets (Windows)
if: contains(matrix.target, 'x86_64') && runner.os == 'Windows'
run: |
choco install -y nasm
- name: Build and run tests
if: matrix.run_tests == true
run: |
zig build -Dtarget=${{matrix.target}} test-all --summary all
- name: Build without running tests
if: matrix.run_tests != true
run: |
zig build -Dtarget=${{matrix.target}}
test-avx:
name: Run Tests (AVX x86_64)
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-linux-gnu
os: ubuntu-latest
- target: x86_64-macos
os: macos-latest
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v2
with:
version: 0.15.2
- name: Install nasm for x86 targets (Linux)
if: contains(matrix.target, 'x86_64') && runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y nasm
- name: Install nasm for x86 targets (macOS)
if: contains(matrix.target, 'x86_64') && runner.os == 'macOS'
run: |
brew install nasm
- name: Run AVX tests
run: |
zig build test-all --summary all
e2e-tests:
name: JavaScript tests
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download x86_64-linux artifact
uses: actions/download-artifact@v4
with:
name: odiff-linux-x64
path: zig-out/bin
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
cache: "npm"
- name: Install root dependencies
run: npm ci --ignore-scripts
- name: Prepare binary for tests
run: |
ls -la zig-out/bin/
cp zig-out/bin/odiff-linux-x64 zig-out/bin/odiff
chmod +x zig-out/bin/odiff
file zig-out/bin/odiff
zig-out/bin/odiff --version
- run: npm run test:js
playwright-tests:
name: Playwright visual regression tests
needs: [build]
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.56.0-noble
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download x86_64-linux artifact
uses: actions/download-artifact@v4
with:
name: odiff-linux-x64
path: zig-out/bin
- name: Install root dependencies
run: npm ci --ignore-scripts
- name: Prepare binary for tests
run: |
ls -la zig-out/bin/
cp zig-out/bin/odiff-linux-x64 zig-out/bin/odiff
cp zig-out/bin/odiff-linux-x64 npm_packages/odiff-bin/bin/odiff.exe
chmod +x zig-out/bin/odiff
chmod +x npm_packages/odiff-bin/bin/odiff.exe
zig-out/bin/odiff --version
- name: Build playwright-odiff package
working-directory: npm_packages/playwright-odiff
run: npm run build
- name: Run Playwright tests
working-directory: npm_packages/playwright-odiff
run: npm test
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: npm_packages/playwright-odiff/test-results
retention-days: 7
spellcheck:
name: Spell check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run typos
uses: crate-ci/typos@master
with:
config: ./typos.toml
publish:
name: Publish release
needs: [build, test, e2e-tests]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Download built binaries
uses: actions/download-artifact@v4
with:
pattern: odiff-*
merge-multiple: true
path: npm_packages/odiff-bin/raw_binaries
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
cache: "npm"
always-auth: true
registry-url: "https://registry.npmjs.org"
cache-dependency-path: "package-lock.json"
- name: Verify that we have 8 binaries
run: |
ls -la npm_packages/odiff-bin/raw_binaries
if [ $(ls -1 npm_packages/odiff-bin/raw_binaries | wc -l) -ne 8 ]; then
echo "Expected 6 binaries, but found $(ls -1 npm_packages/odiff-bin/raw_binaries | wc -l)"
exit 1
fi
- name: Copy root readme
run: cp README.md npm_packages/odiff-bin/README.md
- name: Publish odiff-bin package
working-directory: npm_packages/odiff-bin
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish playwright-odiff package
working-directory: npm_packages/playwright-odiff
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create github release
uses: softprops/action-gh-release@v1
with:
files: "npm_packages/odiff-bin/raw_binaries/*"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}