Skip to content

Commit 1609bd4

Browse files
committed
tasks: Add cockpituous refs/heads/main mock API endpoint
job-runner needs that for cross-project testing [1]. A clean way would be to actually resolve "main" to a current SHA in the test, but as nothing actually cares, just rely on the `main` fallback for now -- nothing cares whether this is an actual SHA, as most things in git are happy with a "ref" -- and we don't use that to post statuses (and that would fail because the mock doesn't provide these paths). [1] cockpit-project/bots#6066
1 parent a7ec360 commit 1609bd4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tasks/mock-github

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ argparser.add_argument('--print-pr-event', action='store_true',
7373
argparser.add_argument('--print-image-refresh-event', action='store_true',
7474
help="Print GitHub webhook issue event for an image-refresh and exit")
7575
argparser.add_argument('--log', metavar="PATH", help="Log requests to this file")
76+
argparser.add_argument('--cockpituous-sha', metavar="SHA", help="resolve cockpituous main branch to this SHA")
7677
argparser.add_argument('repo', metavar='USER/PROJECT', help="GitHub user/org and project name")
7778
argparser.add_argument('sha', help="SHA to test in repo for the mock PR")
7879
args = argparser.parse_args()
@@ -112,6 +113,11 @@ GITHUB_DATA = {
112113
f'/repos/{repo}/git/ref/heads/main': {
113114
'object': {'sha': sha},
114115
},
116+
# for cross-project test; job-runner uses it to determine the clone SHA
117+
'/repos/cockpit-project/cockpituous/git/refs/heads/main': {
118+
# that fallback is strictly wrong, but good enough
119+
'object': {'sha': args.cockpituous_sha or "main"},
120+
},
115121
}
116122

117123
if args.print_pr_event:

0 commit comments

Comments
 (0)