-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
do not run commit hooks in timing tests #1151
Conversation
if you are mandated to have something like `git secrets` installed then the test fails as it takes more time that the test allows to make the commit. On windows git secrets can easily make a commit take 20s to complete or more (but a lower bound is around 5 seconds). As we are doing timing here and we do not care about commit hooks, we can just skip them so they do not interfere.
@@ -161,17 +161,17 @@ public void retrieveHeadsSupportsTagDiscovery_findTagsWithTagDiscoveryTrait() th | |||
sampleRepo.init(); | |||
sampleRepo.git("checkout", "-b", "dev"); | |||
sampleRepo.write("file", "modified"); | |||
sampleRepo.git("commit", "--all", "--message=dev-commit-message"); | |||
sampleRepo.git("commit", "--all", "--message=dev-commit-message", "--no-verify"); | |||
long beforeLightweightTag = System.currentTimeMillis(); |
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.
this should also not use currentTimeMillis
but nonoTime
as the clock can change during testing (NTP step or drifting) causing flaky tests - but well that can be left for another day :)
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.
Thanks!
Similar to jenkinsci#1151 by default git comes without any hooks, but when creating a new sample git repo with the code it would copy the system default hooks, meaning this sample repo can behave differently on different platforms. by not using the hooks here we can avoid littering test code with "--no-verify" on commits, and can avoit hooks in other cases as well, which consume test time and / or even fail the operation due to a failing hook requirement (e.g. no JIRA reference) when consuming this in pipeline-model-definition's ValidatorTest test locally go from failing due to timeout exception (10 minutes) to completing in 2 minutes
Do not run commit hooks in timing test
if you are mandated to have something like
git secrets
installed then the test fails as it takes more time that the test allows to make the commit.On windows git secrets can easily make a commit take 20s to complete or more (but a lower bound is around 5 seconds).
As we are doing timing here and we do not care about commit hooks, we can just skip them so they do not interfere.
Checklist
Types of changes