diff --git a/docker-compose.yml b/docker-compose.yml index c9de843a..fc488878 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -125,6 +125,7 @@ services: image: gogs/gogs:0.14 volumes: - gogs-data:/data + - ./resources/gogs/app.ini:/data/gogs/conf/app.ini ports: - "3002:3000" healthcheck: @@ -135,59 +136,41 @@ services: start_period: 15s gogs-bootstrap: - image: alpine/curl:8.12.1 + image: gogs/gogs:0.14 volumes: - gogs-data:/data depends_on: gogs: condition: service_healthy + entrypoint: /bin/sh environment: - GOGS_ADMIN_USERNAME=${GOGS_ADMIN_USERNAME:-utopia} - GOGS_ADMIN_PASSWORD=${GOGS_ADMIN_PASSWORD:-password} - GOGS_ADMIN_EMAIL=${GOGS_ADMIN_EMAIL:-utopia@example.com} - entrypoint: /bin/sh command: - - -ce + - -c - | - if [ -f /data/gogs/token.txt ]; then exit 0; fi - - apk add --no-cache jq - - curl -s -o /dev/null -X POST http://gogs:3000/install \ - -d db_type=SQLite3 \ - -d db_path=/data/gogs.db \ - -d app_name=Gogs \ - -d repo_root_path=/data/repositories \ - -d run_user=git \ - -d domain=gogs \ - -d http_port=3000 \ - -d app_url=http://gogs:3000/ \ - -d log_root_path=/data/gogs/log \ - -d default_branch=master \ - -d admin_name=$$GOGS_ADMIN_USERNAME \ - -d admin_passwd=$$GOGS_ADMIN_PASSWORD \ - -d admin_confirm_passwd=$$GOGS_ADMIN_PASSWORD \ - -d admin_email=$$GOGS_ADMIN_EMAIL \ - || true + USER=git /app/gogs/gogs admin create-user \ + --admin \ + --name $$GOGS_ADMIN_USERNAME \ + --password $$GOGS_ADMIN_PASSWORD \ + --email $$GOGS_ADMIN_EMAIL \ + --config /data/gogs/conf/app.ini || true - sleep 3 - - if ! grep -q '\[webhook\]' /data/gogs/conf/app.ini; then - printf '\n[webhook]\nDELIVER_TIMEOUT = 10\nSKIP_TLS_VERIFY = true\n' >> /data/gogs/conf/app.ini + if [ ! -f /data/gogs/token.txt ]; then + sleep 2 + TOKEN=$$(curl -s \ + -X POST \ + -u $$GOGS_ADMIN_USERNAME:$$GOGS_ADMIN_PASSWORD \ + -H "Content-Type: application/json" \ + -d "{\"name\":\"bootstrap\"}" \ + http://gogs:3000/api/v1/users/$$GOGS_ADMIN_USERNAME/tokens \ + | grep -o '"sha1":"[^"]*"' | cut -d'"' -f4) + if [ -z "$$TOKEN" ]; then echo "Failed to get token"; exit 1; fi + mkdir -p /data/gogs + echo $$TOKEN > /data/gogs/token.txt fi - RESPONSE=$$(curl -s -X POST http://gogs:3000/api/v1/users/$$GOGS_ADMIN_USERNAME/tokens \ - -H 'Content-Type: application/json' \ - -d "{\"name\":\"bootstrap-$$(date +%s)\"}" \ - -u $$GOGS_ADMIN_USERNAME:$$GOGS_ADMIN_PASSWORD) - echo "Token API response: $$RESPONSE" - - TOKEN=$$(echo "$$RESPONSE" | jq -r '.sha1') - if [ -z "$$TOKEN" ] || [ "$$TOKEN" = "null" ]; then echo 'Failed to extract token'; exit 1; fi - - mkdir -p /data/gogs - echo $$TOKEN > /data/gogs/token.txt - volumes: gitea-data: forgejo-data: diff --git a/resources/gogs/app.ini b/resources/gogs/app.ini new file mode 100644 index 00000000..84455215 --- /dev/null +++ b/resources/gogs/app.ini @@ -0,0 +1,31 @@ +BRAND_NAME = Gogs +RUN_USER = git +RUN_MODE = prod + +[database] +TYPE = sqlite3 +PATH = /data/gogs.db + +[repository] +ROOT = /data/repositories +DEFAULT_BRANCH = master + +[server] +DOMAIN = gogs +HTTP_PORT = 3000 +EXTERNAL_URL = http://gogs:3000/ +DISABLE_SSH = true + +[security] +INSTALL_LOCK = true +SECRET_KEY = aRandomString +LOCAL_NETWORK_ALLOWLIST = * + +[webhook] +DELIVER_TIMEOUT = 10 +SKIP_TLS_VERIFY = true + +[log] +MODE = file +LEVEL = Info +ROOT_PATH = /data/gogs/log diff --git a/tests/VCS/Adapter/GogsTest.php b/tests/VCS/Adapter/GogsTest.php index 2f79cf2f..fe291fa5 100644 --- a/tests/VCS/Adapter/GogsTest.php +++ b/tests/VCS/Adapter/GogsTest.php @@ -61,11 +61,6 @@ protected function setupGogs(): void } } - // Webhook delivery (Gogs queues but does not deliver webhooks in test environment) - public function testWebhookPushEvent(): void - { - $this->markTestSkipped('Gogs webhook delivery not working in test environment'); - } // --- Skip tests for unsupported Gogs features ---