Skip to content
Draft
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
29 changes: 27 additions & 2 deletions lib/OpenQA/Schema/Result/ScheduledProducts.pm
Original file line number Diff line number Diff line change
Expand Up @@ -763,9 +763,34 @@ sub _schedule_from_yaml ($self, $args, $skip_chained_deps, $include_children, @l
my $machines = $data->{machines} // {};
my $job_templates = $data->{job_templates};
my ($error_msg, %wanted, @job_templates);
my @flattened;
for my $key (sort keys %$job_templates) {
my $job_template = $job_templates->{$key};
my $settings = $job_template->{settings} // {};
my $template = $job_templates->{$key};
my %new_template = (%$template, name => $key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is never used as a hash so we could avoid hashing:

Suggested change
my %new_template = (%$template, name => $key);
my @new_template = (%$template, name => $key);

my @machines;
if ($key =~ s/\@\(([\w,-]+)\)$//) {
@machines = grep { length } split /,/, $1;
}
elsif ($template->{machine}) {
my $machine = delete $template->{machine};
if (ref $machine eq 'ARRAY') {
@machines = @$machine;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also remove empty machines here for the sake of consistency:

Suggested change
@machines = @$machine;
@machines = grep { length } @$machine;

}
else {
@machines = $machine;
}
}
else {
push @flattened, {%new_template};
next;
}
for my $machine (@machines) {
push @flattened, {%new_template, machine => $machine};
}
}
for my $job_template (@flattened) {
my $key = $job_template->{name};
my $settings = {%{$job_template->{settings} // {}}};
$settings->{TEST} = $key;
my @worker_class;
push @worker_class, $settings->{WORKER_CLASS} if $settings->{WORKER_CLASS};
Expand Down
8 changes: 6 additions & 2 deletions public/schema/JobScenarios-01.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,18 @@ properties:
type: object
additionalProperties: false
patternProperties:
^[\p{Word} _*.+-]+$:
^[\p{Word} _*.+-]+(\@\([\w,-]+\))?$:
type: object
description: The name of the job template
additionalProperties: false
properties:
product:
type: string
machine:
type: string
oneOf:
- type: string
- type: array
items:
- type: string
settings: *settings-definition
priority: *priority-definition