Skip to content

Commit

Permalink
tasks: Create job-runner.toml in run-local.sh
Browse files Browse the repository at this point in the history
This still needs to happen for production, but allows us to start
testing cockpit-project/bots#6017.
  • Loading branch information
martinpitt authored and allisonkarlitskaya committed Mar 6, 2024
1 parent 493ee86 commit 57c8282
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tasks/run-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,38 @@ EOF
# for the same reason, make podman socket accessible to that container user
# the directory is only accessible for the user, so 666 permissions don't hurt
chmod o+rw ${XDG_RUNTIME_DIR:-/run}/podman/podman.sock

# default to dummy job-runner config
create_job_runner_config
fi
}

create_job_runner_config() {
forge_opts="${1:-}"
cat <<EOF > $SECRETS/tasks/job-runner.toml
[logs]
driver='s3'
[forge.github]
token = "$(cat $SECRETS/webhook/.config--github-token)"
$forge_opts
[logs.s3]
url = '$S3_URL_POD/logs'
ca = [{file='/run/secrets/webhook/ca.pem'}]
# ~/.config/cockpit-dev/s3-keys/localhost.localdomain
key = {access='cockpituous', secret='foobarfoo'}
[container]
command = ['podman-remote', '--url=unix:///podman.sock']
[container.secrets]
# these are *host* paths, this is podman-remote
image-upload=['--volume=$SECRETS/tasks/s3-keys:/run/secrets/tasks/s3-keys:ro']
github-token=['--volume=$SECRETS/webhook/.config--github-token:/run/secrets/webhook/.config--github-token:ro']
EOF
}

launch_containers() {
cleanup() {
if [ $? -ne 0 ] && [ -z "$INTERACTIVE" ] && [ -t 0 ]; then
Expand Down Expand Up @@ -187,6 +216,7 @@ EOF
--env=COCKPIT_BOTS_REPO=${COCKPIT_BOTS_REPO:-} \
--env=COCKPIT_BOTS_BRANCH=${COCKPIT_BOTS_BRANCH:-} \
--env=COCKPIT_TESTMAP_INJECT=main/unit-tests \
--env=JOB_RUNNER_CONFIG=/run/secrets/tasks/job-runner.toml \
--env=AMQP_SERVER=$AMQP_POD \
--env=S3_LOGS_URL=$S3_URL_POD/logs/ \
--env=COCKPIT_S3_KEY_DIR=/run/secrets/tasks/s3-keys \
Expand Down Expand Up @@ -249,6 +279,7 @@ test_image() {

test_mock_pr() {
podman cp "$MYDIR/mock-github" cockpituous-tasks:/work/bots/mock-github
create_job_runner_config "api-url = 'http://127.0.0.7:8443'"
podman exec -i cockpituous-tasks sh -euxc "
cd bots
# test mock PR against our checkout, so that cloning will work
Expand Down Expand Up @@ -290,6 +321,8 @@ test_mock_pr() {
test_pr() {
# need to use real GitHub token for this
[ -z "$TOKEN" ] || cp -fv "$TOKEN" "$SECRETS"/webhook/.config--github-token
# update job runner config with real token
create_job_runner_config

# run the main loop in the background; we could do this with a single run-queue invocation,
# but we want to test the cockpit-tasks script
Expand Down

0 comments on commit 57c8282

Please sign in to comment.