Skip to content

Commit 0232c8a

Browse files
authored
Merge pull request #1 from bytedance/dev
ci: update branch could trigger actions
2 parents e32e282 + a5976fa commit 0232c8a

File tree

6 files changed

+2740
-41
lines changed

6 files changed

+2740
-41
lines changed

.github/workflows/CI.yml

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: CI
22
env:
33
DEBUG: napi:*
4-
APP_NAME: unode-unix-socket
4+
APP_NAME: node-unix-socket
55
MACOSX_DEPLOYMENT_TARGET: '10.13'
66
'on':
77
push:
88
branches:
9-
- main
9+
- master
1010
tags-ignore:
1111
- '**'
1212
paths-ignore:
@@ -29,18 +29,13 @@ jobs:
2929
build: |
3030
yarn build
3131
strip -x *.node
32-
- host: windows-latest
33-
build: yarn build
34-
target: x86_64-pc-windows-msvc
35-
architecture: x64
3632
- host: ubuntu-latest
3733
target: x86_64-unknown-linux-gnu
38-
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine-zig
34+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
3935
build: |-
4036
set -e &&
41-
rustup target add x86_64-unknown-linux-gnu &&
42-
yarn build --target x86_64-unknown-linux-gnu --zig --zig-abi-suffix 2.12 &&
43-
llvm-strip -x *.node
37+
yarn build --target x86_64-unknown-linux-gnu &&
38+
strip *.node
4439
- host: macos-latest
4540
target: aarch64-apple-darwin
4641
build: |
@@ -96,7 +91,7 @@ jobs:
9691
if: ${{ matrix.settings.setup }}
9792
shell: bash
9893
- name: Install dependencies
99-
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
94+
run: yarn install
10095
- name: Build in docker
10196
uses: addnab/docker-run-action@v3
10297
if: ${{ matrix.settings.docker }}
@@ -114,21 +109,18 @@ jobs:
114109
name: bindings-${{ matrix.settings.target }}
115110
path: ${{ env.APP_NAME }}.*.node
116111
if-no-files-found: error
117-
test-macOS-windows-binding:
118-
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
112+
test-linux-x64-gnu-binding:
113+
name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }}
119114
needs:
120115
- build
121116
strategy:
122117
fail-fast: false
123118
matrix:
124-
settings:
125-
- host: windows-latest
126-
target: x86_64-pc-windows-msvc
127119
node:
128120
- '12'
129121
- '14'
130122
- '16'
131-
runs-on: ${{ matrix.settings.host }}
123+
runs-on: ubuntu-latest
132124
steps:
133125
- uses: actions/checkout@v3
134126
- name: Setup node
@@ -141,31 +133,34 @@ jobs:
141133
uses: actions/cache@v2
142134
with:
143135
path: node_modules
144-
key: npm-cache-test-${{ matrix.settings.target }}-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
136+
key: npm-cache-test-linux-x64-gnu-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
145137
- name: Install dependencies
146-
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
138+
run: yarn install
147139
- name: Download artifacts
148140
uses: actions/download-artifact@v3
149141
with:
150-
name: bindings-${{ matrix.settings.target }}
142+
name: bindings-x86_64-unknown-linux-gnu
151143
path: .
152144
- name: List packages
153145
run: ls -R .
154146
shell: bash
155147
- name: Test bindings
156-
run: yarn test
157-
test-linux-x64-gnu-binding:
158-
name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }}
148+
run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim
149+
test-macOS-binding:
150+
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
159151
needs:
160152
- build
161153
strategy:
162154
fail-fast: false
163155
matrix:
156+
settings:
157+
- host: macos-latest
158+
target: x86_64-apple-darwin
164159
node:
165-
- '12'
166160
- '14'
167161
- '16'
168-
runs-on: ubuntu-latest
162+
- '18'
163+
runs-on: ${{ matrix.settings.host }}
169164
steps:
170165
- uses: actions/checkout@v3
171166
- name: Setup node
@@ -175,28 +170,28 @@ jobs:
175170
check-latest: true
176171
cache: yarn
177172
- name: Cache NPM dependencies
178-
uses: actions/cache@v2
173+
uses: actions/cache@v3
179174
with:
180-
path: node_modules
181-
key: npm-cache-test-linux-x64-gnu-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
175+
path: .yarn/cache
176+
key: npm-cache-test-${{ matrix.settings.target }}-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
182177
- name: Install dependencies
183-
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
178+
run: yarn install
184179
- name: Download artifacts
185180
uses: actions/download-artifact@v3
186181
with:
187-
name: bindings-x86_64-unknown-linux-gnu
182+
name: bindings-${{ matrix.settings.target }}
188183
path: .
189184
- name: List packages
190185
run: ls -R .
191186
shell: bash
192187
- name: Test bindings
193-
run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim yarn test
188+
run: yarn build:ts && yarn test
194189
publish:
195190
name: Publish
196191
runs-on: ubuntu-latest
197192
needs:
198-
- test-macOS-windows-binding
199193
- test-linux-x64-gnu-binding
194+
- test-macOS-binding
200195
steps:
201196
- uses: actions/checkout@v3
202197
- name: Setup node
@@ -213,7 +208,7 @@ jobs:
213208
restore-keys: |
214209
npm-cache-
215210
- name: Install dependencies
216-
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
211+
run: yarn install
217212
- name: Download all artifacts
218213
uses: actions/download-artifact@v3
219214
with:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# node-unix-socket
22

