Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add update_activity errors to aggregated errors for mailing #5958

Merged
merged 5 commits into from
Nov 25, 2024
Merged
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
15 changes: 13 additions & 2 deletions app/models/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def process_activities
dirs = activity_dirs
errors = []

# Read all config files and dirconfig files in the activity directories
# filter out the invalid ones and keep track of them to make a single error report at the end
activity_dirs_and_configs = dirs.map do |d|
Pathname.new('./').join(activity_relative_path(d)).parent.descend.each do |p|
read_config_file(full_path.join(p, Activity::DIRCONFIG_FILE))
Expand All @@ -146,14 +148,23 @@ def process_activities
nil
end.compact

# Read the outermost dirconfig file
# if it contains errors, don't process any activities
begin
read_config_file(full_path.join(Activity::DIRCONFIG_FILE))
rescue ConfigParseError => e
errors.push e
activity_dirs_and_configs = []
end

existing_activities = activity_dirs_and_configs
.reject { |_, c| c['internals'].nil? || c['internals']['token'].nil? }
.map { |d, c| [d, Activity.find_by(repository_token: c['internals']['token'], repository_id: id)] }
# rubocop:disable Style/CollectionCompact
# This is a false positive for Hash#compact, where this is Array#compact
.reject { |_, e| e.nil? }
.reject { |_, a| a.nil? }
# rubocop:enable Style/CollectionCompact
.group_by { |_, e| e }
.group_by { |_, a| a }
.transform_values { |l| l.pluck(0) }
handled_directories = []
handled_activity_ids = []
Expand Down