Skip to content

Commit d36c08b

Browse files
committed
v1.0.0
0 parents  commit d36c08b

27 files changed

+5230
-0
lines changed

.github/workflows/ci.yml

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
name: CI
2+
3+
env:
4+
DEBUG: napi:*
5+
APP_NAME: http-handler
6+
MACOSX_DEPLOYMENT_TARGET: '10.13'
7+
8+
permissions:
9+
contents: write
10+
id-token: write
11+
12+
on:
13+
push:
14+
branches:
15+
- main
16+
tags-ignore:
17+
- '**'
18+
paths-ignore:
19+
- '**/*.md'
20+
- LICENSE
21+
- '**/*.gitignore'
22+
- .editorconfig
23+
- docs/**
24+
pull_request:
25+
26+
jobs:
27+
build:
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
settings:
32+
- host: macos-latest
33+
target: x86_64-apple-darwin
34+
build: pnpm run build --target x86_64-apple-darwin
35+
- host: ubuntu-latest
36+
target: x86_64-unknown-linux-gnu
37+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
38+
build: pnpm run build --target x86_64-unknown-linux-gnu
39+
- host: macos-latest
40+
target: aarch64-apple-darwin
41+
build: pnpm run build --target aarch64-apple-darwin
42+
name: stable - ${{ matrix.settings.target }} - node@20
43+
runs-on: ${{ matrix.settings.host }}
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: pnpm/action-setup@v4
47+
with:
48+
version: latest
49+
- uses: actions/setup-node@v4
50+
if: ${{ !matrix.settings.docker }}
51+
with:
52+
node-version: 20
53+
- name: Install
54+
uses: dtolnay/rust-toolchain@stable
55+
if: ${{ !matrix.settings.docker }}
56+
with:
57+
toolchain: stable
58+
targets: ${{ matrix.settings.target }}
59+
- name: Cache cargo
60+
uses: actions/cache@v4
61+
with:
62+
path: |
63+
~/.cargo/registry/index/
64+
~/.cargo/registry/cache/
65+
~/.cargo/git/db/
66+
.cargo-cache
67+
target/
68+
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
69+
- uses: goto-bus-stop/setup-zig@v2
70+
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' || matrix.settings.target == 'armv7-unknown-linux-musleabihf' }}
71+
with:
72+
version: 0.13.0
73+
- name: Setup toolchain
74+
run: ${{ matrix.settings.setup }}
75+
if: ${{ matrix.settings.setup }}
76+
shell: bash
77+
- name: Install dependencies
78+
run: pnpm install
79+
- name: Build in docker
80+
uses: addnab/docker-run-action@v3
81+
if: ${{ matrix.settings.docker }}
82+
with:
83+
image: ${{ matrix.settings.docker }}
84+
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'
85+
run: |
86+
set -x
87+
eval `ssh-agent -s`
88+
ssh-add
89+
corepack disable
90+
npm i -gf pnpm
91+
${{ matrix.settings.build }}
92+
- name: Build
93+
run: ${{ matrix.settings.build }}
94+
if: ${{ !matrix.settings.docker }}
95+
shell: bash
96+
- name: Upload artifact
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: bindings-${{ matrix.settings.target }}
100+
path: |
101+
${{ env.APP_NAME }}.*.node
102+
index.d.ts
103+
index.js
104+
if-no-files-found: error
105+
106+
test-macOS-windows-binding:
107+
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
108+
needs:
109+
- build
110+
strategy:
111+
fail-fast: false
112+
matrix:
113+
settings:
114+
- host: macos-latest
115+
target: x86_64-apple-darwin
116+
node:
117+
- '18'
118+
- '20'
119+
runs-on: ${{ matrix.settings.host }}
120+
steps:
121+
- uses: actions/checkout@v4
122+
- uses: pnpm/action-setup@v4
123+
with:
124+
version: latest
125+
- uses: actions/setup-node@v4
126+
with:
127+
node-version: ${{ matrix.node }}
128+
cache: pnpm
129+
architecture: x64
130+
- run: pnpm install
131+
- uses: actions/download-artifact@v4
132+
with:
133+
name: bindings-${{ matrix.settings.target }}
134+
path: .
135+
- name: List packages
136+
run: ls -R .
137+
shell: bash
138+
- run: pnpm test
139+
140+
test-linux-binding:
141+
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
142+
needs:
143+
- build
144+
strategy:
145+
fail-fast: false
146+
matrix:
147+
settings:
148+
- host: ubuntu-22.04
149+
target: x86_64-unknown-linux-gnu
150+
# Not supported yet.
151+
# - host: ubuntu-22.04
152+
# target: x86_64-unknown-linux-musl
153+
# Not supported yet, ubuntu-24.04-arm runner requires repo is public
154+
# - host: ubuntu-22.04-arm
155+
# target: aarch64-unknown-linux-gnu
156+
# - host: ubuntu-22.04-arm
157+
# target: aarch64-unknown-linux-musl
158+
node:
159+
- '18'
160+
- '20'
161+
runs-on: ${{ matrix.settings.host }}
162+
steps:
163+
- uses: actions/checkout@v4
164+
- uses: pnpm/action-setup@v4
165+
with:
166+
version: latest
167+
- name: Setup node
168+
uses: actions/setup-node@v4
169+
with:
170+
node-version: ${{ matrix.node }}
171+
cache: pnpm
172+
- name: Install dependencies
173+
run: pnpm install
174+
- uses: actions/download-artifact@v4
175+
with:
176+
name: bindings-${{ matrix.settings.target }}
177+
path: .
178+
- name: List packages
179+
run: ls -R .
180+
shell: bash
181+
- name: Output docker params
182+
id: docker
183+
run: |
184+
node -e "
185+
if ('${{ matrix.settings.target }}'.startsWith('aarch64')) {
186+
console.log('PLATFORM=linux/arm64')
187+
} else if ('${{ matrix.settings.target }}'.startsWith('armv7')) {
188+
console.log('PLATFORM=linux/arm/v7')
189+
} else {
190+
console.log('PLATFORM=linux/amd64')
191+
}
192+
" >> $GITHUB_OUTPUT
193+
node -e "
194+
if ('${{ matrix.settings.target }}'.endsWith('-musl')) {
195+
console.log('IMAGE=node:${{ matrix.node }}-alpine')
196+
} else {
197+
console.log('IMAGE=node:${{ matrix.node }}-slim')
198+
}
199+
" >> $GITHUB_OUTPUT
200+
echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
201+
- name: Test crates and bindings
202+
uses: addnab/docker-run-action@v3
203+
with:
204+
image: ${{ steps.docker.outputs.IMAGE }}
205+
options: -v ${{ steps.docker.outputs.PNPM_STORE_PATH }}:${{ steps.docker.outputs.PNPM_STORE_PATH }} -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} --platform ${{ steps.docker.outputs.PLATFORM }}
206+
run: |
207+
corepack disable
208+
npm i -gf pnpm
209+
pnpm test
210+
211+
publish:
212+
name: Publish
213+
runs-on: ubuntu-latest
214+
needs:
215+
- test-macOS-windows-binding
216+
- test-linux-binding
217+
steps:
218+
- uses: actions/checkout@v4
219+
- uses: pnpm/action-setup@v4
220+
with:
221+
version: latest
222+
- uses: actions/setup-node@v4
223+
with:
224+
node-version: 20
225+
cache: pnpm
226+
- name: Install dependencies
227+
run: pnpm install
228+
- name: Download all artifacts
229+
uses: actions/download-artifact@v4
230+
with:
231+
path: artifacts
232+
- name: Move artifacts
233+
run: pnpm artifacts
234+
- name: List packages
235+
run: ls -R ./npm
236+
shell: bash
237+
- name: Publish
238+
if: ${{ contains(github.ref, 'main') }}
239+
run: |
240+
npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
241+
npm config set scope "@platformatic"
242+
# npm config set provenance true
243+
if git log -1 --pretty=%B | grep "^v\?[0-9]\+\.[0-9]\+\.[0-9]\+";
244+
then
245+
npm publish --access public
246+
elif git log -1 --pretty=%B | grep "^v\?[0-9]\+\.[0-9]\+\.[0-9]\+-\.+";
247+
then
248+
npm publish --tag next --access public
249+
else
250+
echo "Not a release, skipping publish"
251+
fi
252+
env:
253+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
254+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/lint.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Lint
2+
3+
'on':
4+
push:
5+
branches:
6+
- main
7+
tags-ignore:
8+
- '**'
9+
paths-ignore:
10+
- '**/*.md'
11+
- LICENSE
12+
- '**/*.gitignore'
13+
- .editorconfig
14+
- docs/**
15+
pull_request: null
16+
17+
env:
18+
CARGO_NET_GIT_FETCH_WITH_CLI: 'true'
19+
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.ref }}-lint
22+
cancel-in-progress: true
23+
24+
jobs:
25+
lint:
26+
name: Lint
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: pnpm/action-setup@v4
31+
with:
32+
version: latest
33+
- name: Setup node
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 22
37+
cache: pnpm
38+
39+
- name: Install
40+
uses: dtolnay/rust-toolchain@stable
41+
with:
42+
components: clippy, rustfmt
43+
44+
- name: Install dependencies
45+
run: pnpm install
46+
47+
- name: ESLint
48+
run: pnpm lint
49+
50+
- name: Cargo fmt
51+
run: cargo fmt -- --check
52+
53+
- name: Clippy
54+
run: cargo clippy

0 commit comments

Comments
 (0)