Skip to content

Commit

Permalink
feat: macos-arm64 / Apple Silicon / M1 builds
Browse files Browse the repository at this point in the history
  • Loading branch information
zone117x authored and obycode committed Feb 12, 2022
1 parent b2acdc1 commit da5f1bc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
28 changes: 20 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ jobs:
linker_package:
cc: ""
architecture: x64
# - os: macos-latest
# platform: darwin
# target: aarch64-apple-darwin
# linker_package:
# cc: ""
# architecture: arm64
- os: macos-latest
platform: darwin
target: aarch64-apple-darwin
linker_package:
cc: ""
architecture: arm64

steps:
- name: Configure git to use LF (Windows)
Expand All @@ -199,7 +199,9 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: '14'
architecture: ${{ matrix.architecture }}
# Host nodejs arch does not matter in our usecase for compiling cross-platform npm packages,
# if enabled, this will fail after installing an arm64 nodejs runtime for an x86_64 arch macos system
# architecture: ${{ matrix.architecture }}
cache: npm
cache-dependency-path: node-bindings/package-lock.json

Expand All @@ -226,6 +228,13 @@ jobs:
# if: ${{ matrix.platform }}-${{ matrix.architecture }} == 'linux-arm64' || ${{ matrix.platform }}-${{ matrix.architecture }} == 'linux-armv7' || ${{ matrix.platform }}-${{ matrix.architecture }} == 'linux-musl-x64'
# run: sudo apt-get update && sudo apt-get install -y ${{ matrix.linker_package }}

# Set environment variables required from cross compiling from macos-x86_64 to macos-arm64
- name: Configure macos-arm64 cross compile config
if: matrix.target == 'aarch64-apple-darwin'
run: |
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV
- name: Build - Cargo
run: cargo build --release --features=telemetry --locked --target ${{ matrix.target }}
# To be uncommented later when adding new distros
Expand Down Expand Up @@ -324,14 +333,17 @@ jobs:
path: stacks-devnet-js-${{ matrix.platform }}-${{ matrix.architecture }}.tar.gz

- name: Unit Tests - Cargo
# can't easily run mac-arm64 tests in GH without native runners for that arch
if: matrix.target != 'aarch64-apple-darwin'
run: cargo test --release --locked --target ${{ matrix.target }}

# - name: Unit Tests - Node
# working-directory: node-bindings
# run: npm run spec

- name: Functional Tests (Not Windows)
if: matrix.os != 'windows-latest'
# can't easily run mac-arm64 tests in GH without native runners for that arch
if: matrix.os != 'windows-latest' && matrix.target != 'aarch64-apple-darwin'
run: |
for testdir in $(ls examples); do
./target/${{ matrix.target }}/release/clarinet test --manifest-path examples/${testdir}/Clarinet.toml
Expand Down
1 change: 1 addition & 0 deletions node-bindings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"build-linux-x64": "npm run build-release -- --target x86_64-unknown-linux-gnu",
"build-windows-x64": "npm run build-release -- --target x86_64-pc-windows-msvc",
"build-darwin-x64": "npm run build-release -- --target x86_64-apple-darwin",
"build-darwin-arm64": "npm run build-release -- --target aarch64-apple-darwin",
"install": "node-pre-gyp install --fallback-to-build=false || npm run build-release",
"lint": "eslint .",
"package": "node-pre-gyp package",
Expand Down

0 comments on commit da5f1bc

Please sign in to comment.