helper.current_milestone can return `nil` due to pagination
Sample failure: https://gitlab.com/gitlab-org/gitlab/-/jobs/4678218631
/builds/gitlab-org/gitlab/vendor/ruby/3.0.0/gems/gitlab-dangerfiles-3.11.0/lib/danger/plugins/changelog.rb:129:in `revert_in_current_milestone?': undefined method `title' for nil:NilClass (NoMethodError)
from /builds/gitlab-org/gitlab/vendor/ruby/3.0.0/gems/gitlab-dangerfiles-3.11.0/lib/danger/plugins/changelog.rb:119:in `check!'
from /builds/gitlab-org/gitlab/vendor/ruby/3.0.0/gems/gitlab-dangerfiles-3.11.0/lib/danger/rules/changelog/Dangerfile:3:in `eval_file'
from /builds/gitlab-org/gitlab/vendor/ruby/3.0.0/gems/danger-8.6.1/lib/danger/danger_core/dangerfile.rb:311:in `eval'
from /builds/gitlab-org/gitlab/vendor/ruby/3.0.0/gems/danger-8.6.1/lib/danger/danger_core/dangerfile.rb:311:in `eval_file'
from /builds/gitlab-org/gitlab/vendor/ruby/3.0.0/gems/danger-8.6.1/lib/danger/danger_core/dangerfile.rb:204:in `block in parse'
from /builds/gitlab-org/gitlab/vendor/ruby/3.0.0/gems/danger-8.6.1/lib/danger/danger_core/dangerfile.rb:201:in `instance_eval'
from /builds/gitlab-org/gitlab/vendor/ruby/3.0.0/gems/danger-8.6.1/lib/danger/danger_core/dangerfile.rb:201:in `parse'
helper.current_milestone
is fetched from the GitLab API in https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/-/blob/0ab311fd47ea98774d8e83366474356c596f8278/lib/danger/plugins/internal/helper.rb#L479-483
The problem with this is that it only fetches the first page. Because we have lots of old milestones open, the current unexpired milestone is in the 2nd page.
As a quick fix, I closed the old milestones so that 16.3 appears in the first page.
We should do a proper fix for this though by automating the closing of milestones or maybe adding a expired=false
option to the GitLab milestones API.