Skip to content

Commit 8c543eb

Browse files
committed
run matchstick as napi bindings instead of downloading binary
1 parent ce99997 commit 8c543eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+24531
-6458
lines changed

packages/cli/src/commands/test.ts

Lines changed: 40 additions & 303 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[target.x86_64-pc-windows-msvc]
2+
rustflags = ["-C", "target-feature=+crt-static"]
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
name: CI
2+
env:
3+
DEBUG: napi:*
4+
APP_NAME: "@graphprotocol/graph-matchstick"
5+
MACOSX_DEPLOYMENT_TARGET: '10.13'
6+
permissions:
7+
contents: write
8+
id-token: write
9+
'on':
10+
push:
11+
branches:
12+
- main
13+
tags-ignore:
14+
- '**'
15+
paths-ignore:
16+
- '**/*.md'
17+
- LICENSE
18+
- '**/*.gitignore'
19+
- .editorconfig
20+
- docs/**
21+
pull_request: null
22+
jobs:
23+
build:
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
settings:
28+
- host: macos-latest
29+
target: x86_64-apple-darwin
30+
build: yarn build --target x86_64-apple-darwin
31+
- host: windows-latest
32+
build: yarn build --target x86_64-pc-windows-msvc
33+
target: x86_64-pc-windows-msvc
34+
- host: ubuntu-latest
35+
target: x86_64-unknown-linux-gnu
36+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
37+
build: yarn build --target x86_64-unknown-linux-gnu
38+
- host: macos-latest
39+
target: aarch64-apple-darwin
40+
build: yarn build --target aarch64-apple-darwin
41+
name: stable - ${{ matrix.settings.target }} - node@20
42+
runs-on: ${{ matrix.settings.host }}
43+
steps:
44+
- uses: actions/checkout@v4
45+
- name: Setup node
46+
uses: actions/setup-node@v4
47+
if: ${{ !matrix.settings.docker }}
48+
with:
49+
node-version: 20
50+
cache: yarn
51+
- name: Install
52+
uses: dtolnay/rust-toolchain@stable
53+
if: ${{ !matrix.settings.docker }}
54+
with:
55+
toolchain: stable
56+
targets: ${{ matrix.settings.target }}
57+
- name: Cache cargo
58+
uses: actions/cache@v4
59+
with:
60+
path: |
61+
~/.cargo/registry/index/
62+
~/.cargo/registry/cache/
63+
~/.cargo/git/db/
64+
.cargo-cache
65+
target/
66+
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
67+
- uses: goto-bus-stop/setup-zig@v2
68+
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' || matrix.settings.target == 'armv7-unknown-linux-musleabihf' }}
69+
with:
70+
version: 0.11.0
71+
- name: Setup toolchain
72+
run: ${{ matrix.settings.setup }}
73+
if: ${{ matrix.settings.setup }}
74+
shell: bash
75+
- name: Setup node x86
76+
if: matrix.settings.target == 'i686-pc-windows-msvc'
77+
run: yarn config set supportedArchitectures.cpu "ia32"
78+
shell: bash
79+
- name: Install dependencies
80+
run: yarn install
81+
- name: Setup node x86
82+
uses: actions/setup-node@v4
83+
if: matrix.settings.target == 'i686-pc-windows-msvc'
84+
with:
85+
node-version: 20
86+
cache: yarn
87+
architecture: x86
88+
- name: Build in docker
89+
uses: addnab/docker-run-action@v3
90+
if: ${{ matrix.settings.docker }}
91+
with:
92+
image: ${{ matrix.settings.docker }}
93+
options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build'
94+
run: ${{ matrix.settings.build }}
95+
- name: Build
96+
run: ${{ matrix.settings.build }}
97+
if: ${{ !matrix.settings.docker }}
98+
shell: bash
99+
- name: Upload artifact
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: bindings-${{ matrix.settings.target }}
103+
path: ${{ env.APP_NAME }}.*.node
104+
if-no-files-found: error
105+
test-macOS-windows-binding:
106+
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
107+
needs:
108+
- build
109+
strategy:
110+
fail-fast: false
111+
matrix:
112+
settings:
113+
- host: macos-latest
114+
target: x86_64-apple-darwin
115+
- host: windows-latest
116+
target: x86_64-pc-windows-msvc
117+
node:
118+
- '18'
119+
- '20'
120+
runs-on: ${{ matrix.settings.host }}
121+
steps:
122+
- uses: actions/checkout@v4
123+
- name: Setup node
124+
uses: actions/setup-node@v4
125+
with:
126+
node-version: ${{ matrix.node }}
127+
cache: yarn
128+
architecture: x64
129+
- name: Install dependencies
130+
run: yarn install
131+
- name: Download artifacts
132+
uses: actions/download-artifact@v4
133+
with:
134+
name: bindings-${{ matrix.settings.target }}
135+
path: .
136+
- name: List packages
137+
run: ls -R .
138+
shell: bash
139+
- name: Test bindings
140+
run: yarn test
141+
test-linux-x64-gnu-binding:
142+
name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }}
143+
needs:
144+
- build
145+
strategy:
146+
fail-fast: false
147+
matrix:
148+
node:
149+
- '18'
150+
- '20'
151+
runs-on: ubuntu-latest
152+
steps:
153+
- uses: actions/checkout@v4
154+
- name: Setup node
155+
uses: actions/setup-node@v4
156+
with:
157+
node-version: ${{ matrix.node }}
158+
cache: yarn
159+
- name: Install dependencies
160+
run: yarn install
161+
- name: Download artifacts
162+
uses: actions/download-artifact@v4
163+
with:
164+
name: bindings-x86_64-unknown-linux-gnu
165+
path: .
166+
- name: List packages
167+
run: ls -R .
168+
shell: bash
169+
- name: Test bindings
170+
run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim yarn test
171+
publish:
172+
name: Publish
173+
runs-on: ubuntu-latest
174+
needs:
175+
- test-macOS-windows-binding
176+
- test-linux-x64-gnu-binding
177+
steps:
178+
- uses: actions/checkout@v4
179+
- name: Setup node
180+
uses: actions/setup-node@v4
181+
with:
182+
node-version: 20
183+
cache: yarn
184+
- name: Install dependencies
185+
run: yarn install
186+
- name: Download all artifacts
187+
uses: actions/download-artifact@v4
188+
with:
189+
path: artifacts
190+
- name: Move artifacts
191+
run: yarn artifacts
192+
- name: List packages
193+
run: ls -R ./npm
194+
shell: bash
195+
- name: Publish
196+
run: |
197+
npm config set provenance true
198+
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
199+
then
200+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
201+
npm publish --access public
202+
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
203+
then
204+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
205+
npm publish --tag next --access public
206+
else
207+
echo "Not a release, skipping publish"
208+
fi
209+
env:
210+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
211+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Release Linux
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
deploy:
13+
name: Deploy for ${{ matrix.os }}
14+
if: startsWith(github.ref, 'refs/tags')
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
name: [linux-22]
19+
20+
include:
21+
- name: linux-22
22+
os: ubuntu-22.04
23+
artifact_name: matchstick
24+
asset_name: binary-linux-22
25+
26+
steps:
27+
- uses: actions/checkout@v3
28+
- uses: dtolnay/rust-toolchain@stable
29+
with:
30+
toolchain: 1.68.0
31+
- name: Install dependencies
32+
run: |
33+
sudo apt-get update
34+
sudo apt-get -y install libpq-dev protobuf-compiler
35+
36+
- name: Build
37+
run: cargo build --release && mv target/release/${{ matrix.artifact_name }} target/release/${{ matrix.asset_name }}
38+
39+
- name: Upload binaries to release
40+
run: echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token && gh release upload ${GITHUB_REF##*/} target/release/${{ matrix.asset_name }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release MacOS Intel
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
deploy:
13+
name: Deploy for ${{ matrix.os }}
14+
if: startsWith(github.ref, 'refs/tags')
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
name: [macos-11, macos-12]
19+
20+
include:
21+
- name: macos-11
22+
os: macos-11
23+
artifact_name: matchstick
24+
asset_name: binary-macos-11
25+
- name: macos-12
26+
os: macos-12
27+
artifact_name: matchstick
28+
asset_name: binary-macos-12
29+
30+
steps:
31+
- uses: actions/checkout@v3
32+
- uses: dtolnay/rust-toolchain@stable
33+
with:
34+
toolchain: 1.68.0
35+
- run: brew install protobuf
36+
37+
- name: Build
38+
run: cargo build --release && mv target/release/${{ matrix.artifact_name }} target/release/${{ matrix.asset_name }}
39+
40+
- name: Upload binaries to release
41+
run: echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token && gh release upload ${GITHUB_REF##*/} target/release/${{ matrix.asset_name }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release MacOS (M1)
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
deploy:
13+
name: Deploy for macos (M1)
14+
if: startsWith(github.ref, 'refs/tags')
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
name: [macos-11-m1, macos-12-m1]
19+
20+
include:
21+
- name: macos-11-m1
22+
os: macos-11
23+
artifact_name: matchstick
24+
asset_name: binary-macos-11-m1
25+
- name: macos-12-m1
26+
os: macos-12
27+
artifact_name: matchstick
28+
asset_name: binary-macos-12-m1
29+
30+
steps:
31+
- uses: actions/checkout@v3
32+
- uses: dtolnay/rust-toolchain@stable
33+
with:
34+
toolchain: 1.68.0
35+
- run: brew install protobuf
36+
37+
- name: Build
38+
run: rustup target add aarch64-apple-darwin && cargo build --release --target aarch64-apple-darwin && mv target/aarch64-apple-darwin/release/${{ matrix.artifact_name }} target/release/${{ matrix.asset_name }}
39+
40+
- name: Upload binary to release
41+
run: echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token && gh release upload ${GITHUB_REF##*/} target/release/${{ matrix.asset_name }}

0 commit comments

Comments
 (0)