-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix GitLab pipelines on default branch with no new commits #94
Fix GitLab pipelines on default branch with no new commits #94
Conversation
In GitLab, when a pipeline is launched but there are no new commits (eg. when a pipeline is manually launched via GL webUI), CI_COMMIT_BEFORE_SHA is set to a string of 40 zeros. This fix expressly handles this case, to avoid internal python errors and to correctly skip DCO check when it's not needed. Signed-off-by: Alberto Pianon <alberto@pianon.eu>
Signed-off-by: Alberto Pianon <alberto@pianon.eu>
Codecov Report
@@ Coverage Diff @@
## master #94 +/- ##
==========================================
- Coverage 73.12% 68.11% -5.01%
==========================================
Files 2 2
Lines 480 483 +3
Branches 77 78 +1
==========================================
- Hits 351 329 -22
- Misses 98 130 +32
+ Partials 31 24 -7
Continue to review full report at Codecov.
|
I set up a dummy repo on GitLab to show when the problems happens and how the proposed fix solves it. https://gitlab.com/alpianon/test-dco-check This is the first pipeline log with dco-check 0.0.11 (without the fix) run on default (master) branch: it fails because it gets Then I changed Finally I re-launched the pipeline from GL webUI, |
Hi, thanks for reporting this and for proposing a fix! I think something like this happened for scheduled pipelines, since there's never any new commits for those, which is why Your explanation looks good, but, just to make sure, how was the first pipeline triggered? Was it manual or automatic? Because it looks like there are actually two issues here:
I know the second issue is really a corner case 😆, so I wouldn't mind merging this and opening a separate issue to figure out how to fix issue 2 above. Let me know what you think/if you're okay with that. |
It was manual (via webUI). At first thought, I was thinking of adding another exception for the case where CI_PIPELINE_SOURCE is 'web' (currently there is only an exception for 'schedule'), but since there may be other cases in which a pipeline is triggered without new commits, I thought it was best to handle the general case.
correct
yes, it is
yes, you're right.
I agree. A possible solution would be to check git log and see if that there is only one initial commit, and check that. |
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.
Great, thanks for the fix!
Fix #92
In GitLab, when a pipeline is launched but there are no new commits (eg. when a pipeline is manually launched via GL webUI),
CI_COMMIT_BEFORE_SHA
is set to a string of 40 zeros. This fix expressly handles this case, to avoid internal python errors and to correctly skip DCO check because it's not needed.I added an example in the comment below, with GitLab pipeline logs from a dummy repo