Skip to content

Commit

Permalink
tasks: Add cockpituous refs/heads/main mock API endpoint
Browse files Browse the repository at this point in the history
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
  • Loading branch information
martinpitt committed Mar 12, 2024
1 parent a7ec360 commit 1609bd4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tasks/mock-github
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ argparser.add_argument('--print-pr-event', action='store_true',
argparser.add_argument('--print-image-refresh-event', action='store_true',
help="Print GitHub webhook issue event for an image-refresh and exit")
argparser.add_argument('--log', metavar="PATH", help="Log requests to this file")
argparser.add_argument('--cockpituous-sha', metavar="SHA", help="resolve cockpituous main branch to this SHA")
argparser.add_argument('repo', metavar='USER/PROJECT', help="GitHub user/org and project name")
argparser.add_argument('sha', help="SHA to test in repo for the mock PR")
args = argparser.parse_args()
Expand Down Expand Up @@ -112,6 +113,11 @@ GITHUB_DATA = {
f'/repos/{repo}/git/ref/heads/main': {
'object': {'sha': sha},
},
# for cross-project test; job-runner uses it to determine the clone SHA
'/repos/cockpit-project/cockpituous/git/refs/heads/main': {
# that fallback is strictly wrong, but good enough
'object': {'sha': args.cockpituous_sha or "main"},
},
}

if args.print_pr_event:
Expand Down

0 comments on commit 1609bd4

Please sign in to comment.