Skip to content

Commit

Permalink
Merge pull request #6038 from asdil12/sym
Browse files Browse the repository at this point in the history
Resolve symlinks before enqueuing git_clone GRU task
  • Loading branch information
mergify[bot] authored Oct 31, 2024
2 parents 529d06f + 8fbc9f3 commit a960523
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 10 additions & 2 deletions lib/OpenQA/Shared/Plugin/Gru.pm
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,16 @@ sub enqueue_git_clones ($self, $clones, $job_ids) {
return unless OpenQA::App->singleton->config->{'scm git'}->{git_auto_clone} eq 'yes';
# $clones is a hashref with paths as keys and git urls as values
# $job_id is used to create entries in a related table (gru_dependencies)
my $found = $self->_find_existing_minion_job('git_clone', $clones, $job_ids);
$self->enqueue('git_clone', $clones, {priority => 10}, $job_ids) unless $found;

# resolve all symlinks in keys of $clones to allow _find_existing_minion_job find and skip identical jobs
my $clones_sr = {};
for my $path (keys %$clones) {
my $path_sr = eval { path($path)->realpath } // $path;
$clones_sr->{$path_sr} = $clones->{$path};
}

my $found = $self->_find_existing_minion_job('git_clone', $clones_sr, $job_ids);
$self->enqueue('git_clone', $clones_sr, {priority => 10}, $job_ids) unless $found;
}

sub enqueue_and_keep_track {
Expand Down
6 changes: 3 additions & 3 deletions t/api/04-jobs.t
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,7 @@ subtest 'handle git_clone with CASEDIR' => sub {
my $gru_task_values = shift @gru_args;
is_deeply $gru_task_values,
{
't/data/openqa/share/tests/foobar' => 'http://localhost/foo.git',
path('t/data/openqa/share/tests/foobar')->realpath => 'http://localhost/foo.git',
't/data/openqa/share/tests/foobar/needles' => 'http://localhost/bar.git'
},
'the git clone gru tasks were created correctly';
Expand Down Expand Up @@ -1673,8 +1673,8 @@ subtest 'handle git_clone without CASEDIR' => sub {
[
[
{
't/data/openqa/share/tests/needles' => undef,
't/data/openqa/share/tests' => undef,
path('t/data/openqa/share/tests')->realpath => undef,
path('t/data/openqa/share/tests/needles')->realpath => undef,
}]
],
'the git_clone gru tasks was created correctly';
Expand Down

0 comments on commit a960523

Please sign in to comment.