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

🔥 Explode on potentially rubbish files in the workdir that aren't Git-tracked #7631

Closed
wants to merge 4 commits into from

Conversation

webknjaz
Copy link
Member

This is a follow-up improvement for
#7624

@webknjaz webknjaz requested a review from pradyunsg January 21, 2020 16:02
@pfmoore
Copy link
Member

pfmoore commented Jan 21, 2020

With this addition, presumably this script is only safe to run on a clean checkout? Is there any way to check and make sure no-one mistakenly runs this in their development checkout?

Rather than deleting unchecked files, could the script not abort if it finds any, and get the user to clean up manually?

Edit: The advantage of the existing code that only clears the build directory is that the build directory is by design intended to be temporary, and safely removable.

@webknjaz
Copy link
Member Author

@pfmoore well, I suppose we could do that with --dry-run.

P.S. Ideally the script should do git worktree into some tmp location and do all the stuff there which combined with git clean would make things even cleaner.

noxfile.py Outdated
if release.have_files_in_folder("build"):
shutil.rmtree("build")
session.log("# Wipe Git-untracked files before building the wheel")
session.run("git", "clean", "-fxd", external=True, silent=True)
Copy link
Member

Choose a reason for hiding this comment

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

See my comment, which should have been submitted as a review instead 🙁

Copy link
Member Author

Choose a reason for hiding this comment

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

(already answered: #7631 (comment))

@pfmoore
Copy link
Member

pfmoore commented Jan 21, 2020

Apart from the build directory, do untracked files actually pose any risk?

@webknjaz
Copy link
Member Author

@pfmoore yes, sometimes you can accidentally include .pyc or some garbage. Even if you have an explicit blacklist, this doesn't protect from future changes: the human factor can kick-in any moment and unwanted things would appear somewhere else. There can be some other package/module name collision with a similar outcome...

@ewjoachim
Copy link
Member

I haven’t looked closely enough whether in the local environment, pip itself is installed in -e mode, but it is sufficiently standard in environments so I’ll go with it, please excuse me if irrelevant:

What about the pip.egg-info folder ? You may not want to delete that, I’d guess (or you’ll have to reinstall pip locally afterwards)
What about the potential personal files, like workspace editor configuration, that might be there ? Whoever does the release might not appreciate loosing that.

@webknjaz
Copy link
Member Author

@ewjoachim this is about the clean-up before building. So it's good to remove artifacts of previous builds. Also, I'm pretty sure that building dists is not related to editable installs.

@pfmoore
Copy link
Member

pfmoore commented Jan 24, 2020

Rather than trying to clean up the checkout that we're running the automation in, wouldn't it be better if the release automation checked out a completely clean new copy of pip master? That way there's no doubt we have a clean starting point...

One possible complication with such an approach would be if people want to build the release in their personal fork, and then make a PR for it. I'm not sure if that's something @pradyunsg does, for example. The docs don't discuss that possibility, though, so if it is an approach we want to allow, I'd rather write it up and then modify the tools to support it (for example, I'm not clear how I'd set the release tag correctly if I did the release via a PR).

@pradyunsg
Copy link
Member

pradyunsg commented Jan 24, 2020

wouldn't it be better if the release automation checked out a completely clean new copy of pip master?

I think so yea, this would definitely be much cleaner IMO -- I've had to make changes to the working directory in the past (to the release process automation, or NEWS.rst file, for example) but I do agree that it'd help to have the actual checkout that the release is built from happen in not-the-same-worktree.

I think I much prefer that over the proposed approach, and very slightly over the current "clean the build directory before building things" approach.


Note that resetting all the files to what a "fresh" git checkout would look like, also removes the .nox directory which contains the python[.exe] we're running from -- that's what's causing the CI failures here.

@pfmoore
Copy link
Member

pfmoore commented Jan 24, 2020

Note that resetting all the files to what a "fresh" git checkout would look like, also removes the .nox directory

Ha. Good point. I'd been thinking of something like nox -s prepare_release -- 99.9 build_dir to build a new checkout in build_dir, then do the prepare in that. Leaving the current checkout unchanged, and never running nox from within the directory we're releasing from. But I hadn't thought through yet whether we'd want to add the same parameter to publish_release or whether we should run that from within the new checkout. As usual, it's the details that are tricky to get right.

Also, are you OK with releasing direct from master, or do you go via a PR? Personally, I feel safer doing a PR, but with our current docs I'd do it from master, as I'd rather trust the docs than guess how to do it any other way (my git skills aren't that good).

@pradyunsg
Copy link
Member

pradyunsg commented Jan 24, 2020

Well, I'm supposed to be updating the docs, to reflect that we can't push to master (it's a protected branch). I allow admins to push temporarily when I'm not interested in the CI (eg. 20.0.2) to allow pushing to master and then re-enable the check within the same minute as I disable it.

I actually wanna automate the entire flow to a push-and-done flow, so that there's no need for such hacks, but baby steps.

@pfmoore
Copy link
Member

pfmoore commented Jan 24, 2020

OK cool (I'd forgotten master was protected). I can probably look at that. The thing I am least sure about was how to get the tags across, as they won't come as part of a PR.

But no rush, there's no more releases for 3 months so have a rest first :-)

@webknjaz
Copy link
Member Author

as they won't come as part of a PR.

If you use a regular merge (with a proper merge commit), you could tag the commit in the PR branch and then it'd belong to master too after merging. Does this sound reasonable?

@webknjaz webknjaz force-pushed the misc/pre-release-cleanup branch from 0770130 to 02ca5e6 Compare January 25, 2020 12:43
@webknjaz webknjaz changed the title 🔥 Exterminate files that aren't Git-tracked 🔥 Explode on potentially rubbish files in the workdir that aren't Git-tracked Jan 25, 2020
@webknjaz
Copy link
Member Author

Folks, I've changed the PR to just check that the dir is clean. It should be safer now.

@pradyunsg
Copy link
Member

Does this sound reasonable?

Yep -- that's how 20.0 was made. :P

Allow own `.nox/` runtime env files.
@webknjaz webknjaz force-pushed the misc/pre-release-cleanup branch from 02ca5e6 to a7fd22b Compare January 26, 2020 01:55
@ewjoachim
Copy link
Member

@ewjoachim this is about the clean-up before building. So it's good to remove artifacts of previous builds. Also, I'm pretty sure that building dists is not related to editable installs.

I do understand that. My point was that if we remove all untracked files, and not just those in the dist folder, we may delete untracked files that are not build artifacts at all (like those I listed).

That being said, 👍 on the new approach.

@webknjaz
Copy link
Member Author

we may delete untracked files that are not build artifacts at all (like those I listed).

I think that the goal should be for those files to not exist when the build starts because it may cause problems over time when somebody changes something in the build system and they will get included...

@webknjaz
Copy link
Member Author

@ewjoachim I've also sketched a more advanced solution here: #7654

@pradyunsg
Copy link
Member

Closing this, in favor of #7654 (nice number!) -- I think the approach there is a bigger improvement over status quo than this PR is. :)

@pradyunsg pradyunsg closed this Jan 28, 2020
@pradyunsg pradyunsg removed their request for review January 28, 2020 07:16
@pradyunsg pradyunsg added C: automation Automated checks, CI etc type: maintenance Related to Development and Maintenance Processes labels Jan 28, 2020
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Feb 28, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Feb 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: automation Automated checks, CI etc type: maintenance Related to Development and Maintenance Processes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants