diff --git a/.github/workflows/backend.yaml b/.github/workflows/backend.yaml index e7af3f6..89b5b92 100644 --- a/.github/workflows/backend.yaml +++ b/.github/workflows/backend.yaml @@ -2,9 +2,9 @@ name: Go Integration & Test Suite on: push: - branches: [ main, dev ] + branches: [ main, v0.1.0 ] pull_request: - branches: [ main, dev ] + branches: [ main, v0.1.0 ] jobs: test: @@ -32,6 +32,20 @@ jobs: uses: actions/setup-go@v5 with: go-version: '1.26' + cache: true + cache-dependency-path: server/go.sum + + - name: Run Go Vet Sanitation Checks + run: | + cd server + go vet ./... + + - name: Run Advanced Staticcheck Compiler + uses: dominikh/staticcheck-action@v1 + with: + version: "latest" + install-go: false + working-directory: "server" - name: Execute Package Test Automation Suite env: @@ -48,4 +62,16 @@ jobs: ARGON_PARALLELISM: ${{ vars.ARGON_PARALLELISM }} run: | cd server + sudo apt-get update && sudo apt-get install -y postgresql-client + PGPASSWORD="${{ secrets.POSTGRES_PASSWORD }}" psql -h localhost -p "${{ vars.POSTGRES_PORT }}" -U "${{ vars.POSTGRES_USER }}" -d "${{ vars.POSTGRES_DB }}" \ + -f migrations/001_create_users_up.sql \ + -f migrations/002_create_refresh_tokens_up.sql \ + -f migrations/003_add_search_indexes_up.sql \ + -f migrations/004_create_message_up.sql + go run main.go & + for i in $(seq 1 10); do + curl -sf http://localhost:${{ vars.PORT }}/api/health && break + echo "Waiting for server... attempt $i" + sleep 2 + done go test -v ./... \ No newline at end of file diff --git a/.gitignore b/.gitignore index cff973d..f16bb15 100644 --- a/.gitignore +++ b/.gitignore @@ -32,5 +32,7 @@ go.work.sum # .idea/ # .vscode/ +mob/windows + # Keep database data folders out of version control pgdata/ diff --git a/compose.yaml b/compose.yaml index 46cf332..3bf7ecf 100644 --- a/compose.yaml +++ b/compose.yaml @@ -18,8 +18,8 @@ services: server: build: - context: . - dockerfile: server/Dockerfile + context: ./server + dockerfile: Dockerfile container_name: elephant_server ports: - "${PORT}:${PORT}" diff --git a/docs/API_CONTRACTS.md b/docs/API_CONTRACTS.md index 683abfc..4b03771 100644 --- a/docs/API_CONTRACTS.md +++ b/docs/API_CONTRACTS.md @@ -1,5 +1,493 @@ -# Elephant Messenger API Documentation +# Elephant Messenger API Contracts - v0.1.0 -## Week 1: Authentication API Contracts +## Global Requirements & Configuration -### POST /api/auth/register \ No newline at end of file +- **Base URL:** `http://HOST:PORT` (Local Sandbox) +- **Default Content-Type:** `application/json` +- **Authorization:** `Bearer ` +- **Timestamp Format:** `ISO8601 UTC` +--- + +## Health Endpoint + +Evaluates the operational status of the server application and its upstream resource dependencies (such as the PostgreSQL database pool). + +- **URL:** `/api/health` +- **Method:** `GET` +- **Authentication Required:** `NO` +- **curl:** `curl -X GET http://HOST:PORT/api/health \ -s | jq .` + +### Expected Responses + +#### `200 OK` (System operational) + +Returned when the server runtime is healthy and can successfully execute a ping query against the database. + +```json +{ + "success": true, + "data": { + "postgres": "up", + "timestamp": "