From 2aeef953e20d63a74c9deddf9195b4a5804ab917 Mon Sep 17 00:00:00 2001 From: lhchavez Date: Fri, 3 May 2024 10:04:26 -0700 Subject: [PATCH] [ci] Fix CI (#7) #4 added a lot of good CI improvements. Let's land them ASAP! This change takes #4 and only keeps the changes needed to fix CI and local Linux development. --------- Co-authored-by: Szymon Kaliski --- .envrc | 3 +++ .github/workflows/CI.yml | 32 ++++++++++++++++++++++---------- .gitignore | 1 + bun.lockb | Bin 21351 -> 21351 bytes flake.nix | 2 ++ index.js | 35 +++++++++++++++++++++++++---------- package.json | 2 +- 7 files changed, 54 insertions(+), 21 deletions(-) diff --git a/.envrc b/.envrc index 3550a30..979cc3e 100644 --- a/.envrc +++ b/.envrc @@ -1 +1,4 @@ +if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" +fi use flake diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e623fd6..9f662c7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -27,10 +27,12 @@ jobs: fail-fast: false matrix: settings: - - host: macos-latest + - host: macos-14-large target: x86_64-apple-darwin - build: | - bun run build + architecture: x64 + build: |- + set -e && + bun run build --target x86_64-apple-darwin && strip -x *.node - host: ubuntu-latest target: x86_64-unknown-linux-gnu @@ -46,6 +48,8 @@ jobs: - uses: actions/checkout@v4 - name: Setup Bun uses: oven-sh/setup-bun@v1 + with: + bun-version: 1.0.26 - name: Setup node uses: actions/setup-node@v4 if: ${{ !matrix.settings.docker }} @@ -58,7 +62,7 @@ jobs: toolchain: stable targets: ${{ matrix.settings.target }} - name: Cache cargo - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.cargo/registry/index/ @@ -89,7 +93,7 @@ jobs: if: ${{ !matrix.settings.docker }} shell: bash - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: bindings-${{ matrix.settings.target }} path: ${{ env.APP_NAME }}.*.node @@ -102,21 +106,25 @@ jobs: strategy: matrix: settings: - - host: macos-latest + - host: macos-14-large target: x86_64-apple-darwin + architecture: x64 runs-on: ${{ matrix.settings.host }} steps: - uses: actions/checkout@v4 - name: Setup Bun uses: oven-sh/setup-bun@v1 + with: + bun-version: 1.0.26 - name: Setup node uses: actions/setup-node@v4 with: node-version: 20 + architecture: ${{ matrix.settings.architecture }} - name: Install dependencies run: bun install - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: bindings-${{ matrix.settings.target }} path: . @@ -140,6 +148,8 @@ jobs: - uses: actions/checkout@v4 - name: Setup Bun uses: oven-sh/setup-bun@v1 + with: + bun-version: 1.0.26 - name: Setup node uses: actions/setup-node@v4 with: @@ -147,7 +157,7 @@ jobs: - name: Install dependencies run: bun install - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: bindings-${{ matrix.settings.target }} path: . @@ -155,7 +165,7 @@ jobs: run: ls -R . shell: bash - name: Test bindings - run: docker run --rm -v $(pwd):/build -w /build oven/bun:1 bun test + run: docker run --rm -v $(pwd):/build -w /build oven/bun:1.0.26 bun test publish: name: Publish @@ -167,6 +177,8 @@ jobs: - uses: actions/checkout@v4 - name: Setup Bun uses: oven-sh/setup-bun@v1 + with: + bun-version: 1.0.26 - name: Setup node uses: actions/setup-node@v4 with: @@ -174,7 +186,7 @@ jobs: - name: Install dependencies run: bun install - name: Download all artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: path: artifacts - name: Move artifacts diff --git a/.gitignore b/.gitignore index 00ed0f8..bed3986 100644 --- a/.gitignore +++ b/.gitignore @@ -196,3 +196,4 @@ Cargo.lock !.yarn/versions *.node +/.direnv diff --git a/bun.lockb b/bun.lockb index 50a1bf2d3b0915389a0de113421b50669618e70c..941803e574b9368b6dfda0d7ceb522a8727cf41f 100755 GIT binary patch delta 501 zcmYMwJ4iwS6vlBc-Wv|m3)CKFYGn>}D=R628X_wK2ZtmOdlFG$X(6;Y^l%9*y5txH zafdL$4BOfYq{z)t=w*+gauE`-Jm1n8e&_HX&#TD1ip)N*-7p=f_hx=WBl4y2^4yvy z6Zv{yn0Bm)59$`ZOFkB{=E{X_&KO;-;8=zcyb62KduUM7?So0ktEl*43Yx2^1YjEW zS5pbXPiU#3as;!`T1!QQ1vsvz5{4ypbUR@TmTIWX!z-w)r{aP)P@|>dh4;{)qvC@} z$m^;2VG5cXs03gd_BT=q!cS;vqH+YY&}yI}!h*p*!AK;Gq)=8U?rzEdu)6hzT@Uy2 ze0JTD%I611s}doHIK}oV&f88uG6{8XI37QpoR9r%4&24IZf(ad_s+>%D|eBby*#um tJ{3RGY!|+zDxsZaqgvx*rL>1P30&WhOvX4nc@y6iwe@LKj7f0YvVWRLn9tJS!T?0=2X*%eo}wbSN7H2_l!sz(I{Dh@dfQ5n2rT#a*zv08fcX{DglG&2X#zo6XW+-v6cYhU92G>%7 zpG3o!_V6h4ZL`h3R|Na|Ov?AAld2k9dbw50v5XYf2W#e_V4xj=c_7 z!E)|+b11jbd6v&bCbz{Kxgzmdy>(*rA+%aeeHN2C#+1flr2TH*$U3DJzw!&UteZ6e diff --git a/flake.nix b/flake.nix index b04fca6..298d5ed 100644 --- a/flake.nix +++ b/flake.nix @@ -20,5 +20,7 @@ { devShells.aarch64-darwin.default = mkDevShell "aarch64-darwin"; devShells.x86_64-darwin.default = mkDevShell "x86_64-darwin"; + devShells.aarch64-linux.default = mkDevShell "aarch64-linux"; + devShells.x86_64-linux.default = mkDevShell "x86_64-linux"; }; } diff --git a/index.js b/index.js index 1481fc1..1a2a909 100644 --- a/index.js +++ b/index.js @@ -224,17 +224,32 @@ switch (platform) { } break case 'arm': - localFileExisted = existsSync( - join(__dirname, 'ruspty.linux-arm-gnueabihf.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./ruspty.linux-arm-gnueabihf.node') - } else { - nativeBinding = require('@replit/ruspty-linux-arm-gnueabihf') + if (isMusl()) { + localFileExisted = existsSync( + join(__dirname, 'ruspty.linux-arm-musleabihf.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./ruspty.linux-arm-musleabihf.node') + } else { + nativeBinding = require('@replit/ruspty-linux-arm-musleabihf') + } + } catch (e) { + loadError = e + } + } else { + localFileExisted = existsSync( + join(__dirname, 'ruspty.linux-arm-gnueabihf.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./ruspty.linux-arm-gnueabihf.node') + } else { + nativeBinding = require('@replit/ruspty-linux-arm-gnueabihf') + } + } catch (e) { + loadError = e } - } catch (e) { - loadError = e } break case 'riscv64': diff --git a/package.json b/package.json index 3fb0923..8bfb8cb 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ }, "license": "MIT", "devDependencies": { - "@napi-rs/cli": "^2.17.0", + "@napi-rs/cli": "^2.18.2", "@types/node": "^20.4.1", "@types/jest": "^29.5.11", "prettier": "^3.2.4"