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

feat: Auto detect commit sha, add shorthand -r flag #119

Merged
merged 10 commits into from
Oct 14, 2023

Conversation

YOU54F
Copy link
Member

@YOU54F YOU54F commented Oct 27, 2022

resolves #100

  • Make --auto-detect-version-properties pick up both the git commit, and git branch, from available env known CI env vars , or git commands if in a git repo.
  • Adds shorthand -r flag

Would love to make default behaviour, but in lieu of that I used the shorthand flag for -r for recommended :)

Should fit in nicely with our re-work of the path to nirvana

@YOU54F YOU54F force-pushed the auto_detect_commit branch from dcf6472 to 2e6d75d Compare October 27, 2022 19:53
@YOU54F YOU54F requested review from mefellows and bethesque May 3, 2023 19:33
lib/pact_broker/client/cli/pact_commands.rb Outdated Show resolved Hide resolved
lib/pact_broker/client/git.rb Outdated Show resolved Hide resolved
lib/pact_broker/client/git.rb Outdated Show resolved Hide resolved
@YOU54F YOU54F marked this pull request as draft May 24, 2023 18:55
@bethesque
Copy link
Member

Ping me when you're happy with this.

lib/pact_broker/client/cli/pact_commands.rb Outdated Show resolved Hide resolved
def consumer_app_version
require 'pact_broker/client/git'
if options.consumer_app_version.blank? && options.auto_detect_version_properties
PactBroker::Client::Git.commit(raise_error: explict_auto_detect_version_properties)
Copy link
Member

Choose a reason for hiding this comment

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

Ok, all this "auto detect vs explicit auto detect" logic was because I started by auto detecting the branch, and I was going to make it auto detect the branch by default, but have it not raise errors if it couldn't find the branch env var if it was the "default auto detect", but for it to raise errors if the user had explicitly said "auto detect", because I wanted to turn it on without breaking anyone's builds. I'm not sure if that logic needs to be applied to the consumer version, because the consumer version is a required property, but the branch wasn't.

Copy link
Member Author

Choose a reason for hiding this comment

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

"auto detect vs explicit auto detect"

Logic was because I started by auto detecting the branch, and

  • I was going to make it auto detect the branch by default
    • don't raise errors if it couldn't find the branch env var if it was the "default auto detect"
    • raise errors if the user had explicitly said "auto detect",

I wanted to turn it on without breaking anyone's builds.

I'm not sure if that logic needs to be applied to the consumer version, because the consumer version is a required property, but the branch wasn't.

Edited to read it a bit better, I had a look last eve, and I think I am confused. I'll push up some changes

Copy link
Member

Choose a reason for hiding this comment

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

Just make this (raise_error: true)

Copy link
Member

Choose a reason for hiding this comment

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

Still relevant ^^

Copy link
Member Author

Choose a reason for hiding this comment

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

sorry I did pick this up this morning to try and wrap it up but got pulled away on various threads. thanks for the extra reviews comments :)

@YOU54F
Copy link
Member Author

YOU54F commented Jun 5, 2023

Hiya Beth, sorry for late reply, haven’t had the headspace to jump back on this at the moment, but will make the logic less complex and meet your wish list.

i’ll be sure to give you a holla so we can tee this up with some docco changes to recommended workflows ( and box off the path to nirvana updates for branches / envs )

@YOU54F YOU54F marked this pull request as ready for review July 28, 2023 11:14
@bethesque
Copy link
Member

Can you have a poke around and see if you can do the same for the build URL?

@YOU54F
Copy link
Member Author

YOU54F commented Aug 2, 2023

Can you have a poke around and see if you can do the same for the build URL?

yeah sure thing, I already know some of them from previous work on a slack reporter for cypress

https://github.com/YOU54F/cypress-plugins/blob/8c559869f3cadc0599eadae980d73472580d2077/cypress-slack-reporter-old/src/slack/slack-alert.ts#L735-L799

doc/pacts/markdown/Pact Broker Client - Pactflow.md Outdated Show resolved Hide resolved
doc/pacts/markdown/README.md Outdated Show resolved Hide resolved
def consumer_app_version
require 'pact_broker/client/git'
if options.consumer_app_version.blank? && options.auto_detect_version_properties
PactBroker::Client::Git.commit(raise_error: explict_auto_detect_version_properties)
Copy link
Member

Choose a reason for hiding this comment

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

Just make this (raise_error: true)

lib/pact_broker/client/tasks/publication_task.rb Outdated Show resolved Hide resolved
@YOU54F
Copy link
Member Author

YOU54F commented Sep 14, 2023

Should be good for review again now, have moved out the DX instructions to #143

@YOU54F YOU54F requested a review from bethesque September 14, 2023 16:16
@bethesque
Copy link
Member

This must be the longest running most painful PR ever. My sincere apologies.

  • I've removed all the "version_required" and "explicit auto detect" code. It wasn't being used, and was just complicating things. Sorry you had to try and reverse engineer that.
  • auto detect now includes the build URL along with the commit and branch
  • raise errors in publication task and publish command if no consumer version is specified/found

@bethesque bethesque merged commit 1dac9f8 into master Oct 14, 2023
29 checks passed
@bethesque bethesque deleted the auto_detect_commit branch October 14, 2023 04:58
@bethesque
Copy link
Member

Thank you for your patience and perseverance with this @YOU54F! We got there in the end 😆

@YOU54F
Copy link
Member Author

YOU54F commented Oct 14, 2023

yay and no problem @bethesque - thanks for the guidance as always and also thank you for wrapping up the last bits 🥰

@mefellows
Copy link
Member

WOOT - better later than never hey!

@bethesque
Copy link
Member

bethesque commented Oct 18, 2023

Unfortunately, it's not going to be much use to the people using the docker image, because you have to map the env vars deliberately to make use of it. But it will help anyone using the standalone.

@YOU54F
Copy link
Member Author

YOU54F commented Oct 19, 2023

good point Polly the party pooper 😂

We can provide guidance to users to either mount their env vars into the container, so they will be picked up

pactflow/actions#14

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.

Populate --consumer-app-version from git commit when --auto-detect-version-properties is used.
3 participants