3-
`node-unix-socket` allows you to use some nonblocking sockets that are not supported by Node.js native modules, including:
3+
`node-unix-socket` allows you to use some nonblocking unix sockets that are currently not supported by Node.js native modules, including:
44

5-
- Using `SO_REUSEPORT` enabled TCP [net.Server](https://nodejs.org/dist/latest-v16.x/docs/api/net.html#class-netserver)
65
- unix seqpacket(`SOCK_SEQPACKET`) sockets
76
- unix datagram(`SOCK_DGRAM`) sockets
7+
- Using `SO_REUSEPORT` enabled TCP [net.Server](https://nodejs.org/dist/latest-v16.x/docs/api/net.html#class-netserver)
88

99
`node-unix-socket` is a [napi-rs](https://napi.rs/) based [Node.js addons](https://nodejs.org/docs/latest-v16.x/api/addons.html). This lib uses [libuv](https://libuv.org/) inside Node.js so that it won't introduce any other asynchronous runtimes.
1010

__test__/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ export function hasIPv6() {
4141
const re = isWindows ? /Loopback Pseudo-Interface/ : /lo/;
4242
return Object.keys(iFaces).some((name) => {
4343
return re.test(name) &&
44-
iFaces[name].some(({ family }) => family === 'IPv6');
44+
iFaces[name]?.some(({ family }) => family === 'IPv6');
4545
});
4646
}

js/addon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { existsSync, readFileSync } = require('fs')
1+
const { existsSync, readFileSync, statSync } = require('fs')
22
const { join } = require('path')
33

44
const { platform, arch } = process
@@ -164,7 +164,7 @@ switch (platform) {
164164
loadError = e
165165
}
166166
} else {
167-
localFileExisted = existsSync(
167+
localFileExisted = statSync(
168168
join(__dirname, '../node-unix-socket.linux-x64-gnu.node')
169169
)
170170
try {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
"description": "node-unix-socket allows you to use SO_REUSEPORT, SOCK_SEQPACKET, SOCK_DGRAM in Node.js.",
1111
"scripts": {
1212
"artifacts": "napi artifacts",
13-
"build": "napi build --platform --js false --dts js/addon.d.ts && npm run build:ts",
14-
"build:release": "napi build --platform --release --js false --dts js/addon.d.ts && npm run build:ts",
13+
"build": "npm run build:ts && napi build --platform --js false --dts js/addon.d.ts",
14+
"build:release": "npm run build:ts && napi build --platform --release --js false --dts js/addon.d.ts",
1515
"build:ts": "tsc -p tsconfig.json",
1616
"check_mem": "node --max-old-space-size=128 scripts/dgram_memory.js",
1717
"doc": "typedoc --excludePrivate --excludeInternal --excludeExternals --plugin typedoc-plugin-markdown js/index.ts",
1818
"prepublishOnly": "napi pre`publish -t npm",
19-
"test": "jest --testRegex '__test__/(.+).spec.ts' --runInBand",
19+
"test": "jest --testRegex '__test__/(.+).spec.ts' --runInBand --silent=false",
2020
"test:dumb": "TERM=dumb npm run test",
2121
"version": "napi version"
2222
},

0 commit comments

Comments
 (0)