-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[Infrastructure] Avoid polluting the repo with changes on builds #62399
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
base: main
Are you sure you want to change the base?
Conversation
@copilot try again |
@copilot one more time |
@copilot third time is the charm? |
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
…kage.json files Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
@copilot the fix is almost there, the only file that remains modified after running |
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
I've added |
eng/Npm.Workspace.nodeproj
Outdated
<Target Name="RestorePackageJsonFiles" AfterTargets="Build;Pack"> | ||
<Message Text="Restoring package.json files and package-lock.json from backups..." Importance="high" /> | ||
<ItemGroup> | ||
<PackageJsonBackupFiles Include="$(RepoRoot)**/*.json.bak" /> | ||
</ItemGroup> | ||
<Move SourceFiles="@(PackageJsonBackupFiles)" | ||
DestinationFiles="@(PackageJsonBackupFiles -> Replace('.bak', ''))" | ||
Condition="@(PackageJsonBackupFiles) != ''" /> | ||
<!-- Restore package-lock.json from git if it was modified --> |
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.
instead of trying to restore these files, wouldn't it be simpler to call git checkout -- <<files>>
using the exec task to undo the changes?
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.
You're absolutely right! I've simplified the approach in commit e995afe. The target now uses git checkout -- <file>
to restore the modified package.json files and package-lock.json instead of manually moving backup files around. This is much cleaner and more reliable since git knows the exact original state of the files.
…f manual file restoration Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Summary
This PR fixes issue #62398 by preventing build artifacts from polluting the repository during npm build processes.
Problem
When running
eng\build.cmd
, the npm pack-workspace script modifiespackage.json
files to update version numbers and creates.bak
backup files. These backup files were not ignored by git and would show up as untracked files, polluting the repository state.Solution
*.bak
to.gitignore
- Prevents backup files from showing as untracked filesRestorePackageJsonFiles
target toeng/Npm.Workspace.nodeproj
that runs after Build and Pack targets to restore original package.json files from their backupsChanges Made
.gitignore
*.bak
to the file extensions section to ignore npm backup fileseng/Npm.Workspace.nodeproj
RestorePackageJsonFiles
target that:Build
andPack
targets*.json.bak
files in the repositorypackage.json
locations (overwriting the modified versions).bak
files in the processTesting
The solution was thoroughly tested by:
.bak
files are created but properly ignored by gitBefore fix:
After fix:
Impact
Fixes #62398
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
googlechromelabs.github.io
node install.mjs
(dns block)https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/linux64/chrome-linux64.zip
node install.mjs
(http block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.