Skip to content

Commit e0ea762

Browse files
committed
tasks: Create job-runner.toml in run-local.sh
This still needs to happen for production, but allows us to start testing cockpit-project/bots#6017.
1 parent 6d8f6ae commit e0ea762

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

tasks/run-local.sh

+53
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,55 @@ EOF
108108
fi
109109
}
110110

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+
111160
launch_containers() {
112161
cleanup() {
113162
if [ $? -ne 0 ] && [ -z "$INTERACTIVE" ] && [ -t 0 ]; then
@@ -189,6 +238,7 @@ EOF
189238
--env=COCKPIT_BOTS_REPO=${COCKPIT_BOTS_REPO:-} \
190239
--env=COCKPIT_BOTS_BRANCH=${COCKPIT_BOTS_BRANCH:-} \
191240
--env=COCKPIT_TESTMAP_INJECT=main/unit-tests \
241+
--env=JOB_RUNNER_CONFIG=/run/secrets/tasks/job-runner.toml \
192242
--env=AMQP_SERVER=$AMQP_POD \
193243
--env=S3_LOGS_URL=$S3_URL_POD/logs/ \
194244
--env=COCKPIT_S3_KEY_DIR=/run/secrets/tasks/s3-keys \
@@ -251,6 +301,7 @@ test_image() {
251301

252302
test_mock_pr() {
253303
podman cp "$MYDIR/mock-github" cockpituous-tasks:/work/bots/mock-github
304+
create_job_runner_config mock
254305
podman exec -i cockpituous-tasks sh -euxc "
255306
cd bots
256307
# test mock PR against our checkout, so that cloning will work
@@ -292,6 +343,7 @@ test_mock_pr() {
292343
test_pr() {
293344
# need to use real GitHub token for this
294345
[ -z "$TOKEN" ] || cp -fv "$TOKEN" "$SECRETS"/webhook/.config--github-token
346+
create_job_runner_config real
295347

296348
# run the main loop in the background; we could do this with a single run-queue invocation,
297349
# but we want to test the cockpit-tasks script
@@ -347,6 +399,7 @@ test_pr() {
347399
test_mock_image_refresh() {
348400
podman cp "$MYDIR/mock-github" cockpituous-tasks:/work/bots/mock-github
349401
podman cp "$MYDIR/mock-git-push" cockpituous-tasks:/usr/local/bin/git
402+
create_job_runner_config mock
350403

351404
podman exec -i cockpituous-tasks sh -euxc "
352405
cd bots

0 commit comments

Comments
 (0)