Skip to content

Commit 4a00aa6

Browse files
committed
Add PR check for proposed API changes
Fixes #20939 Add a PR check for proposed API changes without VS Code engine update. * Modify `package.json` to add a new script entry `check-proposed-api`. * Modify `.github/workflows/pr-file-check.yml` to add a new step to run the `check-proposed-api` script. * Add `src/check-proposed-api.js` to check for changes in `enabledApiProposals` and `vscode` engine version, and fail if `enabledApiProposals` is modified but `vscode` engine version is not updated. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/microsoft/vscode-python/issues/20939?shareId=XXXX-XXXX-XXXX-XXXX).
1 parent 32512b1 commit 4a00aa6

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ jobs:
4242
.github/test_plan.md
4343
skip-label: 'skip tests'
4444
failure-message: 'TypeScript code was edited without also editing a ${file-pattern} file; see the Testing page in our wiki on testing guidelines (the ${skip-label} label can be used to pass this check)'
45+
46+
- name: 'Check for proposed API changes'
47+
run: npm run check-proposed-api

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,8 @@
15521552
"addExtensionPackDependencies": "gulp addExtensionPackDependencies",
15531553
"updateBuildNumber": "gulp updateBuildNumber",
15541554
"verifyBundle": "gulp verifyBundle",
1555-
"webpack": "webpack"
1555+
"webpack": "webpack",
1556+
"check-proposed-api": "node ./src/check-proposed-api.js"
15561557
},
15571558
"dependencies": {
15581559
"@iarna/toml": "^2.2.5",

src/check-proposed-api.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const fs = require('fs');
2+
3+
const packageJsonPath = './package.json';
4+
5+
function checkProposedApiChanges() {
6+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
7+
8+
const enabledApiProposals = packageJson.enabledApiProposals;
9+
const vscodeEngineVersion = packageJson.engines.vscode;
10+
11+
const originalPackageJson = JSON.parse(fs.readFileSync(packageJsonPath + '.original', 'utf8'));
12+
const originalEnabledApiProposals = originalPackageJson.enabledApiProposals;
13+
const originalVscodeEngineVersion = originalPackageJson.engines.vscode;
14+
15+
if (JSON.stringify(enabledApiProposals) !== JSON.stringify(originalEnabledApiProposals) &&
16+
vscodeEngineVersion === originalVscodeEngineVersion) {
17+
console.error('Error: `enabledApiProposals` was modified but `vscode` engine version was not updated.');
18+
process.exit(1);
19+
}
20+
}
21+
22+
checkProposedApiChanges();

0 commit comments

Comments
 (0)