-
Notifications
You must be signed in to change notification settings - Fork 465
168 lines (146 loc) · 5.3 KB
/
build-graph-node.yml
File metadata and controls
168 lines (146 loc) · 5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Build Graph Node Native Modules
on:
push:
branches: [main]
paths:
- 'crates/ruvector-graph/**'
- 'crates/ruvector-graph-node/**'
- 'npm/packages/graph-node/**'
- '.github/workflows/build-graph-node.yml'
tags:
- 'v*'
pull_request:
branches: [main]
paths:
- 'crates/ruvector-graph/**'
- 'crates/ruvector-graph-node/**'
- 'npm/packages/graph-node/**'
workflow_dispatch:
inputs:
publish:
description: 'Publish to npm after build'
required: false
type: boolean
default: false
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
fail-fast: false
matrix:
settings:
- host: ubuntu-22.04
target: x86_64-unknown-linux-gnu
platform: linux-x64-gnu
- host: ubuntu-22.04
target: aarch64-unknown-linux-gnu
platform: linux-arm64-gnu
- host: macos-14
target: x86_64-apple-darwin
platform: darwin-x64
- host: macos-14
target: aarch64-apple-darwin
platform: darwin-arm64
- host: windows-2022
target: x86_64-pc-windows-msvc
platform: win32-x64-msvc
name: Build Graph ${{ matrix.settings.platform }}
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
key: graph-node-${{ matrix.settings.target }}
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.settings.platform == 'linux-arm64-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Install dependencies
working-directory: npm/packages/graph-node
run: npm install --ignore-scripts --omit=optional --force
- name: Build native module
working-directory: npm/packages/graph-node
run: |
npx napi build --platform --release --cargo-cwd ../../../crates/ruvector-graph-node --target ${{ matrix.settings.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Find built .node files (debug)
shell: bash
run: |
echo "=== Searching for Graph .node files ==="
find npm/packages/graph-node -name "*.node" -type f 2>/dev/null || true
- name: Prepare artifact
shell: bash
run: |
mkdir -p graph-artifacts/${{ matrix.settings.platform }}
NODE_FILE=$(find npm/packages/graph-node -name "index.*.node" -type f | head -1)
if [ -z "$NODE_FILE" ]; then
echo "ERROR: No .node file found"
find npm/packages/graph-node -name "*.node" -type f
exit 1
fi
echo "Found: $NODE_FILE"
cp -v "$NODE_FILE" "graph-artifacts/${{ matrix.settings.platform }}/"
- name: Test native module (native platform only)
if: |
(matrix.settings.platform == 'linux-x64-gnu' && runner.os == 'Linux') ||
(matrix.settings.platform == 'darwin-x64' && runner.os == 'macOS' && runner.arch == 'X64') ||
(matrix.settings.platform == 'darwin-arm64' && runner.os == 'macOS' && runner.arch == 'ARM64') ||
(matrix.settings.platform == 'win32-x64-msvc' && runner.os == 'Windows')
continue-on-error: true
working-directory: npm/packages/graph-node
run: npm test
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: graph-node-${{ matrix.settings.platform }}
path: graph-artifacts/${{ matrix.settings.platform }}/*.node
if-no-files-found: error
publish:
name: Publish Graph Node Platform Packages
runs-on: ubuntu-22.04
needs: build
if: inputs.publish == true || startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Copy binaries to package
run: |
for dir in artifacts/graph-node-*/; do
platform=$(basename "$dir" | sed 's/graph-node-//')
NODE_FILE=$(find "$dir" -name "*.node" | head -1)
if [ -n "$NODE_FILE" ]; then
cp -v "$NODE_FILE" "npm/packages/graph-node/index.${platform}.node"
fi
done
ls -la npm/packages/graph-node/*.node
- name: Publish platform packages
working-directory: npm/packages/graph-node
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: node scripts/publish-platforms.js
- name: Publish main package
working-directory: npm/packages/graph-node
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public || echo "Package may already exist"