Skip to content

Commit 3b2e8bb

Browse files
authored
Merge pull request #80 from utopia-php/copilot/add-gogs-adapter-and-tests-again
Supporting Gogs integration with existing tools
2 parents 863361e + 90e6a4f commit 3b2e8bb

File tree

6 files changed

+758
-10
lines changed

6 files changed

+758
-10
lines changed

docker-compose.yml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ services:
88
- ./phpunit.xml:/usr/local/src/phpunit.xml
99
- gitea-data:/data:ro
1010
- forgejo-data:/forgejo-data:ro
11+
- gogs-data:/gogs-data:ro
1112
environment:
1213
- TESTS_GITHUB_PRIVATE_KEY
1314
- TESTS_GITHUB_APP_IDENTIFIER
1415
- TESTS_GITHUB_INSTALLATION_ID
1516
- TESTS_GITEA_URL=http://gitea:3000
1617
- TESTS_GITEA_REQUEST_CATCHER_URL=http://request-catcher:5000
1718
- TESTS_FORGEJO_URL=http://forgejo:3000
19+
- TESTS_GOGS_URL=http://gogs:3000
1820
depends_on:
1921
gitea:
2022
condition: service_healthy
@@ -24,6 +26,10 @@ services:
2426
condition: service_healthy
2527
forgejo-bootstrap:
2628
condition: service_completed_successfully
29+
gogs:
30+
condition: service_healthy
31+
gogs-bootstrap:
32+
condition: service_completed_successfully
2733
request-catcher:
2834
condition: service_started
2935

@@ -115,6 +121,58 @@ services:
115121
fi
116122
"
117123
124+
gogs:
125+
image: gogs/gogs:0.14
126+
volumes:
127+
- gogs-data:/data
128+
- ./resources/gogs/app.ini:/data/gogs/conf/app.ini
129+
ports:
130+
- "3002:3000"
131+
healthcheck:
132+
test: ["CMD", "curl", "-f", "http://localhost:3000/"]
133+
interval: 10s
134+
timeout: 5s
135+
retries: 10
136+
start_period: 15s
137+
138+
gogs-bootstrap:
139+
image: gogs/gogs:0.14
140+
volumes:
141+
- gogs-data:/data
142+
- ./resources/gogs/app.ini:/data/gogs/conf/app.ini
143+
depends_on:
144+
gogs:
145+
condition: service_healthy
146+
entrypoint: /bin/sh
147+
environment:
148+
- GOGS_ADMIN_USERNAME=${GOGS_ADMIN_USERNAME:-utopia}
149+
- GOGS_ADMIN_PASSWORD=${GOGS_ADMIN_PASSWORD:-password}
150+
- GOGS_ADMIN_EMAIL=${GOGS_ADMIN_EMAIL:-utopia@example.com}
151+
command:
152+
- -c
153+
- |
154+
USER=git /app/gogs/gogs admin create-user \
155+
--admin \
156+
--name $$GOGS_ADMIN_USERNAME \
157+
--password $$GOGS_ADMIN_PASSWORD \
158+
--email $$GOGS_ADMIN_EMAIL \
159+
--config /data/gogs/conf/app.ini || true
160+
161+
if [ ! -f /data/gogs/token.txt ]; then
162+
sleep 2
163+
TOKEN=$$(curl -s \
164+
-X POST \
165+
-u $$GOGS_ADMIN_USERNAME:$$GOGS_ADMIN_PASSWORD \
166+
-H "Content-Type: application/json" \
167+
-d "{\"name\":\"bootstrap\"}" \
168+
http://gogs:3000/api/v1/users/$$GOGS_ADMIN_USERNAME/tokens \
169+
| grep -o '"sha1":"[^"]*"' | cut -d'"' -f4)
170+
if [ -z "$$TOKEN" ]; then echo "Failed to get token"; exit 1; fi
171+
mkdir -p /data/gogs
172+
echo $$TOKEN > /data/gogs/token.txt
173+
fi
174+
118175
volumes:
119176
gitea-data:
120-
forgejo-data:
177+
forgejo-data:
178+
gogs-data:

resources/gogs/app.ini

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
BRAND_NAME = Gogs
2+
RUN_USER = git
3+
RUN_MODE = prod
4+
5+
[database]
6+
TYPE = sqlite3
7+
PATH = /data/gogs.db
8+
9+
[repository]
10+
ROOT = /data/repositories
11+
DEFAULT_BRANCH = master
12+
13+
[server]
14+
DOMAIN = gogs
15+
HTTP_PORT = 3000
16+
EXTERNAL_URL = http://gogs:3000/
17+
DISABLE_SSH = true
18+
19+
[security]
20+
INSTALL_LOCK = true
21+
SECRET_KEY = aRandomString
22+
LOCAL_NETWORK_ALLOWLIST = *
23+
24+
[webhook]
25+
DELIVER_TIMEOUT = 10
26+
SKIP_TLS_VERIFY = true
27+
28+
[log]
29+
MODE = file
30+
LEVEL = Info
31+
ROOT_PATH = /data/gogs/log

src/VCS/Adapter/Git/Gitea.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public function createRepository(string $owner, string $repositoryName, bool $pr
101101
]);
102102

103103
return $response['body'] ?? [];
104+
// return is_array($body) ? $body : [];
104105
}
105106

106107
public function createOrganization(string $orgName): string

0 commit comments

Comments
 (0)