Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PR check for proposed API changes #24586

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, engines } = packageJson;
const vscodeEngineVersion = 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.');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we throw error to be more explicit? I just dont want this to get hidden in pile of other logs&error.

process.exit(1);
}
}

checkProposedApiChanges();
Loading