From 2e6cd134c30a5c7d6a03409674e7edf87f2494c4 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Fri, 27 Oct 2023 11:27:28 -0700 Subject: [PATCH 1/8] feat!: use package.json files to limit which files are published Fixes: #2372 --- package.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/package.json b/package.json index dadbf1d25a..e89b8314b3 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,20 @@ "preferGlobal": true, "bin": "./bin/node-gyp.js", "main": "./lib/node-gyp.js", + "files": [ + "/bin/", + "!/gyp/", + "/gyp/data/", + "/gyp/pylib/", + "/gyp/gyp", + "/gyp/gyp_main.py", + "/gyp.bat", + "/gyp/gyp", + "/lib/", + "/src/", + "/addon.gypi", + "macOS_Cataline_acid_test.sh" + ], "dependencies": { "env-paths": "^2.2.0", "exponential-backoff": "^3.1.1", From 719959b24583e99d6854b8260a93216354f61b5a Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Sat, 28 Oct 2023 14:13:43 -0700 Subject: [PATCH 2/8] Use npmignore instead of package.json#files --- .github/workflows/tests.yml | 23 +++++++++++++++++++++++ .npmignore | 8 ++++++++ package.json | 14 -------------- 3 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 .npmignore diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4aa041df9e..34eafd1804 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,6 +48,29 @@ jobs: # TODO: move this to its own action npm install @npmcli/arborist@7 semver@7 --no-save node .github/scripts/check-engines.js + Pack_Test: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Use Node.js 20.x + uses: actions/setup-node@v3 + with: + node-version: 20.x + - name: Update npm + run: npm install npm@latest -g + - name: Install Dependencies + run: npm install --no-progress + - name: Pack + run: | + DIR=${{ runner.temp }}/node-gyp + mkdir -p $DIR + npm pack + tar xzf *.tgz -C $DIR --strip-components=1 + cp -r test/ $DIR/test/ + - name: Test + run: npm test + working-directory: ${{ runner.temp }}/node-gyp Tests: needs: Lint_Python # Lint_Python takes ~5 seconds, so wait for it to pass before running the full matrix of tests. strategy: diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000000..100a9c0f2c --- /dev/null +++ b/.npmignore @@ -0,0 +1,8 @@ +/.github/ +/docs/ +/gyp/.github/ +/gyp/tools/ +/gyp/*.md +/gyp/AUTHORS +/test/ +*.tgz diff --git a/package.json b/package.json index e89b8314b3..dadbf1d25a 100644 --- a/package.json +++ b/package.json @@ -21,20 +21,6 @@ "preferGlobal": true, "bin": "./bin/node-gyp.js", "main": "./lib/node-gyp.js", - "files": [ - "/bin/", - "!/gyp/", - "/gyp/data/", - "/gyp/pylib/", - "/gyp/gyp", - "/gyp/gyp_main.py", - "/gyp.bat", - "/gyp/gyp", - "/lib/", - "/src/", - "/addon.gypi", - "macOS_Cataline_acid_test.sh" - ], "dependencies": { "env-paths": "^2.2.0", "exponential-backoff": "^3.1.1", From a9cb7ba564db87a0f52781ffe7dbf44c5f7ee27c Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Sat, 28 Oct 2023 14:26:44 -0700 Subject: [PATCH 3/8] Add update-gyp.py to npmignore --- .gitignore | 1 + .npmignore | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e906ca7280..6a3bf3f380 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ test/.node-gyp .ncu .nyc_output package-lock.json +node-gyp-*.tgz diff --git a/.npmignore b/.npmignore index 100a9c0f2c..193787ddb9 100644 --- a/.npmignore +++ b/.npmignore @@ -1,8 +1,9 @@ /.github/ /docs/ /gyp/.github/ -/gyp/tools/ /gyp/*.md /gyp/AUTHORS +/gyp/tools/ +/node-gyp-*.tgz /test/ -*.tgz +/update-gyp.py From b7b806e1346f28aa2850740c113c8d52ef8b82f0 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Sat, 28 Oct 2023 14:27:13 -0700 Subject: [PATCH 4/8] Add install to pack test --- .github/workflows/tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 34eafd1804..d07552410a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -69,7 +69,9 @@ jobs: tar xzf *.tgz -C $DIR --strip-components=1 cp -r test/ $DIR/test/ - name: Test - run: npm test + run: | + npm install --no-progress + npm test working-directory: ${{ runner.temp }}/node-gyp Tests: needs: Lint_Python # Lint_Python takes ~5 seconds, so wait for it to pass before running the full matrix of tests. From b4aabcd6009d68e650f8fb3c6c5e526522c61c9e Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Sat, 28 Oct 2023 14:35:06 -0700 Subject: [PATCH 5/8] Use output var for pack dir --- .github/workflows/tests.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d07552410a..d629e58f9c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -62,17 +62,22 @@ jobs: - name: Install Dependencies run: npm install --no-progress - name: Pack + id: pack + env: + NODE_GYP_TEMP_DIR: '${{ runner.temp }}/node-gyp' run: | - DIR=${{ runner.temp }}/node-gyp - mkdir -p $DIR + mkdir -p $NODE_GYP_TEMP_DIR npm pack - tar xzf *.tgz -C $DIR --strip-components=1 - cp -r test/ $DIR/test/ + tar xzf *.tgz -C $NODE_GYP_TEMP_DIR --strip-components=1 + cp -r test/ $NODE_GYP_TEMP_DIR/test/ + echo "dir=$NODE_GYP_TEMP_DIR" >> "$GITHUB_OUTPUT" - name: Test + working-directory: ${{ steps.pack.outputs.dir }} + env: + FULL_TEST: '1' run: | npm install --no-progress npm test - working-directory: ${{ runner.temp }}/node-gyp Tests: needs: Lint_Python # Lint_Python takes ~5 seconds, so wait for it to pass before running the full matrix of tests. strategy: From e90b9fc47084958f615aefc6eb0656af9b7a6953 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Sat, 28 Oct 2023 14:53:44 -0700 Subject: [PATCH 6/8] Move existing .gitignore entries to .npmignore --- .npmignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.npmignore b/.npmignore index 193787ddb9..57e9d28d89 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,7 @@ +*.swp +.ncu +.nyc_output +node-gyp-*.tgz /.github/ /docs/ /gyp/.github/ @@ -7,3 +11,5 @@ /node-gyp-*.tgz /test/ /update-gyp.py +/gyp/test +/test/.node-gyp From 69d3e8e08aad07982eba56d4acb6a3d84d1ad847 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Sat, 28 Oct 2023 15:17:24 -0700 Subject: [PATCH 7/8] Sort git and npm ignores --- .gitignore | 8 ++++---- .npmignore | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 6a3bf3f380..e588699b7a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ +.ncu +.nyc_output *.swp gyp/test node_modules -test/.node-gyp -.ncu -.nyc_output -package-lock.json node-gyp-*.tgz +package-lock.json +test/.node-gyp diff --git a/.npmignore b/.npmignore index 57e9d28d89..8f95594d44 100644 --- a/.npmignore +++ b/.npmignore @@ -1,15 +1,15 @@ -*.swp .ncu .nyc_output -node-gyp-*.tgz +*.swp /.github/ /docs/ /gyp/.github/ /gyp/*.md /gyp/AUTHORS +/gyp/test /gyp/tools/ /node-gyp-*.tgz /test/ -/update-gyp.py -/gyp/test /test/.node-gyp +/update-gyp.py +node-gyp-*.tgz From 958d7c581559d7b642feefe29523a2cc136c58aa Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Sat, 28 Oct 2023 15:17:55 -0700 Subject: [PATCH 8/8] Update and cleanup workflows --- .github/workflows/tests.yml | 58 +++++++++++++++-------------- .github/workflows/visual-studio.yml | 5 +-- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d629e58f9c..fde4aacfc1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,5 +1,5 @@ # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources -# TODO: Line 48, enable pytest --doctest-modules +# TODO: add `python -m pytest --doctest-modules` name: Tests on: @@ -12,55 +12,61 @@ permissions: contents: read # to fetch code (actions/checkout) jobs: - Lint_Python: + lint-python: + name: Lint Python runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: pip install --user ruff - run: ruff --output-format=github --select="E,F,PLC,PLE,UP,W,YTT" --ignore="E721,PLC1901,S101,UP031" --target-version=py38 . - Lint_JS: + + lint-js: + name: Lint JS runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v4 - name: Use Node.js 20.x - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 20.x - name: Install Dependencies - run: npm install --no-progress + run: npm install - name: Lint run: npm run lint - Engines: + + check-engines: + name: Check Engines runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v4 - name: Use Node.js 20.x - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 20.x - name: Install Dependencies - run: | - npm install --no-progress + run: npm install - name: Check Engines run: | # TODO: move this to its own action npm install @npmcli/arborist@7 semver@7 --no-save node .github/scripts/check-engines.js - Pack_Test: + + test-pack: + name: Test Pack runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Use Node.js 20.x - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 20.x - name: Update npm run: npm install npm@latest -g - name: Install Dependencies - run: npm install --no-progress + run: npm install - name: Pack id: pack env: @@ -76,10 +82,12 @@ jobs: env: FULL_TEST: '1' run: | - npm install --no-progress + npm install npm test - Tests: - needs: Lint_Python # Lint_Python takes ~5 seconds, so wait for it to pass before running the full matrix of tests. + + tests: + # lint-python takes ~5 seconds, so wait for it to pass before running the full matrix of tests. + needs: [lint-python] strategy: fail-fast: false max-parallel: 15 @@ -93,7 +101,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - name: Use Python ${{ matrix.python }} @@ -104,26 +112,22 @@ jobs: PYTHON_VERSION: ${{ matrix.python }} # Why do this? - name: Install Dependencies run: | - npm install --no-progress + npm install pip install pytest - - name: Set Windows environment - if: matrix.os == 'windows' + - name: Set Windows Env + if: runner.os == 'Windows' run: | echo 'GYP_MSVS_VERSION=2015' >> $Env:GITHUB_ENV echo 'GYP_MSVS_OVERRIDE_PATH=C:\\Dummy' >> $Env:GITHUB_ENV - - name: Run Python tests + - name: Run Python Tests run: python -m pytest - # - name: Run doctests with pytest - # run: python -m pytest --doctest-modules - - name: Environment Information - run: npx envinfo - - name: Run Node tests (macOS or Linux) + - name: Run Tests (macOS or Linux) if: runner.os != 'Windows' shell: bash run: npm test --python="${pythonLocation}/python" env: FULL_TEST: ${{ (matrix.node == '20.x' && matrix.python == '3.12') && '1' || '0' }} - - name: Run tests (Windows) + - name: Run Tests (Windows) if: runner.os == 'Windows' shell: pwsh run: npm run test --python="${env:pythonLocation}\\python.exe" diff --git a/.github/workflows/visual-studio.yml b/.github/workflows/visual-studio.yml index 8b796256da..19993a57f9 100644 --- a/.github/workflows/visual-studio.yml +++ b/.github/workflows/visual-studio.yml @@ -26,10 +26,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - name: Install Dependencies - run: | - npm install --no-progress - - name: Environment Information - run: npx envinfo + run: npm install - name: Run Node tests shell: pwsh run: |