Skip to content

feat: add minimal GitLab adapter with CI/CD setup#85

Open
jaysomani wants to merge 3 commits intoutopia-php:mainfrom
jaysomani:feat/gitlab-adapter
Open

feat: add minimal GitLab adapter with CI/CD setup#85
jaysomani wants to merge 3 commits intoutopia-php:mainfrom
jaysomani:feat/gitlab-adapter

Conversation

@jaysomani
Copy link
Copy Markdown
Contributor

  • Add GitLab CE service to docker-compose with OAuth2 bootstrap
  • Add GitLab adapter with createRepository, getRepository, deleteRepository
  • Add GitLabTest with 4 passing tests, remaining skipped for follow-up PRs
  • Fix Adapter.php body decoding bug (strpos ?: 0 -> strlen) for adapters returning plain 'application/json' without charset suffix
  • All unimplemented methods throw Exception('Not implemented')

- Add GitLab CE service to docker-compose with OAuth2 bootstrap
- Add GitLab adapter with createRepository, getRepository, deleteRepository
- Add GitLabTest with 4 passing tests, remaining skipped for follow-up PRs
- Fix Adapter.php body decoding bug (strpos ?: 0 -> strlen) for adapters
  returning plain 'application/json' without charset suffix
- All unimplemented methods throw Exception('Not implemented')
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 7, 2026

Greptile Summary

This PR introduces a minimal GitLab adapter (createRepository, getRepository, deleteRepository), wires up a GitLab CE Docker service for CI, and fixes a long-standing bug in Adapter.php where Content-Type: application/json responses without a ;charset= suffix were not decoded. The Adapter.php fix is correct and the PHP adapter itself is well-structured with proper status-code error checking.

The critical issue is in docker-compose.yml: GitLab 17.x+ mandates expires_at on PAT creation, and gitlab-ce:18.10.1-ce.0 will reject the payload with a 422 error, causing the bootstrap container to exit with "Failed to get token" and breaking all CI test runs.

  • docker-compose.yml: Adds gitlab and gitlab-bootstrap services — PAT creation payload is missing the required expires_at field, which causes a hard failure on GitLab 18.x
  • src/VCS/Adapter/Git/GitLab.php: New minimal adapter; all state-mutating methods check response status codes and throw on >= 400; unimplemented methods throw Exception("Not implemented")
  • src/VCS/Adapter.php: Fixes Content-Type parsing so bare application/json responses (without ;charset=…) are correctly decoded
  • tests/VCS/Adapter/GitLabTest.php: 4 active tests with proper try/finally cleanup; 15 remaining tests skipped pending future implementation

Confidence Score: 3/5

Not safe to merge — the bootstrap script will fail on GitLab 18.x, preventing all GitLab CI tests from running.

A P0 defect in the bootstrap script means every fresh CI run will exit with 'Failed to get token', making the entire feature untestable. The PHP adapter code is sound and the Adapter.php fix is correct, but broken CI infrastructure is a blocker.

docker-compose.yml requires adding expires_at to the PAT creation payload before merging.

Important Files Changed

Filename Overview
docker-compose.yml Adds GitLab CE + bootstrap services; PAT creation is broken on GitLab 18.x because the mandatory expires_at field is missing, causing bootstrap to exit with empty token.
src/VCS/Adapter/Git/GitLab.php New minimal GitLab adapter; createRepository, getRepository, deleteRepository all check status codes; remaining methods throw Not implemented.
src/VCS/Adapter.php Bug fix: strpos(...) ?: strlen($responseType) correctly handles bare application/json Content-Type headers without a ;charset= suffix.
tests/VCS/Adapter/GitLabTest.php 4 active tests with proper try/finally cleanup; 15 skipped; expectException(\Exception::class) in testGetDeletedRepositoryFails is too broad.

Reviews (3): Last reviewed commit: "fix: suggestions2" | Re-trigger Greptile

if [ -z "$$TOKEN" ]; then echo "Failed to get token"; exit 1; fi
mkdir -p /gitlab-data
echo $$TOKEN > /gitlab-data/token.txt

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Missing expires_at breaks the bootstrap on GitLab 18.x

GitLab made expires_at mandatory for PAT creation starting in 17.x, and this is fully enforced in gitlab-ce:18.10.1-ce.0. Omitting it causes the API to return a 422 validation error ("Expiration date can't be blank"). Because the bootstrap script greps for "token":"..." in the error response body (which won't match), TOKEN stays empty, and the container exits with "Failed to get token" — preventing every CI pipeline from acquiring credentials and running any GitLab tests.

Add expires_at to the payload. A far-future date is fine for a test environment:

Suggested change
-d '{"name":"bootstrap","scopes":["api","read_user","read_repository","write_repository"],"expires_at":"2099-01-01"}')

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.

1 participant