Skip to content

Commit

Permalink
Fix macOS x64 build
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Feb 5, 2024
1 parent b629e79 commit 4985872
Show file tree
Hide file tree
Showing 12 changed files with 223 additions and 219 deletions.
38 changes: 38 additions & 0 deletions .github/actions/setup-rust.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: 'Setup rust'
description: 'Rust setup, including cache configuration'
inputs:
target:
description: 'Cargo target'
required: true
components:
description: 'Rustup components'
required: false
default: ''
runs:
using: 'composite'
steps:
- name: Print rustup toolchain version
shell: bash
id: rustup-version
run: |
export RUST_TOOLCHAIN_VERSION="$(grep 'channel' rust-toolchain.toml | head -1 | awk -F '"' '{print $2}')"
echo "Rust toolchain version: $RUST_TOOLCHAIN_VERSION"
echo "RUST_TOOLCHAIN_VERSION=$RUST_TOOLCHAIN_VERSION" >> "$GITHUB_OUTPUT"
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: '${{ steps.rustup-version.outputs.RUST_TOOLCHAIN_VERSION }}'
targets: ${{ inputs.target }}
components: ${{ inputs.components }}
env:
CARGO_INCREMENTAL: '1'

- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/
~/.cargo/git/db/
~/.napi-rs
target/${{ inputs.target }}
key: ${{ steps.rustup-version.outputs.RUST_TOOLCHAIN_VERSION }}-${{ inputs.target }}-cargo-cache
185 changes: 164 additions & 21 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,51 @@ on:
- '**'
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.ref_name != 'main' }}

jobs:
lint:
name: Lint SourceCode
runs-on: ubuntu-latest
container:
image: ghcr.io/brooooooklyn/canvas/ubuntu-builder:jammy

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'

- name: Install
uses: ./actions/setup-rust
with:
targets: x86_64-apple-darwin
components: clippy, rustfmt

- name: Install dependencies
run: yarn install --immutable --mode=skip-build

- name: Download skia binary
run: |
git config --global --add safe.directory $(pwd)
node ./scripts/release-skia-binary.js --download
- name: 'Lint JS/TS'
run: yarn lint

- name: Cargo fmt
run: cargo fmt -- --check

- name: Clippy
run: cargo clippy

build:
strategy:
fail-fast: false
Expand Down Expand Up @@ -147,10 +191,9 @@ jobs:
if: matrix.settings.host == 'windows-latest'

- name: Install
uses: dtolnay/rust-toolchain@stable
uses: ./actions/setup-rust
with:
targets: ${{ matrix.settings.target }}
toolchain: nightly-2023-08-09

- name: Cache cargo registry
uses: actions/cache@v4
Expand Down Expand Up @@ -186,7 +229,7 @@ jobs:
run: ${{ matrix.settings.build }}

- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: ${{ env.APP_NAME }}.*.node
Expand All @@ -199,8 +242,10 @@ jobs:
fail-fast: false
matrix:
settings:
- host: macos-latest
- host: macos-14
target: 'x86_64-apple-darwin'
- host: macos-14
target: 'aarch64-apple-darwin'
- host: windows-latest
target: 'x86_64-pc-windows-msvc'
node: ['18', '20']
Expand All @@ -222,20 +267,25 @@ jobs:

- name: Setup node
uses: actions/setup-node@v4
if: startsWith(matrix.settings.target, 'x86_64')
with:
node-version: ${{ matrix.node }}
cache: 'yarn'
architecture: 'x64'

- name: Cache yarn
uses: actions/cache@v4
- name: Setup node
uses: actions/setup-node@v4
if: startsWith(matrix.settings.target, 'aarch64')
with:
path: .yarn/cache
key: ${{ matrix.settings.target }}-yarn-cache-node-${{ matrix.node }}
node-version: ${{ matrix.node }}
cache: 'yarn'
architecture: 'arm64'

- name: Install dependencies
run: yarn install --immutable --mode=skip-build

- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: .
Expand All @@ -249,7 +299,7 @@ jobs:

- name: Test failed
if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: failure-images-${{ matrix.settings.target }}-${{ matrix.node }}
path: __test__/failure/**
Expand Down Expand Up @@ -286,7 +336,7 @@ jobs:
run: yarn install --immutable --mode=skip-build

- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: bindings-x86_64-unknown-linux-gnu
path: .
Expand All @@ -300,7 +350,7 @@ jobs:

- name: Test failed
if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: failure-images-x86_64-unknown-linux-gnu-${{ matrix.node }}
path: __test__/failure/**
Expand Down Expand Up @@ -339,7 +389,7 @@ jobs:
yarn install --immutable --mode=skip-build
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: bindings-x86_64-unknown-linux-musl
path: .
Expand All @@ -353,7 +403,7 @@ jobs:

- name: Test failed
if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: failure-images-x86_64-unknown-linux-musl-${{ matrix.node }}
path: __test__/failure/**
Expand Down Expand Up @@ -381,7 +431,7 @@ jobs:
out-file-path: __test__/fonts/

- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: bindings-aarch64-unknown-linux-gnu
path: .
Expand Down Expand Up @@ -414,7 +464,7 @@ jobs:
- name: Test failed
if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: failure-images-aarch64-unknown-linux-gnu-${{ matrix.node }}
path: __test__/failure/**
Expand All @@ -439,7 +489,7 @@ jobs:
out-file-path: __test__/fonts/

- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: bindings-aarch64-unknown-linux-musl
path: .
Expand Down Expand Up @@ -472,7 +522,7 @@ jobs:
- name: Test failed
if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: failure-images-aarch64-unknown-linux-musl-lts
path: __test__/failure/**
Expand Down Expand Up @@ -500,7 +550,7 @@ jobs:
out-file-path: __test__/fonts/

- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: bindings-armv7-unknown-linux-gnueabihf
path: .
Expand Down Expand Up @@ -533,11 +583,104 @@ jobs:
- name: Test failed
if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: failure-images-armv7-unknown-linux-gnueabihf-${{ matrix.node }}
path: __test__/failure/**

rust-test:
name: stable - macOS - cargo - test
runs-on: macos-14

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install
uses: ./actions/setup-rust
with:
targets: x86_64-apple-darwin

- name: Install dependencies
run: yarn install --immutable --mode=skip-build

- name: Install nasm
run: brew install nasm llvm

- name: Download skia binary
run: node ./scripts/release-skia-binary.js --download

- name: Test
run: |
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
clang --version
cargo test -- --nocapture
bench:
name: Bench
runs-on: ubuntu-latest
container:
image: ghcr.io/brooooooklyn/canvas/ubuntu-builder:jammy

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'

- name: Install
uses: ./actions/setup-rust
with:
targets: x86_64-unknown-linux-gnu
toolchain: nightly-2023-08-09

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: bench-cargo-cache

- name: Install dependencies
run: yarn install --immutable

- name: Download skia binary
run: |
git config --global --add safe.directory $(pwd)
node ./scripts/release-skia-binary.js --download
- name: 'Build'
run: yarn build

- name: 'Run benchmark'
run: yarn bench

- name: Store benchmark result
uses: rhysd/github-action-benchmark@v1
if: github.ref == 'refs/heads/main'
with:
tool: 'benchmarkjs'
output-file-path: bench.txt
github-token: ${{ secrets.GH_TOKEN }}
auto-push: true

- name: Store benchmark result
uses: rhysd/github-action-benchmark@v1
continue-on-error: true
if: github.ref != 'refs/heads/main'
with:
tool: 'benchmarkjs'
output-file-path: bench.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-always: true

publish:
name: Publish
runs-on: ubuntu-latest
Expand All @@ -564,7 +707,7 @@ jobs:
run: yarn install --immutable --mode=skip-build

- name: Download all artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: artifacts

Expand Down
Loading

0 comments on commit 4985872

Please sign in to comment.