From e8448e380799a8839f2422553843e65fee1fb066 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 6 Oct 2023 16:17:12 +0200 Subject: [PATCH 1/3] examples/docker-compose: upgrade to runner 3.0.1 --- examples/docker-compose/compose-forgejo-and-runner.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/docker-compose/compose-forgejo-and-runner.yml b/examples/docker-compose/compose-forgejo-and-runner.yml index 18e8111..05a5110 100644 --- a/examples/docker-compose/compose-forgejo-and-runner.yml +++ b/examples/docker-compose/compose-forgejo-and-runner.yml @@ -46,7 +46,7 @@ services: - 8080:3000 runner-register: - image: code.forgejo.org/forgejo/runner:3.0.0 + image: code.forgejo.org/forgejo/runner:3.0.1 links: - docker-in-docker - forgejo @@ -67,7 +67,7 @@ services: ' runner-daemon: - image: code.forgejo.org/forgejo/runner:3.0.0 + image: code.forgejo.org/forgejo/runner:3.0.1 links: - docker-in-docker - forgejo From bf11dac84818afcbe22445e0ce2e456e9791d209 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 6 Oct 2023 16:18:09 +0200 Subject: [PATCH 2/3] examples/docker-compose: network: host is required otherwise a network will be created with no route to the forgejo instance and a checkout will fail to reach it --- examples/docker-compose/compose-demo-workflow.yml | 2 +- examples/docker-compose/compose-forgejo-and-runner.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/docker-compose/compose-demo-workflow.yml b/examples/docker-compose/compose-demo-workflow.yml index 1ce2fee..663dc53 100644 --- a/examples/docker-compose/compose-demo-workflow.yml +++ b/examples/docker-compose/compose-demo-workflow.yml @@ -19,7 +19,7 @@ services: cd /srv/demo ; git init --initial-branch=main ; mkdir -p .forgejo/workflows ; - echo "{ on: [push], jobs: { test: { runs-on: docker, steps: [ { run: echo All Good } ] } } }" > .forgejo/workflows/demo.yml ; + echo "{ on: [push], jobs: { test: { runs-on: docker, steps: [ {uses: actions/checkout@v4}, { run: echo All Good } ] } } }" > .forgejo/workflows/demo.yml ; git add . ; git config user.email root@example.com ; git config user.name username ; diff --git a/examples/docker-compose/compose-forgejo-and-runner.yml b/examples/docker-compose/compose-forgejo-and-runner.yml index 05a5110..ae432b9 100644 --- a/examples/docker-compose/compose-forgejo-and-runner.yml +++ b/examples/docker-compose/compose-forgejo-and-runner.yml @@ -62,6 +62,7 @@ services: sleep 1 ; done ; forgejo-runner generate-config > config.yml ; + sed -i -e "s|network: .*|network: host|" config.yml ; sed -i -e "s|labels: \[\]|labels: \[\"docker:docker://alpine:3.18\"\]|" config.yml ; chown -R 1000:1000 /data ' From 9cb0716425d987aeabffb0ea47855098b5aaf764 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 6 Oct 2023 16:19:55 +0200 Subject: [PATCH 3/3] examples/docker-compose: fix false positive because of the -x the success string was always in the output and the workflow .forgejo/workflows/example-docker-compose.yml would always report success, even if it fails --- .forgejo/workflows/example-docker-compose.yml | 4 +++- examples/docker-compose/compose-demo-workflow.yml | 12 ++++++------ .../docker-compose/compose-forgejo-and-runner.yml | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.forgejo/workflows/example-docker-compose.yml b/.forgejo/workflows/example-docker-compose.yml index b0fd7c8..1b9c2e0 100644 --- a/.forgejo/workflows/example-docker-compose.yml +++ b/.forgejo/workflows/example-docker-compose.yml @@ -42,11 +42,13 @@ jobs: # $cli ps --help success='DEMO WORKFLOW SUCCESS' + failure='DEMO WORKFLOW FAILURE' for delay in $(seq 60) ; do $cli logs -n 10 demo-workflow > /tmp/out grep --quiet "$success" /tmp/out && break + grep --quiet "$failure" /tmp/out && break $cli ps --all - cat /tmp/out + tail /tmp/out sleep 10 done if ! grep --quiet "$success" /tmp/out ; then diff --git a/examples/docker-compose/compose-demo-workflow.yml b/examples/docker-compose/compose-demo-workflow.yml index 663dc53..0e44c59 100644 --- a/examples/docker-compose/compose-demo-workflow.yml +++ b/examples/docker-compose/compose-demo-workflow.yml @@ -13,7 +13,7 @@ services: runner-register: condition: service_completed_successfully command: >- - sh -xc ' + sh -ec ' apk add --quiet git curl jq ; mkdir -p /srv/demo ; cd /srv/demo ; @@ -29,10 +29,10 @@ services: sleep 5 ; done ; sha=`git rev-parse HEAD` ; - while : ; do + for delay in 1 1 1 1 2 5 5 10 10 10 15 ; do curl -sS -f http://forgejo:3000/api/v1/repos/root/test/commits/$$sha/status | jq --raw-output .state | tee status ; - grep success status && break ; - sleep 5 ; - done ; - echo DEMO WORKFLOW SUCCESS + if grep success status ; then echo DEMO WORKFLOW SUCCESS && break ; fi ; + if grep failure status ; then echo DEMO WORKFLOW FAILURE && break ; fi ; + sleep $$delay ; + done ' diff --git a/examples/docker-compose/compose-forgejo-and-runner.yml b/examples/docker-compose/compose-forgejo-and-runner.yml index ae432b9..9ec1a89 100644 --- a/examples/docker-compose/compose-forgejo-and-runner.yml +++ b/examples/docker-compose/compose-forgejo-and-runner.yml @@ -56,7 +56,7 @@ services: - /srv/runner-data:/data user: 0:0 command: >- - bash -c ' + bash -ec ' while : ; do forgejo-runner create-runner-file --instance http://forgejo:3000 --name runner --secret {SHARED_SECRET} && break ; sleep 1 ;