Skip to content

Commit f759e4d

Browse files
committed
feat!: use .npmignore file to limit which files are published (#2921)
* feat!: use package.json files to limit which files are published Fixes: #2372 * Use npmignore instead of package.json#files * Add update-gyp.py to npmignore * Add install to pack test * Use output var for pack dir * Move existing .gitignore entries to .npmignore * Sort git and npm ignores * Update and cleanup workflows
1 parent 73c3287 commit f759e4d

File tree

4 files changed

+76
-29
lines changed

4 files changed

+76
-29
lines changed

.github/workflows/tests.yml

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
2-
# TODO: Line 48, enable pytest --doctest-modules
2+
# TODO: add `python -m pytest --doctest-modules`
33

44
name: Tests
55
on:
@@ -12,44 +12,82 @@ permissions:
1212
contents: read # to fetch code (actions/checkout)
1313

1414
jobs:
15-
Lint_Python:
15+
lint-python:
16+
name: Lint Python
1617
runs-on: ubuntu-latest
1718
steps:
1819
- uses: actions/checkout@v4
1920
- run: pip install --user ruff
2021
- run: ruff --output-format=github --select="E,F,PLC,PLE,UP,W,YTT" --ignore="E721,PLC1901,S101,UP031" --target-version=py38 .
21-
Lint_JS:
22+
23+
lint-js:
24+
name: Lint JS
2225
runs-on: ubuntu-latest
2326
steps:
2427
- name: Checkout Repository
2528
uses: actions/checkout@v4
2629
- name: Use Node.js 20.x
27-
uses: actions/setup-node@v3
30+
uses: actions/setup-node@v4
2831
with:
2932
node-version: 20.x
3033
- name: Install Dependencies
31-
run: npm install --no-progress
34+
run: npm install
3235
- name: Lint
3336
run: npm run lint
34-
Engines:
37+
38+
check-engines:
39+
name: Check Engines
3540
runs-on: ubuntu-latest
3641
steps:
3742
- name: Checkout Repository
3843
uses: actions/checkout@v4
3944
- name: Use Node.js 20.x
40-
uses: actions/setup-node@v3
45+
uses: actions/setup-node@v4
4146
with:
4247
node-version: 20.x
4348
- name: Install Dependencies
44-
run: |
45-
npm install --no-progress
49+
run: npm install
4650
- name: Check Engines
4751
run: |
4852
# TODO: move this to its own action
4953
npm install @npmcli/arborist@7 semver@7 --no-save
5054
node .github/scripts/check-engines.js
51-
Tests:
52-
needs: Lint_Python # Lint_Python takes ~5 seconds, so wait for it to pass before running the full matrix of tests.
55+
56+
test-pack:
57+
name: Test Pack
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout Repository
61+
uses: actions/checkout@v4
62+
- name: Use Node.js 20.x
63+
uses: actions/setup-node@v4
64+
with:
65+
node-version: 20.x
66+
- name: Update npm
67+
run: npm install npm@latest -g
68+
- name: Install Dependencies
69+
run: npm install
70+
- name: Pack
71+
id: pack
72+
env:
73+
NODE_GYP_TEMP_DIR: '${{ runner.temp }}/node-gyp'
74+
run: |
75+
mkdir -p $NODE_GYP_TEMP_DIR
76+
npm pack
77+
tar xzf *.tgz -C $NODE_GYP_TEMP_DIR --strip-components=1
78+
cp -r test/ $NODE_GYP_TEMP_DIR/test/
79+
echo "dir=$NODE_GYP_TEMP_DIR" >> "$GITHUB_OUTPUT"
80+
- name: Test
81+
working-directory: ${{ steps.pack.outputs.dir }}
82+
env:
83+
FULL_TEST: '1'
84+
run: |
85+
npm install
86+
npm test
87+
88+
tests:
89+
# lint-python takes ~5 seconds, so wait for it to pass before running the full matrix of tests.
90+
needs: [lint-python]
5391
strategy:
5492
fail-fast: false
5593
max-parallel: 15
@@ -63,7 +101,7 @@ jobs:
63101
- name: Checkout Repository
64102
uses: actions/checkout@v4
65103
- name: Use Node.js ${{ matrix.node }}
66-
uses: actions/setup-node@v3
104+
uses: actions/setup-node@v4
67105
with:
68106
node-version: ${{ matrix.node }}
69107
- name: Use Python ${{ matrix.python }}
@@ -74,26 +112,22 @@ jobs:
74112
PYTHON_VERSION: ${{ matrix.python }} # Why do this?
75113
- name: Install Dependencies
76114
run: |
77-
npm install --no-progress
115+
npm install
78116
pip install pytest
79-
- name: Set Windows environment
80-
if: matrix.os == 'windows'
117+
- name: Set Windows Env
118+
if: runner.os == 'Windows'
81119
run: |
82120
echo 'GYP_MSVS_VERSION=2015' >> $Env:GITHUB_ENV
83121
echo 'GYP_MSVS_OVERRIDE_PATH=C:\\Dummy' >> $Env:GITHUB_ENV
84-
- name: Run Python tests
122+
- name: Run Python Tests
85123
run: python -m pytest
86-
# - name: Run doctests with pytest
87-
# run: python -m pytest --doctest-modules
88-
- name: Environment Information
89-
run: npx envinfo
90-
- name: Run Node tests (macOS or Linux)
124+
- name: Run Tests (macOS or Linux)
91125
if: runner.os != 'Windows'
92126
shell: bash
93127
run: npm test --python="${pythonLocation}/python"
94128
env:
95129
FULL_TEST: ${{ (matrix.node == '20.x' && matrix.python == '3.12') && '1' || '0' }}
96-
- name: Run tests (Windows)
130+
- name: Run Tests (Windows)
97131
if: runner.os == 'Windows'
98132
shell: pwsh
99133
run: npm run test --python="${env:pythonLocation}\\python.exe"

.github/workflows/visual-studio.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ jobs:
2626
- name: Checkout Repository
2727
uses: actions/checkout@v4
2828
- name: Install Dependencies
29-
run: |
30-
npm install --no-progress
31-
- name: Environment Information
32-
run: npx envinfo
29+
run: npm install
3330
- name: Run Node tests
3431
shell: pwsh
3532
run: |

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
.ncu
2+
.nyc_output
13
*.swp
24
gyp/test
35
node_modules
4-
test/.node-gyp
5-
.ncu
6-
.nyc_output
6+
node-gyp-*.tgz
77
package-lock.json
8+
test/.node-gyp

.npmignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.ncu
2+
.nyc_output
3+
*.swp
4+
/.github/
5+
/docs/
6+
/gyp/.github/
7+
/gyp/*.md
8+
/gyp/AUTHORS
9+
/gyp/test
10+
/gyp/tools/
11+
/node-gyp-*.tgz
12+
/test/
13+
/test/.node-gyp
14+
/update-gyp.py
15+
node-gyp-*.tgz

0 commit comments

Comments
 (0)