|
| 1 | +name: npm hosted/vendored compatibility |
| 2 | + |
| 3 | +# Real npm releases (at least one per major, 6 through 12) through the |
| 4 | +# hermetic hosted (`e2e_redirect_npm_build`) and vendored |
| 5 | +# (`e2e_vendor_npm_build`) capstones, each flow ending in the manifest-less |
| 6 | +# VEX checks. Builds the CLI and both test binaries once; every matrix leg |
| 7 | +# installs one pinned npm and runs them. See docs/testing/npm-compatibility.md. |
| 8 | + |
| 9 | +on: |
| 10 | + pull_request: |
| 11 | + push: |
| 12 | + branches: [main] |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + timeout-minutes: 25 |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 24 | + with: |
| 25 | + persist-credentials: false |
| 26 | + - name: Compile CLI and npm capstones once |
| 27 | + run: | |
| 28 | + cargo test --locked -p socket-patch-cli --test e2e_redirect_npm_build --test e2e_vendor_npm_build --no-run --message-format=json > target-build.json |
| 29 | + python3 - <<'PY' |
| 30 | + import json, pathlib, shutil |
| 31 | + dest = pathlib.Path('target/npm-e2e'); dest.mkdir(parents=True, exist_ok=True) |
| 32 | + shutil.copy2('target/debug/socket-patch', dest / 'socket-patch') |
| 33 | + for line in pathlib.Path('target-build.json').read_text().splitlines(): |
| 34 | + item = json.loads(line) |
| 35 | + name = item.get('target', {}).get('name') |
| 36 | + if name in ('e2e_redirect_npm_build', 'e2e_vendor_npm_build') and item.get('executable'): |
| 37 | + shutil.copy2(item['executable'], dest / name) |
| 38 | + assert all((dest / n).is_file() for n in ('e2e_redirect_npm_build', 'e2e_vendor_npm_build')) |
| 39 | + PY |
| 40 | + - uses: ./.github/actions/upload-artifact |
| 41 | + with: |
| 42 | + name: npm-e2e |
| 43 | + path: target/npm-e2e/ |
| 44 | + if-no-files-found: error |
| 45 | + retention-days: 7 |
| 46 | + |
| 47 | + install-proof: |
| 48 | + needs: build |
| 49 | + runs-on: ubuntu-latest |
| 50 | + timeout-minutes: 25 |
| 51 | + strategy: |
| 52 | + fail-fast: false |
| 53 | + matrix: |
| 54 | + include: |
| 55 | + # node 16's bundled npm 8 writes the v2 lock for the npm 6 x v2 test. |
| 56 | + - {npm: '6.14.18', node: '16.20.2'} |
| 57 | + - {npm: '7.0.0', node: '16.20.2'} |
| 58 | + - {npm: '7.24.2', node: '16.20.2'} |
| 59 | + - {npm: '8.19.4', node: '16.20.2'} |
| 60 | + - {npm: '9.0.0', node: '18.20.8'} |
| 61 | + - {npm: '9.9.4', node: '18.20.8'} |
| 62 | + - {npm: '10.9.9', node: '22.22.2'} |
| 63 | + - {npm: '11.20.0', node: '24.11.1'} |
| 64 | + - {npm: '12.0.0', node: '24.15.0'} |
| 65 | + - {npm: '12.1.0', node: '24.15.0'} |
| 66 | + steps: |
| 67 | + # Same workspace path as the build job, so the socket-patch path |
| 68 | + # compiled into the tests (CARGO_BIN_EXE_socket-patch) resolves. |
| 69 | + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 |
| 70 | + with: |
| 71 | + pattern: npm-e2e* |
| 72 | + merge-multiple: true |
| 73 | + path: target/debug |
| 74 | + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 75 | + with: |
| 76 | + node-version: '24.11.1' |
| 77 | + - name: Install the pinned npm |
| 78 | + env: |
| 79 | + NPM_TEST_VERSION: ${{ matrix.npm }} |
| 80 | + run: | |
| 81 | + npm install --prefix "$RUNNER_TEMP/npm-tool" --no-audit --no-fund "npm@$NPM_TEST_VERSION" |
| 82 | + echo "SOCKET_PATCH_NPM_E2E_BIN=$RUNNER_TEMP/npm-tool/node_modules/.bin/npm" >> "$GITHUB_ENV" |
| 83 | + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 84 | + with: |
| 85 | + node-version: ${{ matrix.node }} |
| 86 | + - name: Hosted + vendored installs, manifest-less VEX |
| 87 | + env: |
| 88 | + SOCKET_PATCH_NPM_E2E_VERSION: ${{ matrix.npm }} |
| 89 | + SOCKET_PATCH_NPM_E2E_REQUIRED: '1' |
| 90 | + SOCKET_NO_CONFIG: '1' |
| 91 | + SOCKET_NO_UPDATE_CHECK: '1' |
| 92 | + run: | |
| 93 | + chmod +x target/debug/socket-patch target/debug/e2e_redirect_npm_build target/debug/e2e_vendor_npm_build |
| 94 | + target/debug/e2e_redirect_npm_build --include-ignored --test-threads 4 |
| 95 | + target/debug/e2e_vendor_npm_build --include-ignored --test-threads 4 |
0 commit comments