Skip to content

Commit 1554c99

Browse files
committed
ci: remove native packages from tests
1 parent 20ce19e commit 1554c99

File tree

8 files changed

+180
-25
lines changed

8 files changed

+180
-25
lines changed

.github/workflows/ci.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
key: stable-${{ matrix.os }}-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
5757

5858
- name: 'Install dependencies'
59-
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
59+
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
6060

6161
- name: Cargo test
6262
uses: actions-rs/cargo@v1
@@ -105,7 +105,7 @@ jobs:
105105
key: npm-cache-windows-i686-node@lts-${{ hashFiles('yarn.lock') }}
106106

107107
- name: Install dependencies
108-
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
108+
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
109109

110110
- name: Build TypeScript
111111
run: yarn build:ts
@@ -195,7 +195,7 @@ jobs:
195195
docker tag ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine builder
196196
197197
- name: 'Install dependencies'
198-
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
198+
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
199199

200200
- name: 'Build'
201201
run: |
@@ -260,7 +260,7 @@ jobs:
260260
sudo apt-get update
261261
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y
262262
- name: Install dependencies
263-
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
263+
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
264264

265265
- name: Cross build aarch64
266266
run: yarn build -- -- --target aarch64-unknown-linux-gnu
@@ -325,7 +325,7 @@ jobs:
325325
sudo apt-get install gcc-aarch64-linux-gnu -y
326326
327327
- name: Install dependencies
328-
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
328+
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
329329

330330
- name: Cross build aarch64
331331
run: yarn build -- -- --target aarch64-unknown-linux-musl
@@ -399,7 +399,7 @@ jobs:
399399
sudo apt-get update
400400
sudo apt-get install gcc-arm-linux-gnueabihf -y
401401
- name: Install dependencies
402-
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
402+
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
403403

404404
- name: Cross build arm7
405405
run: yarn build -- -- --target armv7-unknown-linux-gnueabihf
@@ -457,7 +457,7 @@ jobs:
457457
key: npm-cache-apple-aarch64-node@14-${{ hashFiles('yarn.lock') }}
458458

459459
- name: Install dependencies
460-
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
460+
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
461461

462462
- name: Cross build aarch64
463463
run: yarn build -- -- --target aarch64-apple-darwin
@@ -506,7 +506,7 @@ jobs:
506506
key: npm-cache-apple-aarch64-node@14-${{ hashFiles('yarn.lock') }}
507507

508508
- name: Install dependencies
509-
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
509+
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
510510

511511
- name: Build
512512
shell: bash
@@ -555,10 +555,12 @@ jobs:
555555
whoami
556556
env
557557
freebsd-version
558-
yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
558+
yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
559559
yarn build:ts
560560
yarn build
561561
yarn test
562+
rm -rf node_modules
563+
rm -rf target
562564
563565
- name: Upload artifact
564566
uses: actions/upload-artifact@v2
@@ -588,7 +590,7 @@ jobs:
588590

589591
# Do not cache node_modules, or yarn workspace links broken
590592
- name: 'Install dependencies'
591-
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
593+
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
592594

