Skip to content

Commit d57fcba

Browse files
bschnurrCopilot
andauthored
Route package installs through Microsoft feed proxies (#1125)
* Route package installs through Microsoft feed proxies Port vscode-isort setup, lockfile normalization, GitHub CI, and DevDiv release feed routing while preserving public Dependabot registries and legacy Azure pipeline definitions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e2972852-17e2-4e68-81e8-db73c74bfe25 * Remove redundant npm registry overrides from CI workflows Let ci:msft explicitly select the npm proxy in PR and push workflows. Retain the Python index and registry configuration for CodeQL/Azure consumers, and add regression coverage and documentation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e2972852-17e2-4e68-81e8-db73c74bfe25 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e2972852-17e2-4e68-81e8-db73c74bfe25
1 parent 44a63c8 commit d57fcba

21 files changed

Lines changed: 1003 additions & 18 deletions

‎.eslintrc.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
"no-throw-literal": "warn",
1717
"semi": "off"
1818
},
19+
"overrides": [
20+
{
21+
"files": ["build/setup*.js", "build/normalize-package-lock*.js"],
22+
"env": { "node": true, "es2022": true },
23+
"parserOptions": { "ecmaVersion": 2022, "sourceType": "script" },
24+
"rules": { "@typescript-eslint/naming-convention": "off" }
25+
}
26+
],
1927
"ignorePatterns": [
2028
"out",
2129
"dist",

‎.githooks/.gitattributes‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pre-commit text eol=lf

‎.githooks/pre-commit‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License.
4+
5+
exec node build/normalize-package-lock.js --staged

‎.github/actions/build-vsix/action.yml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ runs:
3535
run: python -m pip install -U pip pipx wheel
3636
shell: bash
3737

38-
- name: Run npm ci
39-
run: npm ci --prefer-offline
38+
- name: Install Node dependencies through Microsoft feeds
39+
run: npm run ci:msft
40+
env:
41+
npm_config_prefer_offline: 'true'
4042
shell: bash
4143

4244
- name: Install bundled python libraries

‎.github/actions/lint/action.yml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ runs:
1515
node-version: ${{ inputs.node_version }}
1616
cache: 'npm'
1717

18+
- name: Test setup and hook scripts (no dependencies required)
19+
run: npm run test:setup
20+
shell: bash
21+
1822
- name: Install Node dependencies
19-
run: npm ci
23+
run: npm run ci:msft
2024
shell: bash
2125

2226
- name: Lint TypeScript code

‎.github/workflows/codeql-analysis.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ on:
2020
schedule:
2121
- cron: '15 16 * * 2'
2222

23+
env:
24+
NPM_CONFIG_REGISTRY: https://packagefeedproxy.microsoft.io/npm/
25+
PIP_INDEX_URL: https://packagefeedproxy.microsoft.io/pypi/simple/
26+
2327
jobs:
2428
analyze:
2529
name: Analyze

‎.github/workflows/pr-check.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
permissions: {}
77

88
env:
9+
PIP_INDEX_URL: https://packagefeedproxy.microsoft.io/pypi/simple/
910
NODE_VERSION: 22.17.0
1011
TEST_RESULTS_DIRECTORY: .
1112
# Force a path with spaces and unicode chars to test extension works in these scenarios
@@ -84,7 +85,7 @@ jobs:
8485
cache-dependency-path: ${{ env.special-working-directory-relative }}/package-lock.json
8586

8687
- name: Install dependencies (npm ci)
87-
run: npm ci
88+
run: npm run ci:msft
8889

8990
# Now that the bundle is installed to target using python 3.9
9091
# switch back the python we want to test with

‎.github/workflows/push-check.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
permissions: {}
1212

1313
env:
14+
PIP_INDEX_URL: https://packagefeedproxy.microsoft.io/pypi/simple/
1415
NODE_VERSION: 22.17.0
1516
TEST_RESULTS_DIRECTORY: .
1617
# Force a path with spaces and unicode chars to test extension works in these scenarios
@@ -89,7 +90,7 @@ jobs:
8990
cache-dependency-path: ${{ env.special-working-directory-relative }}/package-lock.json
9091

9192
- name: Install dependencies (npm ci)
92-
run: npm ci
93+
run: npm run ci:msft
9394

9495
# Now that the bundle is installed to target using python 3.9
9596
# switch back the python we want to test with

‎README.md‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,81 @@ You can reference the table below to find the most recent Python Debugger extens
5454

5555
## Data and telemetry
5656
The Debugpy Extension for Visual Studio Code collects usage data and sends it to Microsoft to help improve our products and services. Read our [privacy statement](https://privacy.microsoft.com/privacystatement) to learn more. This extension respects the `telemetry.telemetryLevel` setting which you can learn more about at https://code.visualstudio.com/docs/supporting/faq#_how-to-disable-telemetry-reporting.
57+
58+
### Local package feeds
59+
60+
Use Node.js supported by this repository and Python 3.10 or later. Both setup commands create or reuse `.venv` and install the Python bundling tools. Choose the appropriate setup below before installing dependencies. Committed lockfiles use public npm URLs; Microsoft setup rewrites working copies for proxy installs.
61+
62+
#### Public contributors (non-Microsoft employees)
63+
64+
Use the public setup, which selects `https://registry.npmjs.org/` and `https://pypi.org/simple/` for its child processes. No Microsoft account or internal-feed credentials are needed, and this command works before `node_modules` exists:
65+
66+
From the repository root:
67+
68+
```bash
69+
npm run setup
70+
```
71+
72+
For subsequent npm installs, use `npm ci`. Public contributors do not need the Microsoft feed commands or lockfile hook.
73+
74+
#### Microsoft employees only
75+
76+
> **Microsoft users only:** The commands in this section configure Microsoft package feeds. Public contributors should use the public setup above.
77+
78+
Use the Microsoft setup, which selects `https://packagefeedproxy.microsoft.io/npm/` and `https://packagefeedproxy.microsoft.io/pypi/simple/` for its child processes:
79+
80+
```bash
81+
npm run setup:msft
82+
```
83+
84+
Microsoft setup rewrites public npm and Yarn `resolved` URLs in the root `package-lock.json` to the npm proxy before running `npm ci`. Versions, integrity hashes, formatting, and private-feed URLs are preserved. The public setup leaves lockfiles unchanged.
85+
86+
After pulling a new lockfile from GitHub, rerun `npm run setup:msft`, or run the dependency-free rewrite step alone before your next install/build:
87+
88+
```bash
89+
npm run setup:msft-registry
90+
```
91+
92+
The standalone step requires the root lockfile to exist; it does not require a shared TypeScript checkout. Rewriting is idempotent and stops on missing or invalid lockfiles. Keep committed lockfile URLs public using the optional pre-commit hook below (or `npm run normalize-lockfile` for the root lockfile).
93+
94+
For subsequent root npm installs, use:
95+
96+
```bash
97+
npm run ci:msft
98+
```
99+
100+
This rewrites the root lockfile, then runs root `npm ci` with the proxy registry explicitly selected for package, audit, and metadata requests. Use `npm run setup:msft` for full setup, including Python dependencies.
101+
102+
Local setup, lockfile rewriting, and `ci:msft` share the feed URLs in `build/package-feeds.json`.
103+
104+
Both setup commands use the same implementation, stop on errors, and keep registry overrides scoped to setup's child processes; they do not change your shell environment, edit `.npmrc`, or add credentials. The standalone rewrite step only edits lockfiles; it does not configure the registry for subsequent commands.
105+
106+
After setup, run `npm run compile` to build the extension. For subsequent Python commands, use `.venv\Scripts\python.exe` on Windows or `.venv/bin/python` on macOS/Linux (or activate that virtual environment). Registry overrides are not retained after setup.
107+
108+
#### Microsoft contributor pre-commit hook
109+
110+
If you use the Microsoft feeds and will commit changes, enable the recommended lockfile hook once per clone (no installed npm dependencies are required). It is not needed just to install or build:
111+
112+
```bash
113+
npm run setup-hooks
114+
```
115+
116+
The installer sets the clone's local `core.hooksPath` to `.githooks`, which also affects its linked worktrees. It refuses to replace an existing hook or a different hooks configuration. If you already use hooks, add `node build/normalize-package-lock.js --staged` to your existing pre-commit hook instead. Only enable this configuration in worktrees/branches that contain these hook files.
117+
118+
Before a local commit, the hook converts known `Pylance_PublicPackages`, `packagefeedproxy.microsoft.io/npm/`, and named `1es-public/npm-public` mirror tarball URLs in the staged root `package-lock.json` to public npm URLs. It preserves versions, integrity hashes, formatting, and intentional Azure-hosted dependencies such as `msft_consumption`. Unknown feeds are left unchanged. It re-stages only the lockfile; if normalization is needed and the lockfile has unstaged changes, the commit is blocked without modifying it. Stage or stash those changes, then retry.
119+
120+
To normalize manually, run `npm run normalize-lockfile`, review the changes, and stage them. To disable the installed hook, run `git config --local --unset core.hooksPath`. These are local Git hooks: GitHub and Dependabot do not execute them. No workflow writes changes to PR branches.
121+
122+
### GitHub Actions package feeds
123+
124+
The PR and push workflows set `PIP_INDEX_URL` to `https://packagefeedproxy.microsoft.io/pypi/simple/` for pip and nox installs. Their Node installation steps select `https://packagefeedproxy.microsoft.io/npm/` explicitly through `npm run ci:msft`, so these workflows do not set `NPM_CONFIG_REGISTRY`. CodeQL retains both environment variables because its autobuild step does not use the install helper. The npm endpoint follows the [TypeScript CI package-feed-proxy job](https://github.com/microsoft/TypeScript/blob/main/.github/workflows/ci.yml).
125+
126+
The shared lint and VSIX build actions and applicable PR/push test jobs use `npm run ci:msft`, rewriting working-copy lockfile URLs before installation and explicitly selecting the proxy for npm requests. Workflows do not commit these rewrites or change local registry configuration or Dependabot configuration. Existing dependency caches are retained; the VSIX build also retains its offline-cache preference. CodeQL retains workflow-level feed settings for its autobuild step.
127+
128+
### Azure release package feeds
129+
130+
The DevDiv Azure stable/prerelease pipelines pass the npm proxy to their build/publish templates using `customNPMRegistry`. Their dependency install steps use `npm run ci:msft` to rewrite the root npm lockfile and install through the proxy.
131+
132+
Each Python bootstrap and bundled-library install step explicitly sets `PIP_INDEX_URL` from `PIP_PROXY_INDEX_URL`, selecting the pip proxy even when a template's authentication setup changes the job-level index. Release triggers, approval gates, signing, and publishing behavior are unchanged.
133+
134+
Dependabot continues to use public registries and its existing update settings. Legacy Azure stable, prerelease, and validation definitions are unchanged.

‎build/azure-devdiv-pipeline.pre-release.yml‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ variables:
2626
value: VSCode-python-debugger
2727
- name: VsixName
2828
value: python-debugger.vsix
29-
- name: AZURE_ARTIFACTS_FEED
30-
value: 'https://devdiv.pkgs.visualstudio.com/DevDiv/_packaging/Pylance_PublicPackages/npm/registry/'
29+
- name: NPM_CONFIG_REGISTRY
30+
value: 'https://packagefeedproxy.microsoft.io/npm/'
31+
- name: PIP_PROXY_INDEX_URL
32+
value: 'https://packagefeedproxy.microsoft.io/pypi/simple/'
3133

3234
parameters:
3335
- name: publishExtension
@@ -65,20 +67,28 @@ parameters:
6567
- name: buildSteps
6668
type: stepList
6769
default:
68-
- script: npm ci
70+
- script: npm run ci:msft
6971
displayName: Install NPM dependencies
7072

7173
- script: python -m pip install -U pip
7274
displayName: Upgrade pip
75+
env:
76+
PIP_INDEX_URL: $(PIP_PROXY_INDEX_URL)
7377

7478
- script: python -m pip install wheel
7579
displayName: Install wheel
80+
env:
81+
PIP_INDEX_URL: $(PIP_PROXY_INDEX_URL)
7682

7783
- script: python -m pip install nox
7884
displayName: Install nox
85+
env:
86+
PIP_INDEX_URL: $(PIP_PROXY_INDEX_URL)
7987

8088
- script: python -m nox --session install_bundled_libs
8189
displayName: Install Python dependencies
90+
env:
91+
PIP_INDEX_URL: $(PIP_PROXY_INDEX_URL)
8292

8393
- script: python ./build/update_ext_version.py --for-publishing
8494
displayName: Update build number
@@ -114,7 +124,7 @@ extends:
114124
buildSteps: ${{ parameters.buildSteps }}
115125
isPreRelease: true
116126
standardizedVersioning: true
117-
customNPMRegistry: $(AZURE_ARTIFACTS_FEED)
127+
customNPMRegistry: $(NPM_CONFIG_REGISTRY)
118128

119129
- stage: Publish
120130
displayName: Publish Extension
@@ -129,4 +139,4 @@ extends:
129139
ghCreateTag: true
130140
ghCreateRelease: true
131141
ghReleaseAddChangeLog: true
132-
customNPMRegistry: $(AZURE_ARTIFACTS_FEED)
142+
customNPMRegistry: $(NPM_CONFIG_REGISTRY)

0 commit comments

Comments
 (0)