Skip to content

Supporting Gogs integration with existing tools#80

Open
Copilot wants to merge 18 commits intomainfrom
copilot/add-gogs-adapter-and-tests-again
Open

Supporting Gogs integration with existing tools#80
Copilot wants to merge 18 commits intomainfrom
copilot/add-gogs-adapter-and-tests-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

Todos

Summary

  • Create src/VCS/Adapter/Git/Gogs.php extending Gitea
  • Create tests/VCS/Adapter/GogsTest.php extending GiteaTest
  • Update docker-compose.yml — gogs/gogs-bootstrap services, gogs-data volume
  • Fix unhealthy Gogs container: remove pre-mounted app.ini (was silently ignored by Gogs 0.13), replace CLI user-creation bootstrap with a /install endpoint POST (configures SQLite3 + creates admin user in one step), extract token with tr -d ' ' | sed instead of jq (avoids slow apk add)
  • Remove unused tests/resources/gogs-custom/conf/app.ini

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Meldiron Meldiron marked this pull request as ready for review March 23, 2026 17:55
@Meldiron Meldiron added the test Enables E2E tests in CI/CD label Mar 23, 2026
@greptile-apps
Copy link

greptile-apps bot commented Mar 23, 2026

Greptile Summary

This PR adds a Gogs VCS adapter by extending the existing Gitea adapter, following the same inheritance pattern used by the Forgejo adapter. It wires Gogs into the Docker Compose test infrastructure with a dedicated service, bootstrap container, and test class.

Changes:

  • src/VCS/Adapter/Git/Gogs.php — new adapter that overrides getName(), getHookType(), and getCommitStatuses(). The getCommitStatuses() override is necessary and correct: Gogs returns state in its API response whereas Gitea/Forgejo return status, so the mapping ensures the inherited test suite's assertion on $status['status'] passes.
  • tests/VCS/Adapter/GogsTest.php — extends GiteaTest to reuse the full integration test suite, consistent with ForgejoTest.
  • docker-compose.yml — adds gogs and gogs-bootstrap services. Unlike Gitea/Forgejo (which use an admin CLI command to generate a token), Gogs lacks that CLI, so the bootstrap calls the REST API via curl. The token extraction does not validate the result before writing it to disk, which can silently store the string "null" on any API error.
  • tests/resources/gogs-custom/conf/app.ini — Gogs configuration for the isolated test environment.

Confidence Score: 3/5

  • Safe to merge with one logic fix in the bootstrap token validation before tests can be relied upon in CI.
  • The adapter and test code are well-structured and consistent with existing patterns. The main concern is the bootstrap script's silent failure mode: if the token API call returns an error, the literal string "null" is written to the token file, causing all integration tests to fail with opaque 401 errors rather than a clear bootstrap failure. This needs to be addressed for the CI setup to be reliable.
  • docker-compose.yml — specifically the gogs-bootstrap command's token validation logic.

Important Files Changed

Filename Overview
src/VCS/Adapter/Git/Gogs.php New Gogs adapter extending Gitea. Correctly overrides getName(), getHookType(), and getCommitStatuses() to normalize the Gogs-specific 'state' response field to 'status'.
tests/VCS/Adapter/GogsTest.php New test class extending GiteaTest to reuse the full test suite against the Gogs adapter. Setup pattern is consistent with ForgejoTest.
docker-compose.yml Adds gogs and gogs-bootstrap services. The bootstrap uses an API+curl approach to create the access token (unlike Gitea/Forgejo which use admin CLI), and does not validate the token value before writing it to disk — a "null" string could be silently persisted on API failure.
tests/resources/gogs-custom/conf/app.ini Gogs configuration for local/CI testing. Hardcoded SECRET_KEY is acknowledged with a comment; settings are appropriate for an isolated test environment.

Reviews (1): Last reviewed commit: "Add Gogs VCS adapter, tests, Docker serv..." | Re-trigger Greptile

@Meldiron
Copy link
Contributor

