diff --git a/gems/gitlab-housekeeper/.gitlab-ci.yml b/gems/gitlab-housekeeper/.gitlab-ci.yml index 2d7f34238a2ce332d9859832f5bb998e9666294d..f1b159969047584a444ccf0d3e06cb67a42a821b 100644 --- a/gems/gitlab-housekeeper/.gitlab-ci.yml +++ b/gems/gitlab-housekeeper/.gitlab-ci.yml @@ -2,3 +2,15 @@ include: - local: gems/gem.gitlab-ci.yml inputs: gem_name: "gitlab-housekeeper" + +gitlab-housekeeper-integration-test: + script: + - mkdir -p keeps + - cp spec/fixtures/pretty_useless_keep.rb keeps/ + - git init --initial-branch=master + - 'git config --global user.email "test@example.com"' + - 'git config --global user.name "Test User"' + - 'git commit --allow-empty -m "Initial commit"' + - bundle exec bin/gitlab-housekeeper -k Keeps::PrettyUselessKeep -d + - bundle exec bin/gitlab-housekeeper -k Keeps::PrettyUselessKeep -d -m 3 + - bundle exec bin/gitlab-housekeeper -k Keeps::PrettyUselessKeep -d -m 3 --filter-identifiers=2 diff --git a/gems/gitlab-housekeeper/README.md b/gems/gitlab-housekeeper/README.md index 5523dea041604506c3ec8e2b25371dec1ed8845f..d32017d05c3419a169ca5e961bcc698b09950530 100644 --- a/gems/gitlab-housekeeper/README.md +++ b/gems/gitlab-housekeeper/README.md @@ -90,7 +90,7 @@ module Keeps This MR makes a new file #{file_name} MARKDOWN - change.labels = %w(type::feature) + change.labels = %w[type::feature] change.changed_files = [file_name] diff --git a/gems/gitlab-housekeeper/bin/gitlab-housekeeper b/gems/gitlab-housekeeper/bin/gitlab-housekeeper index 76ef41281894df1a5decf9c2cffcc5b3d5702cb0..3fb0c9447869674dc345be3666585043790f49b0 100755 --- a/gems/gitlab-housekeeper/bin/gitlab-housekeeper +++ b/gems/gitlab-housekeeper/bin/gitlab-housekeeper @@ -1,5 +1,7 @@ #!/usr/bin/env ruby +$:.unshift File.expand_path("../lib", __dir__) + require "optparse" require 'gitlab/housekeeper' diff --git a/gems/gitlab-housekeeper/spec/fixtures/pretty_useless_keep.rb b/gems/gitlab-housekeeper/spec/fixtures/pretty_useless_keep.rb new file mode 100644 index 0000000000000000000000000000000000000000..cf4d337d9162515fefce0c61973621c98b64d551 --- /dev/null +++ b/gems/gitlab-housekeeper/spec/fixtures/pretty_useless_keep.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Keeps + class PrettyUselessKeep < ::Gitlab::Housekeeper::Keep + def each_change + (1..3).each do |i| + file_name = "new_file#{i}.txt" + + `touch #{file_name}` + + change = ::Gitlab::Housekeeper::Change.new + + change.identifiers = [self.class.name.demodulize, "new_file#{i}"] + + change.title = "Make new file #{file_name}" + + change.description = <<~MARKDOWN + ## New files + + This MR makes a new file #{file_name} + MARKDOWN + + change.labels = %w[type::feature] + + change.changed_files = [file_name] + + # to push changes without triggering a pipeline. + change.push_options.ci_skip = true + + yield(change) + end + end + end +end