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

Prefer CI info over git if present #190

Closed
wants to merge 1 commit into from
Closed

Prefer CI info over git if present #190

wants to merge 1 commit into from

Conversation

andrewhood125
Copy link

Resolves #189

@andrewhood125 andrewhood125 changed the title Prefer CI git info over .git if present Prefer CI info over git if present May 31, 2017
@gdiggs gdiggs requested a review from maxjacobson June 1, 2017 15:21
@gdiggs gdiggs removed their assignment Jun 1, 2017
Copy link
Contributor

@maxjacobson maxjacobson left a comment

Choose a reason for hiding this comment

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

Hi @andrewhood125. I think this change is reasonable, and thanks for contributing.

I flagged two things I'd like you to change, and then I'm happy to merge and cut a new release.

I'd also like to let you know about our new test-reporter which has some additional features and is where we're currently focusing more of our development effort.

it 'returns the head sha from ci if git is not available' do
expect(Git).to receive(:git).with("log -1 --pretty=format:'%H'").and_return("")
expect(Ci).to receive(:service_data).and_return({commit_sha: "4567"})
it 'returns the head sha from git if ci is not available' do
Copy link
Contributor

@maxjacobson maxjacobson Jun 1, 2017

Choose a reason for hiding this comment

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

it looks like we're missing a spec it 'returns the head from CI when both git and ci are available'

@@ -44,7 +44,8 @@ def head_from_git
end

def head_from_ci
Ci.service_data[:commit_sha]
sha = Ci.service_data[:commit_sha]
return nil if sha.empty?
Copy link
Contributor

Choose a reason for hiding this comment

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

as-written, this will always return nil

Copy link
Author

@andrewhood125 andrewhood125 Jun 1, 2017

Choose a reason for hiding this comment

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

Right you are. So weird.. thought I ran this from pry and it returned the sha. I'll switch it up.

@andrewhood125
Copy link
Author

@maxjacobson thanks for pointing me to that! I'll take a look!

@andrewhood125
Copy link
Author

@maxjacobson updated! 👍

@andrewhood125
Copy link
Author

Hmm.. looking at fails.

@andrewhood125
Copy link
Author

No safe operator. 😢

@andrewhood125
Copy link
Author

andrewhood125 commented Jun 1, 2017

Looks like for some reason the ordering of the formatter spec was switched. I wonder if a less strict compare would be better. Is this a flakey spec? Thoughts @maxjacobson ?

@maxjacobson
Copy link
Contributor

maxjacobson commented Jun 1, 2017

I think I know what's happening. The expectation that's not met is here:

       -:git => {:head=>"7a36651c654c73e7e9a6dfc9f9fa78c5fe37241e", :committed_at=>1474318896, :branch=>"master"},
       +:git => {:head=>"73a72f2142b1dbba41cefa0181b996d856f7ee4b", :committed_at=>1474318896, :branch=>"master"},

The head is expected to be the latest sha in this compressed repository https://github.com/codeclimate/ruby-test-reporter/blob/master/spec/fixtures/fake_project.tar.gz , but instead, when the test runs on Circle CI, it prefers the value from the environment (because of your change) and fails. When you run the test locally, no CI-specific environment variables are set, so it uses the one from the repository (and passes).

Does that make sense? I think you can probably avoid this failure by stubbing something.

@andrewhood125
Copy link
Author

andrewhood125 commented Jun 1, 2017

Ah I see it now. I glazed over those shas thinking they were the same 👍 Thanks for highlighting that.

@andrewhood125
Copy link
Author

@maxjacobson updated.

@andrewhood125
Copy link
Author

@maxjacobson look good to you?

@maxjacobson
Copy link
Contributor

@andrewhood125 hey, thanks for the ping and for working on this. I was about to merge this, but then noticed that my colleague was making a similar change in our new test reporter. After talking it through, I believe this change isn't as thorough as it needs to be. Before merging, we would need to also update this to prefer the CI information for branch and committed_at.

I do appreciate your work, and if you'd like to make that change I'll be happy to merge it. But if you're interested, what do you think about trying out our new test reporter (it's in beta and has some additional cool features)? As of today's release, it should already work for your use-case.

@andrewhood125
Copy link
Author

👌 got the new test reporter working.

@andrewhood125 andrewhood125 deleted the change-order-for-git-commit-sha branch June 6, 2017 23: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.

3 participants