593595
- name: Build TypeScript
594596
run: yarn build:ts
@@ -674,7 +676,7 @@ jobs:
674676
key: npm-cache-test-aarch64-linux-node@${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
675677

676678
- name: 'Install dependencies'
677-
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
679+
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
678680

679681
- name: Build TypeScript
680682
run: yarn build:ts
@@ -732,7 +734,7 @@ jobs:
732734
key: npm-cache-ubuntu-latest-publish-${{ hashFiles('yarn.lock') }}
733735

734736
- name: 'Install dependencies'
735-
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
737+
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
736738

737739
- name: Download all artifacts
738740
uses: actions/download-artifact@v2

packages/bcrypt/__tests__/bcrypt.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import test from 'ava'
22

33
import { verifySync, hash } from '../index'
44

5-
const { hashSync } = require('bcrypt')
5+
const { hashSync } = require('bcryptjs')
66

77
const fx = Buffer.from('bcrypt-test-password')
88

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Snapshot report for `packages/crc32/__tests__/index.spec.ts`
2+
3+
The actual snapshot is saved in `index.spec.ts.snap`.
4+
5+
Generated by [AVA](https://avajs.dev).
6+
7+
## crc32c result should be equal with sse4_crc32
8+
9+
> Snapshot 1
10+
11+
2608757237
12+
13+
## crc32c result should be equal with sse4_crc32 when caclulate with initial crc
14+
15+
> Snapshot 1
16+
17+
614479218
126 Bytes
Binary file not shown.

packages/crc32/__tests__/index.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@ import { crc32 as nodeCrc32 } from 'crc'
33

44
import { crc32c, crc32 } from '../index'
55

6-
const { calculate } = require('sse4_crc32')
7-
86
const fx = Buffer.from('crc32c - test')
97

108
test('crc32c result should be equal with sse4_crc32', (t) => {
11-
t.is(crc32c(fx), calculate(fx))
9+
t.snapshot(crc32c(fx))
1210
})
1311

1412
test('crc32c result should be equal with sse4_crc32 when caclulate with initial crc', (t) => {
1513
const initialCrc = crc32c(fx)
16-
t.is(crc32c(fx, initialCrc), calculate(fx, initialCrc))
14+
t.snapshot(crc32c(fx, initialCrc))
1715
})
1816

1917
test('crc32 result should be equal with crc32 node', (t) => {
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Snapshot report for `packages/jieba/__tests__/jieba.spec.ts`
2+
3+
The actual snapshot is saved in `jieba.spec.ts.snap`.
4+
5+
Generated by [AVA](https://avajs.dev).
6+
7+
## cut result should be equal to nodejieba
8+
9+
> Snapshot 1
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+
## tag result shoule be equal to nodejieba
36+
37+
> Snapshot 1
38+
39+
[
40+
{
41+
tag: 'r',
42+
word: '我',
43+
},
44+
{
45+
tag: 'v',
46+
word: '是',
47+
},
48+
{
49+
tag: 'n',
50+
word: '拖拉机',
51+
},
52+
{
53+
tag: 'n',
54+
word: '学院',
55+
},
56+
{
57+
tag: 'n',
58+
word: '手扶拖拉机',
59+
},
60+
{
61+
tag: 'n',
62+
word: '专业',
63+
},
64+
{
65+
tag: 'uj',
66+
word: '的',
67+
},
68+
{
69+
tag: 'x',
70+
word: '。',
71+
},
72+
{
73+
tag: 'v',
74+
word: '不用',
75+
},
76+
{
77+
tag: 'm',
78+
word: '多久',
79+
},
80+
{
81+
tag: 'x',
82+
word: ',',
83+
},
84+
{
85+
tag: 'r',
86+
word: '我',
87+
},
88+
{
89+
tag: 'd',
90+
word: '就',
91+
},
92+
{
93+
tag: 'v',
94+
word: '会',
95+
},
96+
{
97+
tag: 'v',
98+
word: '升职',
99+
},
100+
{
101+
tag: 'nr',
102+
word: '加薪',
103+
},
104+
{
105+
tag: 'x',
106+
word: ',',
107+
},
108+
{
109+
tag: 'v',
110+
word: '走上',
111+
},
112+
{
113+
tag: 'n',
114+
word: '人生',
115+
},
116+
{
117+
tag: 'n',
118+
word: '巅峰',
119+
},
120+
{
121+
tag: 'x',
122+
word: '。',
123+
},
124+
]
125+
126+
## extract should be equal to nodejieba
127+
128+
> Snapshot 1
129+
130+
[
131+
{
132+
keyword: '北京烤鸭',
133+
weight: 'number',
134+
},
135+
{
136+
keyword: '纽约',
137+
weight: 'number',
138+
},
139+
{
140+
keyword: '天气',
141+
weight: 'number',
142+
},
143+
]
1.03 KB
Binary file not shown.
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
import test from 'ava'
2-
import * as nodejieba from 'nodejieba'
32

43
import { cut, tag, extract } from '../index'
54

65
const sentence = '我是拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,走上人生巅峰。'
76

87
test('cut result should be equal to nodejieba', (t) => {
9-
t.deepEqual(cut(sentence).join(''), nodejieba.cut(sentence).join(''))
8+
t.snapshot(cut(sentence))
109
})
1110

1211
test('tag result shoule be equal to nodejieba', (t) => {
13-
t.deepEqual(tag(sentence), nodejieba.tag(sentence))
12+
t.snapshot(tag(sentence))
1413
})
1514

1615
test('extract should be equal to nodejieba', (t) => {
1716
const sentence =
1817
'今天纽约的天气真好啊,京华大酒店的张尧经理吃了一只北京烤鸭。后天纽约的天气不好,昨天纽约的天气也不好,北京烤鸭真好吃'
1918
const topn = 3
20-
t.deepEqual(
19+
t.snapshot(
2120
extract(sentence, topn).map((t) => ({
2221
keyword: t.keyword,
2322
weight: typeof t.weight,
2423
})),
25-
nodejieba.extract(sentence, topn).map((t) => ({
26-
keyword: t.word,
27-
weight: typeof t.weight,
28-
})),
2924
)
3025
})

0 commit comments

Comments
 (0)