Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .simplecov
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ SimpleCov.start do
add_filter %r{^/(spec|config)/}
add_filter 'database_loader.rb'
add_filter 'workers/slack_username2_id.rb'
add_filter 'workers/github_notify_watch_dog.rb'
add_group 'Models', 'lib/models'
add_group 'GitHub Functions', 'lib/github'
add_group 'Bamboo CI Functions', 'lib/bamboo_ci'
Expand Down
1 change: 1 addition & 0 deletions config/delayed_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

require_relative '../lib/helpers/github_logger'
require_relative '../database_loader'
require_relative '../workers/github_notify_watch_dog'

require 'delayed_job'
require 'active_support'
Expand Down
1 change: 1 addition & 0 deletions lib/github_ci_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
require_relative '../workers/timeout_execution'
require_relative '../workers/ci_job_fetch_topotest_failures'
require_relative '../workers/slack_username2_id'
require_relative '../workers/github_notify_watch_dog'

# Slack libs
require_relative 'slack/slack'
Expand Down
11 changes: 11 additions & 0 deletions lib/slack_bot/slack_bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ def stage_in_progress_notification(stage)
end
end

def notify_watch_dog(slack_user_id, message)
url = "#{GitHubApp::Configuration.instance.config['slack_bot_url']}/github/user"

post_request(URI(url),
machine: 'slack_bot.netdef.org',
body: {
message: message,
slack_user_id: slack_user_id
}.to_json)
end

private

def current_execution?(check_suite)
Expand Down
32 changes: 32 additions & 0 deletions workers/github_notify_watch_dog.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# SPDX-License-Identifier: BSD-2-Clause
#
# github_notify_watch_dog.rb
# Part of NetDEF CI System
#
# Copyright (c) 2024 by
# Network Device Education Foundation, Inc. ("NetDEF")
#
# frozen_string_literal: true

class GithubNotifyWatchDog
class << self
def run
check_stages

GithubNotifyWatchDog
.delay(run_at: 1.hour.from_now.utc, queue: 'github_notify_watch_dog')
.run
end

def check_stages
Stage.where(status: :in_progress).where(updated_at: ..3.hour.ago).each do |stage|
GitHubApp::Configuration.instance.config['notify_users_when_stage_stuck']&.each do |slack_id|
SlackBot
.instance
.notify_watch_dog(slack_id,
"Stage #{stage.name} is stuck in progress - #{stage.check_suite.bamboo_ci_ref}")
end
end
end
end
end
Loading