Skip to content

Commit 5993209

Browse files
committed
add a post-publish test of the npm package
1 parent 4b87a36 commit 5993209

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

.github/workflows/test-package.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Test npm package
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Package version to test"
8+
required: true
9+
10+
jobs:
11+
test_npm_binaries:
12+
runs-on: ${{ matrix.platforms }}
13+
14+
strategy:
15+
matrix:
16+
platforms: [ubuntu-latest, windows-2019, macos-11]
17+
node-version: [14.x, 16.x, 18.x]
18+
19+
steps:
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
- run: npm i -g npm@latest
25+
- name: Set up the unit tests
26+
run: |
27+
curl https://codeload.github.com/mmomtchev/pymport/zip/refs/tags/v${{ github.event.inputs.version }} --output repo.zip
28+
unzip repo.zip
29+
mv pymport-${{ github.event.inputs.version }}/package.json .
30+
mv pymport-${{ github.event.inputs.version }}/test .
31+
npm install
32+
- name: Install from npm
33+
run: npm install --force pymport@${{ github.event.inputs.version }}
34+
- name: Run the unit tests
35+
run: |
36+
cd test
37+
npx mocha --reporter=tap -r ts-node/register -r tsconfig-paths/register --timeout 20000 --v8-expose-gc *.test.ts
38+
env:
39+
TS_NODE_PROJECT: tsconfig.test.json
40+
MOCHA_SKIP_EXEC: 1
41+
42+
test_npm_rebuild:
43+
runs-on: ${{ matrix.platforms }}
44+
45+
strategy:
46+
matrix:
47+
platforms: [ubuntu-latest, windows-2019, macos-11]
48+
node-version: [14.x, 16.x, 18.x]
49+
50+
steps:
51+
- name: Use Node.js ${{ matrix.node-version }}
52+
uses: actions/setup-node@v1
53+
with:
54+
node-version: ${{ matrix.node-version }}
55+
- run: npm i -g npm@latest
56+
- name: Set up the unit tests
57+
run: |
58+
curl https://codeload.github.com/mmomtchev/pymport/zip/refs/tags/v${{ github.event.inputs.version }} --output repo.zip
59+
unzip repo.zip
60+
mv pymport-${{ github.event.inputs.version }}/package.json .
61+
mv pymport-${{ github.event.inputs.version }}/test .
62+
npm install
63+
- name: Rebuild with npm
64+
run: npm install --verbose --force pymport@${{ github.event.inputs.version }} --build-from-source
65+
- name: Run the unit tests
66+
run: |
67+
cd test
68+
npx mocha --reporter=tap -r ts-node/register -r tsconfig-paths/register --timeout 20000 --v8-expose-gc *.test.ts
69+
env:
70+
TS_NODE_PROJECT: tsconfig.test.json
71+
MOCHA_SKIP_EXEC: 1

test/mapbox-node-pre-gyp.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module '@mapbox/node-pre-gyp' {
2+
export function find(dir: string): string;
3+
}

test/tsconfig.test.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"esModuleInterop": true,
4+
"strict": true,
5+
"strictNullChecks": true,
6+
"baseUrl": ".",
7+
"paths": {
8+
"@mapbox/node-pre-gyp": [
9+
"./mapbox-node-pre-gyp"
10+
]
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)