@copilot Check out CI/CD test runs, they are failing

 Network vcs_default  Creating
 Network vcs_default  Created
 Volume "vcs_forgejo-data"  Creating
 Volume "vcs_forgejo-data"  Created
 Volume "vcs_gogs-data"  Creating
 Volume "vcs_gogs-data"  Created
 Volume "vcs_gitea-data"  Creating
 Volume "vcs_gitea-data"  Created
 Container vcs-forgejo-1  Creating
 Container vcs-gitea-1  Creating
 Container vcs-request-catcher-1  Creating
 Container vcs-gogs-1  Creating
 Container vcs-forgejo-1  Created
 Container vcs-forgejo-bootstrap-1  Creating
 Container vcs-gitea-1  Created
 Container vcs-request-catcher-1  Created
 Container vcs-gitea-bootstrap-1  Creating
 Container vcs-gogs-1  Created
 Container vcs-gogs-bootstrap-1  Creating
 Container vcs-gitea-bootstrap-1  Created
 Container vcs-forgejo-bootstrap-1  Created
 Container vcs-gogs-bootstrap-1  Created
 Container vcs-tests-1  Creating
 Container vcs-tests-1  Created
 Container vcs-gitea-1  Starting
 Container vcs-gogs-1  Starting
 Container vcs-request-catcher-1  Starting
 Container vcs-forgejo-1  Starting
 Container vcs-forgejo-1  Started
 Container vcs-forgejo-1  Waiting
 Container vcs-gitea-1  Started
 Container vcs-gitea-1  Waiting
 Container vcs-request-catcher-1  Started
 Container vcs-gogs-1  Started
 Container vcs-gogs-1  Waiting
 Container vcs-forgejo-1  Healthy
 Container vcs-forgejo-bootstrap-1  Starting
 Container vcs-gitea-1  Healthy
 Container vcs-gitea-bootstrap-1  Starting
 Container vcs-forgejo-bootstrap-1  Started
 Container vcs-gitea-bootstrap-1  Started
 Container vcs-gogs-1  Error
dependency failed to start: container vcs-gogs-1 is unhealthy
Error: Process completed with exit code 1.

Try to reproduce and fix it. If you have no lead, switch to debugging phase - update CI/CD logging to gain more info

… pre-configured app.ini

Co-authored-by: Meldiron <19310830+Meldiron@users.noreply.github.com>
Agent-Logs-Url: https://github.com/utopia-php/vcs/sessions/a31418bd-fb1d-47ab-8ff3-8c8e56db0365
Copy link
Contributor Author

Copilot AI commented Mar 23, 2026

@copilot Check out CI/CD test runs, they are failing

...

Investigated and fixed in commit 91907fd.

Root cause: Gogs 0.13 was silently ignoring the pre-mounted app.ini file (the GOGS_CUSTOM env variable and file bind-mount inside a named volume had no effect), so Gogs always crashed trying to connect to its hardcoded PostgreSQL default, making the health check fail.

Fix:

  1. Removed the pre-mounted app.ini — Gogs handles its own configuration on first start
  2. Replaced the bootstrap — instead of the broken CLI create-user (wrong binary path /opt/gogs/gogs instead of /app/gogs/gogs) + apk add jq (slow/unreliable in CI), the bootstrap now POSTs to Gogs's /install web endpoint which configures SQLite3, creates the admin user, and writes the final app.ini atomically in one step
  3. Token extraction uses tr -d ' ' | sed (built into the Gogs Alpine image) instead of jq — avoids the apk add round-trip entirely

Tested locally: the Gogs container becomes healthy (HTTP 302), the bootstrap completes, and a valid 40-character SHA1 access token is saved to /data/gogs/token.txt.

Copilot AI requested a review from Meldiron March 23, 2026 18:37
@Meldiron Meldiron removed the test Enables E2E tests in CI/CD label Mar 23, 2026
@Meldiron Meldiron changed the base branch from copilot/add-forgejo-adapter-and-tests to main March 24, 2026 09:31
Your Name and others added 4 commits March 24, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants