Make it possible to test git hooks workflow in test environment
Currently, when someone makes a Git push, we execute some server side git hooks that are located in project.git/hooks
.
In test environment, however, we do not have server side hooks, because we clone gitlab-test
project using --bare
and this does not provide hooks
. Some features that may depend on hooks being executed and therefore are untestable in RSpec test suite.
The example is removing branch through user interface.
- user removes branch in the UI hitting remove branch button
-
Repository#rm_branch
executes git hooks service -
GitHooksService
runs all relevantGitlab::Git::Hook
-
Gitlab::Git::Hook
tries to findnamespace/project.git/hooks/post-receive|pre-receive
script and execute it
In test environment it won't go any further, because there are no hooks/
. In normal environment, it proceeds to:
- hooks scripts call relevant objects from
Gitlab::Shell
project - GitLab Shell connects to redis and schedules asynchronous
PostReceive
Sidekiq job -
PostReceive
worker callsGitPushService
orGitTagService
and does some other stuff as well.
It probably would be difficult to support this out of the box, so probably adding some helpers to TestEnv
like TestEnv.trigger_hooks
would be a good start.
At this point we are not able to write some feature specs for feature that do depend on server-side hooks being executed.
What do you think @rymai @DouweM @smcgivern?