|
108 | 108 | fi
|
109 | 109 | }
|
110 | 110 |
|
| 111 | +create_job_runner_config() { |
| 112 | + # we never want to push to real GitHub branches in this test |
| 113 | + run_args="'--volume=$MYDIR/mock-git-push:/usr/local/bin/git:ro'" |
| 114 | + |
| 115 | + if [ "$1" = "mock" ]; then |
| 116 | + forge_opts="api-url = '$GHAPI_URL_POD'" |
| 117 | + # needs to run in pod network so that it can access GITHUB_API_POD |
| 118 | + run_args="${run_args}, '--pod=cockpituous'" |
| 119 | + run_args="${run_args}, '--env=GITHUB_API=$GHAPI_URL_POD', '--env=COCKPIT_IMAGE_UPLOAD_STORE=$S3_URL_POD/images/'" |
| 120 | + elif [ "$1" = "real" ]; then |
| 121 | + forge_opts="" |
| 122 | + else |
| 123 | + echo "ERROR: unknown job-runner config $1" >&2 |
| 124 | + exit 1 |
| 125 | + fi |
| 126 | + |
| 127 | + cat <<EOF > $SECRETS/tasks/job-runner.toml |
| 128 | +[logs] |
| 129 | +driver='s3' |
| 130 | +
|
| 131 | +[forge.github] |
| 132 | +token = "$(cat $SECRETS/webhook/.config--github-token)" |
| 133 | +$forge_opts |
| 134 | +
|
| 135 | +[logs.s3] |
| 136 | +url = '$S3_URL_POD/logs' |
| 137 | +ca = [{file='/run/secrets/webhook/ca.pem'}] |
| 138 | +# ~/.config/cockpit-dev/s3-keys/localhost.localdomain |
| 139 | +key = {access='cockpituous', secret='foobarfoo'} |
| 140 | +
|
| 141 | +[container] |
| 142 | +command = ['podman-remote', '--url=unix:///podman.sock'] |
| 143 | +run-args = [$run_args] |
| 144 | +
|
| 145 | +[container.secrets] |
| 146 | +# these are *host* paths, this is podman-remote |
| 147 | +image-upload=[ |
| 148 | + '--volume=$SECRETS/tasks/s3-keys:/run/secrets/s3-keys:ro', |
| 149 | + '--env=COCKPIT_S3_KEY_DIR=/run/secrets/s3-keys', |
| 150 | + '--volume=$SECRETS/webhook/ca.pem:/run/secrets/ca.pem:ro', |
| 151 | + '--env=COCKPIT_CA_PEM=/run/secrets/ca.pem', |
| 152 | +] |
| 153 | +github-token=[ |
| 154 | + '--volume=$SECRETS/webhook/.config--github-token:/run/secrets/github-token:ro', |
| 155 | + '--env=COCKPIT_GITHUB_TOKEN_FILE=/run/secrets/github-token', |
| 156 | +] |
| 157 | +EOF |
| 158 | +} |
| 159 | + |
111 | 160 | launch_containers() {
|
112 | 161 | cleanup() {
|
113 | 162 | if [ $? -ne 0 ] && [ -z "$INTERACTIVE" ] && [ -t 0 ]; then
|
|
189 | 238 | --env=COCKPIT_BOTS_REPO=${COCKPIT_BOTS_REPO:-} \
|
190 | 239 | --env=COCKPIT_BOTS_BRANCH=${COCKPIT_BOTS_BRANCH:-} \
|
191 | 240 | --env=COCKPIT_TESTMAP_INJECT=main/unit-tests \
|
| 241 | + --env=JOB_RUNNER_CONFIG=/run/secrets/tasks/job-runner.toml \ |
192 | 242 | --env=AMQP_SERVER=$AMQP_POD \
|
193 | 243 | --env=S3_LOGS_URL=$S3_URL_POD/logs/ \
|
194 | 244 | --env=COCKPIT_S3_KEY_DIR=/run/secrets/tasks/s3-keys \
|
@@ -251,6 +301,7 @@ test_image() {
|
251 | 301 |
|
252 | 302 | test_mock_pr() {
|
253 | 303 | podman cp "$MYDIR/mock-github" cockpituous-tasks:/work/bots/mock-github
|
| 304 | + create_job_runner_config mock |
254 | 305 | podman exec -i cockpituous-tasks sh -euxc "
|
255 | 306 | cd bots
|
256 | 307 | # test mock PR against our checkout, so that cloning will work
|
@@ -292,6 +343,7 @@ test_mock_pr() {
|
292 | 343 | test_pr() {
|
293 | 344 | # need to use real GitHub token for this
|
294 | 345 | [ -z "$TOKEN" ] || cp -fv "$TOKEN" "$SECRETS"/webhook/.config--github-token
|
| 346 | + create_job_runner_config real |
295 | 347 |
|
296 | 348 | # run the main loop in the background; we could do this with a single run-queue invocation,
|
297 | 349 | # but we want to test the cockpit-tasks script
|
@@ -347,6 +399,7 @@ test_pr() {
|
347 | 399 | test_mock_image_refresh() {
|
348 | 400 | podman cp "$MYDIR/mock-github" cockpituous-tasks:/work/bots/mock-github
|
349 | 401 | podman cp "$MYDIR/mock-git-push" cockpituous-tasks:/usr/local/bin/git
|
| 402 | + create_job_runner_config mock |
350 | 403 |
|
351 | 404 | podman exec -i cockpituous-tasks sh -euxc "
|
352 | 405 | cd bots
|
|
0 commit comments