-
Notifications
You must be signed in to change notification settings - Fork 152
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
chore(null): Add CI task to check for new files to add to tsconfig.strictNullChecks.json #5918
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0ebd1f8
add stict null checks autoadd to gh ci
08c66c6
yaml cleanup
52bb02b
more indentation
b74e524
final form
00807ec
Merge branch 'microsoft:main' into null-checks-ci
madalynrose f2418c6
update script path
madalynrose f648c74
yarn null:autoadd
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// // Copyright (c) Microsoft Corporation. All rights reserved. | ||
// // Licensed under the MIT License. | ||
// | ||
// USAGE: | ||
// | ||
// node verify-unchanged-strict-null-checks.js | ||
// | ||
// Verifies that "git status" does not report any pending changes to tsconfig.strictNullChecks.json | ||
// | ||
// This serves as a reminder for humans to update strict null checks when they add files. | ||
|
||
const path = require('path'); | ||
const process = require('process'); | ||
const child_process = require('child_process'); | ||
|
||
const lockfilePath = path.join(__dirname, '..', '..', 'tsconfig.strictNullChecks.json'); | ||
|
||
const gitStatusResult = child_process.execFileSync('git', ['status', '--porcelain=1', '--', lockfilePath]); | ||
const isLockfileChanged = gitStatusResult.toString() !== ''; | ||
|
||
if (isLockfileChanged) { | ||
const gitDiffResult = child_process.execFileSync('git', ['diff', '--', lockfilePath]); | ||
console.error(` | ||
Error: Running "yarn null:autoadd" identified new files to be included in null checks. | ||
|
||
To ensure these files are included: | ||
1) Pull this branch | ||
2) Run "yarn null:autoadd" | ||
3) Commit and push the resulting change to tsconfig.strictNullChecks.json | ||
|
||
Diff of the necessary change: | ||
|
||
${gitDiffResult.toString()} | ||
`); | ||
process.exit(1); | ||
} else { | ||
console.log('Success! git status reports no outstanding tsconfig.strictNullChecks.json changes.'); | ||
process.exit(0); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by this logic- the comment at the top of the file says that we're verifying that there are NO changes to tsconfig.strictNullChecks.json, but this error message suggests that we DO want to update that file. What is the actual expected outcome?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expected outcome is that CI will pass if this finds no changes and will fail if it does, prompting the author to run it and add those changes manually. This workflow is based on the behavior we use in accessibility-insights-for-android-service to ensure that gradle.lock is kept up-to-date
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, okay, makes sense to me!