diff --git a/lib/DB.rakumod b/lib/DB.rakumod index 7dfadf4..bbd3923 100644 --- a/lib/DB.rakumod +++ b/lib/DB.rakumod @@ -7,10 +7,13 @@ class SourceSpec { has Str $.rakudo-git-url = config.projects.rakudo.repo-url; has SHA1 $.rakudo-commit-sha = 'LATEST'; + has Str $.rakudo-fetch-ref; has Str $.nqp-git-url = config.projects.nqp.repo-url; has SHA1 $.nqp-commit-sha = 'LATEST'; + has Str $.nqp-fetch-ref; has Str $.moar-git-url = config.projects.moar.repo-url; has SHA1 $.moar-commit-sha = 'LATEST'; + has Str $.moar-fetch-ref; submethod TWEAK() { $!rakudo-commit-sha .= uc; @@ -157,10 +160,13 @@ model CITestSet is rw is table { has Str $!rakudo-git-url is column{ :nullable }; has Str $!rakudo-commit-sha is column{ :nullable }; + has Str $!rakudo-fetch-ref is column{ :nullable }; has Str $!nqp-git-url is column{ :nullable }; has Str $!nqp-commit-sha is column{ :nullable }; + has Str $!nqp-fetch-ref is column{ :nullable }; has Str $!moar-git-url is column{ :nullable }; has Str $!moar-commit-sha is column{ :nullable }; + has Str $!moar-fetch-ref is column{ :nullable }; has Str $.source-archive-id is column{ :nullable, :type }; has UInt $.source-retrieval-retries is column = 0; @@ -173,19 +179,25 @@ model CITestSet is rw is table { multi method source-spec($spec) { $!rakudo-git-url = $spec.rakudo-git-url; $!rakudo-commit-sha = $spec.rakudo-commit-sha; + $!rakudo-fetch-ref = $spec.rakudo-fetch-ref; $!nqp-git-url = $spec.nqp-git-url; $!nqp-commit-sha = $spec.nqp-commit-sha; + $!nqp-fetch-ref = $spec.nqp-fetch-ref; $!moar-git-url = $spec.moar-git-url; $!moar-commit-sha = $spec.moar-commit-sha; + $!moar-fetch-ref = $spec.moar-fetch-ref; } multi method source-spec() { SourceSpec.new( rakudo-git-url => $!rakudo-git-url // "", rakudo-commit-sha => $!rakudo-commit-sha // "", + rakudo-fetch-ref => $!rakudo-fetch-ref // "", nqp-git-url => $!nqp-git-url // "", nqp-commit-sha => $!nqp-commit-sha // "", + nqp-fetch-ref => $!nqp-fetch-ref // "", moar-git-url => $!moar-git-url // "", moar-commit-sha => $!moar-commit-sha // "", + moar-fetch-ref => $!moar-fetch-ref // "", ) } } diff --git a/lib/GitHubCITestRequester.rakumod b/lib/GitHubCITestRequester.rakumod index 303df06..aa29579 100644 --- a/lib/GitHubCITestRequester.rakumod +++ b/lib/GitHubCITestRequester.rakumod @@ -276,6 +276,8 @@ method process-worklist() is serial-dedup { # NOT the head (the repo where the new commits are). # Using the head repo will not work, as that's usually a different repo where the RCB is # not installed on and thus has no permissons to add check_runs. + # In addition it's possible there is no head repo. That is the case when the branch or repo a + # PR is based on has been deleted. # One would think using the base repo can't work, because the commits are not part of that # repository. But there is some almost completely undocumented behavior in GitHub that copies # PR commits to the base repo and even creates merge commits (without the PR being merged!). @@ -330,7 +332,8 @@ method process-worklist() is serial-dedup { method !determine-source-spec(:$project!, :$git-url!, :$commit-sha!, :$pr --> SourceSpec) { my ($rakudo-git-url, $nqp-git-url, $moar-git-url, - $rakudo-commit-sha, $nqp-commit-sha, $moar-commit-sha); + $rakudo-commit-sha, $nqp-commit-sha, $moar-commit-sha, + $rakudo-fetch-ref, $nqp-fetch-ref, $moar-fetch-ref); my $did-things = False; with $pr { my %head-data = self!github-url-to-project-repo($pr.head-url); @@ -354,13 +357,14 @@ method !determine-source-spec(:$project!, :$git-url!, :$commit-sha!, :$pr --> So my $branch = $pr.head-branch; - for DB::RAKUDO, $rakudo-git-url, $rakudo-commit-sha, $r-proj, $r-repo, - DB::NQP, $nqp-git-url, $nqp-commit-sha, $n-proj, $n-repo, - DB::MOAR, $moar-git-url, $moar-commit-sha, $m-proj, $m-repo - -> $cur-proj, $out-url is rw, $out-commit-sha is rw, $gh-project, $repo { + for DB::RAKUDO, $rakudo-git-url, $rakudo-commit-sha, $rakudo-fetch-ref, $r-proj, $r-repo, + DB::NQP, $nqp-git-url, $nqp-commit-sha, $nqp-fetch-ref, $n-proj, $n-repo, + DB::MOAR, $moar-git-url, $moar-commit-sha, $moar-fetch-ref, $m-proj, $m-repo + -> $cur-proj, $out-url is rw, $out-commit-sha is rw, $out-fetch-ref is rw, $gh-project, $repo { if $cur-proj == $project { - $out-url = $git-url; + $out-url = $pr.base-url; $out-commit-sha = $commit-sha; + $out-fetch-ref = "pull/{$pr.number}/head"; } else { my $branch-data = $!github-interface.get-branch(:owner($gh-project), :$repo, :$branch); @@ -381,18 +385,39 @@ method !determine-source-spec(:$project!, :$git-url!, :$commit-sha!, :$pr --> So } } if !$did-things { - given $project { - when DB::RAKUDO { - $rakudo-git-url = $git-url; - $rakudo-commit-sha = $commit-sha; - } - when DB::NQP { - $nqp-git-url = $git-url; - $nqp-commit-sha = $commit-sha; + with $pr { + given $project { + when DB::RAKUDO { + $rakudo-git-url = $pr.base-url; + $rakudo-commit-sha = $commit-sha; + $rakudo-fetch-ref = "pull/{$pr.number}/head"; + } + when DB::NQP { + $nqp-git-url = $pr.base-url; + $nqp-commit-sha = $commit-sha; + $nqp-fetch-ref = "pull/{$pr.number}/head"; + } + when DB::MOAR { + $moar-git-url = $pr.base-url; + $moar-commit-sha = $commit-sha; + $moar-fetch-ref = "pull/{$pr.number}/head"; + } } - when DB::MOAR { - $moar-git-url = $git-url; - $moar-commit-sha = $commit-sha; + } + else { + given $project { + when DB::RAKUDO { + $rakudo-git-url = $git-url; + $rakudo-commit-sha = $commit-sha; + } + when DB::NQP { + $nqp-git-url = $git-url; + $nqp-commit-sha = $commit-sha; + } + when DB::MOAR { + $moar-git-url = $git-url; + $moar-commit-sha = $commit-sha; + } } } } @@ -400,10 +425,13 @@ method !determine-source-spec(:$project!, :$git-url!, :$commit-sha!, :$pr --> So return SourceSpec.new: |($rakudo-git-url ?? :$rakudo-git-url !! ()), |($rakudo-commit-sha ?? :$rakudo-commit-sha !! ()), + |($rakudo-fetch-ref ?? :$rakudo-fetch-ref !! ()), |($nqp-git-url ?? :$nqp-git-url !! ()), |($nqp-commit-sha ?? :$nqp-commit-sha !! ()), + |($nqp-fetch-ref ?? :$nqp-fetch-ref !! ()), |($moar-git-url ?? :$moar-git-url !! ()), |($moar-commit-sha ?? :$moar-commit-sha !! ()), + |($moar-fetch-ref ?? :$moar-fetch-ref !! ()), } method !github-url-to-project-repo($url) { diff --git a/lib/SourceArchiveCreator.rakumod b/lib/SourceArchiveCreator.rakumod index 97695f6..b50a731 100644 --- a/lib/SourceArchiveCreator.rakumod +++ b/lib/SourceArchiveCreator.rakumod @@ -108,10 +108,10 @@ method create-archive(DB::CITestSet $test-set) { } my @shas; - for $!rakudo-dir, $source-spec.rakudo-git-url, $source-spec.rakudo-commit-sha, config.projects.rakudo.main, - $!nqp-dir, $source-spec.nqp-git-url, $source-spec.nqp-commit-sha, config.projects.nqp.main, - $!moar-dir, $source-spec.moar-git-url, $source-spec.moar-commit-sha, config.projects.moar.main - -> $repo-dir, $remote, $commit, $main { + for $!rakudo-dir, $source-spec.rakudo-git-url, $source-spec.rakudo-commit-sha, $source-spec.rakudo-fetch-ref, config.projects.rakudo.main, + $!nqp-dir, $source-spec.nqp-git-url, $source-spec.nqp-commit-sha, $source-spec.nqp-fetch-ref, config.projects.nqp.main, + $!moar-dir, $source-spec.moar-git-url, $source-spec.moar-commit-sha, $source-spec.moar-fetch-ref, config.projects.moar.main + -> $repo-dir, $remote, $commit, $fetch-ref, $main { debug "SourceArchiveCreator: working on " ~ $remote ~ " " ~ $commit; my $tmp-branch = 'tmp-branch'; @@ -121,8 +121,7 @@ method create-archive(DB::CITestSet $test-set) { validate run qw|git remote add|, $tmp-branch, $remote, :cwd($repo-dir), :merge; - #validate run qw|git fetch|, $tmp-branch, |($.fetch-ref ?? ("+refs/" ~ $.fetch-ref ~ ":refs/remotes/" ~ $.fetch-ref,) !! ()), - validate run qw|git fetch|, $tmp-branch, + validate run qw|git fetch|, $tmp-branch, |($fetch-ref ?? ("+refs/" ~ $fetch-ref ~ ":refs/remotes/" ~ $fetch-ref,) !! ()), :cwd($repo-dir), :merge; my $ref = $commit eq 'LATEST' ?? "$tmp-branch/$main" !! $commit;