Skip to content

Commit

Permalink
Expand on the help for the mentions check
Browse files Browse the repository at this point in the history
In particular, suggest rebasing
  • Loading branch information
zdrve committed Dec 14, 2023
1 parent 1552a79 commit 9334f73
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
28 changes: 26 additions & 2 deletions lib/kennel/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def git_push?

# ideally do this on every run, but it's slow (~1.5s) and brittle (might not find all + might find false-positives)
# https://help.datadoghq.com/hc/en-us/requests/254114 for automatic validation
desc "Verify that all used monitor mentions are valid"
desc "Verify that all used monitor mentions are valid"
task validate_mentions: :environment do
known = Kennel::Api.new
.send(:request, :get, "/monitor/notifications")
Expand All @@ -91,7 +91,31 @@ def git_push?

if bad.any?
url = Kennel::Utils.path_to_url "/account/settings"
Kennel.out.puts "Invalid mentions found, either ignore them by adding to `KNOWN` env var or add them via #{url}"

Kennel.out.puts <<~MESSAGE
⛔️ Possibly invalid mentions found ⛔️
The monitor definitions in `generated` include at least one mention
that isn't currently in Datadog. See the list below for exactly what
was found.
This check exists to protect against typos in mentions, mentioning
non-existent targets, etc.
How to resolve this:
- If the problems listed below are nothing to do with what you're
changing on this branch, then rebase onto a fresh `#{ENV.fetch("DEFAULT_BRANCH", "master")}`
- If the problems listed below seem valid, i.e. a typo or other mistake,
then fix them :-)
- If you want to mention someone new, someone whom no existing monitor
currently mentions, then you can allow-list them by adding to the
`KNOWN` environment variable, or by adding them in #{url}"
MESSAGE

bad.each { |f, v| Kennel.out.puts "Invalid mention #{v} in monitor message of #{f}" }
Kennel::Tasks.abort ENV["KNOWN_WARNING"]
end
Expand Down
2 changes: 1 addition & 1 deletion test/kennel/tasks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def execute(...)
it "fails when unknown mentions are used" do
content[:message] = "@oo@ps"
assert_raises { execute }.message.must_equal "Aborted SystemExit"
stdout.string.must_include "Invalid mentions"
stdout.string.downcase.must_include "invalid mentions"
end
end

Expand Down

0 comments on commit 9334f73

Please sign in to comment.