From 9a36582c77764f12173261a3476cda2446e54e33 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Wed, 27 Feb 2019 20:57:53 +0100 Subject: Have GitalyBot apply labels throught Danger Using Danger a small rule book, @GitalyBot will apply labels and have a few more rules on the changelog. --- Dangerfile | 44 ++++---------------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) (limited to 'Dangerfile') diff --git a/Dangerfile b/Dangerfile index f1bb16150..a06699f6c 100644 --- a/Dangerfile +++ b/Dangerfile @@ -1,42 +1,6 @@ -require 'yaml' -require 'json' - -fail("Please provide a MR description") if gitlab.mr_body.empty? - -def check_changelog(path) - if git.modified_files.include?("CHANGELOG.md") - fail("CHANGELOG.md was edited. Please remove the additions and create an entry with _support/changelog") - return - end - - if !git.added_files.include?(path) - warn("No changelog entry was generated, please do so by executing _support/changelog") - else - yaml = YAML.safe_load(File.read(path)) - - unless yaml['merge_request'] == gitlab.mr_json["iid"] - fail("Merge request ID was not set to #{gitlab.mr_json['iid']}") - end - - unless yaml['title'] == gitlab.mr_title - fail('Changelog entry should match the MR title') - end - end -end - -check_changelog(File.join('changelogs', 'unreleased', "#{gitlab.branch_for_head}.yml")) - -VENDOR_JSON = 'vendor/vendor.json' -fail("Expected #{VENDOR_JSON} to exist") unless File.exist?(VENDOR_JSON) - -if git.modified_files.include?(VENDOR_JSON) - parsed_json = JSON.parse(File.read(VENDOR_JSON)) - - proto = parsed_json["package"]&.find { |h| h["path"].start_with?("gitlab.com/gitlab-org/gitaly-proto") } - - unless proto["version"] && proto["version"] =~ /\Av\d+\./ - fail("gitaly-proto version is incorrect") - end -end +danger.import_dangerfile(path: 'danger/changelog') +danger.import_dangerfile(path: 'danger/govendor_proto_check') +danger.import_dangerfile(path: 'danger/labels') +danger.import_dangerfile(path: 'danger/merge_request') # vim: ft=ruby -- cgit v1.2.3