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

ENH: allow in-script tagging in ioc-deploy #200

Merged
merged 6 commits into from
Sep 10, 2024

Conversation

ZLLentz
Copy link
Member

@ZLLentz ZLLentz commented Sep 7, 2024

Description

Main goal: allow us to make releases from the command line without going to the github website, for convenience

Main changes:

  • If the provided release number does not exist, prompt the user to create a new tag.
  • Enforce Rx.x.x format for the new tag
  • The new tag is an annotated tag if we're adding a message to it, and a non-annotated tag otherwise
  • Show the last commit message to the user for tag context, confirmation that they pushed their code, and as the defacto "default" message if they decide not to include one with their tag

Other things to note:

  • Increase logging consistency between shell out functions
  • Have a special message for KeyboardInterrupt, since it's way more likely to happen when the user is dropped into a text prompt, and seeing a traceback when you do it is a bit annoying.
  • With --auto-confirm, the tag will be made automatically with no message.

I also snuck some smaller changes into here

Motivation and Context

https://jira.slac.stanford.edu/browse/ECS-6035

For releasing hutch-specific templated IOCs that amount to version bumps, etc., people have expressed that they find it annoying to open up github and do by hand what in the past they had done all in the command-line, so I provide these features here.

This isn't so necessary or useful for when you're already on github doing a code review process.

How Has This Been Tested?

Interactively only

Where Has This Been Documented?

Added to the help text and readme

@ZLLentz
Copy link
Member Author

ZLLentz commented Sep 9, 2024

The diff here still shows the variant from before the other PR was merged, I'll see if closing and re-opening fixes it

@ZLLentz ZLLentz closed this Sep 9, 2024
@ZLLentz ZLLentz reopened this Sep 9, 2024
@ZLLentz
Copy link
Member Author

ZLLentz commented Sep 9, 2024

It worked, now with the updated diff I'll have an easier time writing the description and the reviews will be simpler later too.

@ZLLentz ZLLentz marked this pull request as ready for review September 9, 2024 22:35
@ZLLentz
Copy link
Member Author

ZLLentz commented Sep 9, 2024

This is likely the last ioc-deploy PR for a while unless new bugs are found

Copy link
Contributor

@tangkong tangkong left a comment

Choose a reason for hiding this comment

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

This looks good to me, a few nitpicks.

I don't think we have any restrictions on who can make tags, and if that's the case this seems fine. Though it does open us up to people messing up the semantic versioning convention and pushing annoying tag names. I don't quite think this is the place to enforce that, and attempting to do so would probably result in a huge annoying block of info.

)
except subprocess.CalledProcessError as exc:
raise ValueError(
f"Error cloning {github_org}/{name}, please make sure you have the correct access rights and the repository exists."
Copy link
Contributor

Choose a reason for hiding this comment

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

looooooooong line

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll split this up, I'm getting away with long strings because ruff doesn't care

Copy link
Member Author

Choose a reason for hiding this comment

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

While I was at it, I split up the other excessively long lines in the file
Rather than aiming for any specific length I tried to separate them by semantically logical bits

except KeyboardInterrupt:
logger.error("Interruped with ctrl+C")
logger.debug("Traceback", exc_info=True)
rval = ReturnCode.EXCEPTION
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems more like a ReturnCode.NO_CONFIRM case to me, where if a user quits out it was intentional

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I agree

"""
Return the most recent commit message or raise a subprocess.CalledProcessError
"""
cmd = ["git", "log", "-1"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cmd = ["git", "log", "-1"]
cmd = ["git", "log", "-1", "--pretty=%B"]

For me this gets all the nitty gritty from the log output as well, adding a few arguments can strip that

Copy link
Member Author

Choose a reason for hiding this comment

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

This doesn't work for a shallow clone and I do not know why

Copy link
Contributor

@tangkong tangkong Sep 10, 2024

Choose a reason for hiding this comment

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

Weird, this works for me in a clone --depth 1, maybe I'm doing something differently?

Details

$ git clone --depth 1 [email protected]:tangkong/hello-world
Cloning into 'hello-world'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (3/3), done.
$ cd hello-world/
$ git log
commit e2e299826a1f0d96bf1f2e5448d33032f85157f2 (grafted, HEAD -> master, tag: v0.0.1, origin/master, origin/HEAD)
Author: tangkong <[email protected]>
Date:   Fri Jan 12 18:17:25 2018 +0000

    Merge pull request #1 from tangkong/readme-edits

    Update1 approved
$ git log -1 --pretty=%B
Merge pull request #1 from tangkong/readme-edits

Update1 approved

Copy link
Member Author

Choose a reason for hiding this comment

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

I swear this was failing for me last week but now I see the same

Copy link
Member Author

Choose a reason for hiding this comment

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

I after seeing it fail (somehow) last week and switching to the full log, I ended up really appreciating seeing the full thing including the timestamp, user, etc., so it's more obvious if you are accidentally tagging prior to pushing or merging the PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

So to that end I'm going to change the docstring instead of the command

Copy link
Contributor

Choose a reason for hiding this comment

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

The only thing a user might not care to see is the commit hash, but then again I personally wouldn't mind it. Sounds good to me

slactjohnson
slactjohnson previously approved these changes Sep 10, 2024
Copy link
Contributor

@slactjohnson slactjohnson left a comment

Choose a reason for hiding this comment

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

This looks good to me. It's a nice QOL improvement. 👍

Copy link
Contributor

@tangkong tangkong left a comment

Choose a reason for hiding this comment

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

LGTM

@ZLLentz
Copy link
Member Author

ZLLentz commented Sep 10, 2024

One more re-check from me that the main code paths work after the minor adjustments and then I'm clicking merge!

@ZLLentz ZLLentz merged commit d225b28 into pcdshub:master Sep 10, 2024
2 checks passed
@ZLLentz ZLLentz deleted the enh_make_tag branch September 10, 2024 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants