Skip to content

Conversation

@cfsmp3
Copy link
Contributor

@cfsmp3 cfsmp3 commented Dec 25, 2025

Summary

Adds a new /health/version endpoint that returns the current git commit hash, making it easy to verify that a deployment has completed successfully.

Problem

After merging a PR, there's no easy way to confirm the fix has been deployed to production. You'd have to SSH into the server and run git rev-parse HEAD.

Solution

New endpoint that exposes git version information:

curl https://sampleplatform.ccextractor.org/health/version

Response (200 OK):

{
  "timestamp": "2025-12-25T08:30:00Z",
  "git": {
    "commit": "abc123def456789012345678901234567890abcd",
    "short": "abc123d",
    "branch": "master"
  }
}

Response when git unavailable (503):

{
  "timestamp": "2025-12-25T08:30:00Z",
  "git": {
    "commit": null,
    "short": null,
    "branch": null
  },
  "error": "Could not retrieve version information"
}

Usage Examples

Verify a specific commit is deployed

# After merging PR, wait ~7 min for deployment, then:
curl -s https://sampleplatform.ccextractor.org/health/version | jq '.git.short'
# Should return the merged commit's short hash

Script to wait for deployment

EXPECTED_COMMIT="abc123d"
while true; do
  DEPLOYED=$(curl -s https://sampleplatform.ccextractor.org/health/version | jq -r '.git.short')
  if [ "$DEPLOYED" = "$EXPECTED_COMMIT" ]; then
    echo "Deployment complete!"
    break
  fi
  echo "Waiting... (current: $DEPLOYED)"
  sleep 30
done

Files Changed

File Changes
mod_health/controllers.py Added get_git_info() helper and /health/version endpoint
tests/test_health/test_controllers.py Added 5 new tests

Tests Added

  • test_version_endpoint_returns_200_with_git_info - Endpoint returns 200 with commit info
  • test_version_endpoint_returns_503_when_git_unavailable - Endpoint returns 503 when git fails
  • test_get_git_info_success - Helper function returns correct values
  • test_get_git_info_git_not_available - Graceful handling when git not installed
  • test_get_git_info_not_a_repo - Graceful handling when not a git repository
$ python -m nose2 -v tests.test_health.test_controllers

Ran 15 tests in 1.825s

OK

Security Considerations

  • Only exposes git commit hash and branch name (public info from GitHub)
  • Does not expose any secrets or internal paths
  • Errors are logged server-side but not exposed to client

🤖 Generated with Claude Code

Adds a new endpoint that returns the current git commit hash, making it
easy to verify that a deployment has completed successfully.

Response format:
```json
{
  "timestamp": "2025-12-25T08:30:00Z",
  "git": {
    "commit": "abc123def456789012345678901234567890abcd",
    "short": "abc123d",
    "branch": "master"
  }
}
```

Returns 503 if git information cannot be retrieved (e.g., not a git repo).

Usage:
  curl https://sampleplatform.ccextractor.org/health/version

Changes:
- Added get_git_info() helper function
- Added /health/version endpoint
- Added 5 new tests for version endpoint and get_git_info function

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sonarqubecloud
Copy link

@cfsmp3 cfsmp3 merged commit 2a1ddea into master Dec 25, 2025
6 checks passed
@cfsmp3 cfsmp3 deleted the feat/version-endpoint branch December 25, 2025 08:34
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