Skip to content

Commit

Permalink
Add PR check for proposed API changes
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
eleanorjboyd committed Dec 11, 2024
1 parent 32512b1 commit 4a00aa6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/pr-file-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ jobs:
.github/test_plan.md
skip-label: 'skip tests'
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)'

- name: 'Check for proposed API changes'
run: npm run check-proposed-api
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,8 @@
"addExtensionPackDependencies": "gulp addExtensionPackDependencies",
"updateBuildNumber": "gulp updateBuildNumber",
"verifyBundle": "gulp verifyBundle",
"webpack": "webpack"
"webpack": "webpack",
"check-proposed-api": "node ./src/check-proposed-api.js"
},
"dependencies": {
"@iarna/toml": "^2.2.5",
Expand Down
22 changes: 22 additions & 0 deletions src/check-proposed-api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const fs = require('fs');

const packageJsonPath = './package.json';

function checkProposedApiChanges() {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));

const enabledApiProposals = packageJson.enabledApiProposals;

Check failure on line 8 in src/check-proposed-api.js

View workflow job for this annotation

GitHub Actions / Lint

Use object destructuring

Check failure on line 8 in src/check-proposed-api.js

View workflow job for this annotation

GitHub Actions / Lint

Use object destructuring
const vscodeEngineVersion = packageJson.engines.vscode;

const originalPackageJson = JSON.parse(fs.readFileSync(packageJsonPath + '.original', 'utf8'));

Check failure on line 11 in src/check-proposed-api.js

View workflow job for this annotation

GitHub Actions / Lint

Unexpected string concatenation

Check failure on line 11 in src/check-proposed-api.js

View workflow job for this annotation

GitHub Actions / Lint

Unexpected string concatenation
const originalEnabledApiProposals = originalPackageJson.enabledApiProposals;
const originalVscodeEngineVersion = originalPackageJson.engines.vscode;

if (JSON.stringify(enabledApiProposals) !== JSON.stringify(originalEnabledApiProposals) &&
vscodeEngineVersion === originalVscodeEngineVersion) {
console.error('Error: `enabledApiProposals` was modified but `vscode` engine version was not updated.');
process.exit(1);
}
}

checkProposedApiChanges();

0 comments on commit 4a00aa6

Please sign in to comment.