Skip to content

ci: Fix Danger job being broken because of duplicate Gemfiles

Patrick Steinhardt requested to merge pks-danger-fix-duplicate-gemfile into master

Recently our Danger job has started failing with the following error message:

[!] There was an error parsing `injected gems`: You cannot specify the same gem twice with different version requirements.
You specified: gitlab-dangerfiles (~> 3.1.0) and gitlab-dangerfiles (>= 0). Gem already added. Bundler cannot continue.

As it turns out, this breakage is caused by the upstream change 9e3eff4 (Don't require projects to contain Gemfile when using danger-review job, 2022-06-10) in the common pipeline configurations: if the CI job detects that there is no Gemfile, it has now started to write one for us that contains the gitlab-dangerfiles version. And because our Gemfile is not contained in the root directory but instead in the danger/ sub directory we now end up with two Gemfiles.

Fix this issue by making use of the new feature: instead of carrying our own Gemfile, we can now simply rely on the auto-generated Gemfile. While this forces us to get rid of the Ruby cache which was keyed by our own Gemfile, this is really not an issue at all: execution of the whole job only takes about 40 seconds without the cache, which is fast enough.

Edited by Patrick Steinhardt

Merge request reports