Skip to content

Commit

Permalink
[ci] Fix CI (#7)
Browse files Browse the repository at this point in the history
#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 <[email protected]>
  • Loading branch information
lhchavez and szymonkaliski authored May 3, 2024
1 parent d920a63 commit 2aeef95
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -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
32 changes: 22 additions & 10 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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/
Expand Down Expand Up @@ -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
Expand All @@ -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: .
Expand All @@ -140,22 +148,24 @@ 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:
node-version: 20
- 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: .
- name: List packages
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
Expand All @@ -167,14 +177,16 @@ 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:
node-version: 20
- 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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,4 @@ Cargo.lock
!.yarn/versions

*.node
/.direnv
Binary file modified bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
}
35 changes: 25 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 2aeef95

Please sign in to comment.