CI #112
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| # The account's included GitHub Actions minutes are limited, and pushes to main | |
| # are frequent, so CI does not run per-push or per-pull-request. It runs at most | |
| # once per day on a schedule, plus on manual dispatch when a run is genuinely | |
| # needed. Primary verification is local: the Go and region suites on a | |
| # workstation and the Linux build host. | |
| on: | |
| schedule: | |
| - cron: "0 7 * * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| go: | |
| name: Go (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: grid/go.mod | |
| cache-dependency-path: grid/go.sum | |
| - name: Test | |
| working-directory: grid | |
| run: go test ./... | |
| - name: Vet | |
| working-directory: grid | |
| run: go vet ./... | |
| region: | |
| name: Region C++ (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install SQLite development package | |
| if: runner.os == 'Linux' | |
| run: sudo apt-get update && sudo apt-get install --yes libsqlite3-dev | |
| - name: Configure (Linux) | |
| if: runner.os == 'Linux' | |
| run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug | |
| - name: Build (Linux) | |
| if: runner.os == 'Linux' | |
| run: cmake --build build --config Debug | |
| - name: Test (Linux) | |
| if: runner.os == 'Linux' | |
| run: ctest --test-dir build -C Debug --output-on-failure | |
| - uses: actions/setup-go@v6 | |
| if: runner.os == 'Linux' | |
| with: | |
| go-version-file: grid/go.mod | |
| cache-dependency-path: grid/go.sum | |
| - name: Package (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| go run ./grid/cmd/package-release \ | |
| -version ci -output dist \ | |
| -region-executable build/region/homeworldz-region | |
| tar -tzf dist/homeworldz-grid-ci-linux-x64.tar.gz | grep 'homeworldz-grid/homeworldz-grid$' | |
| tar -tzf dist/homeworldz-region-ci-linux-x64.tar.gz | grep 'homeworldz-region/homeworldz-region$' | |
| - name: Build and test (Windows) | |
| if: runner.os == 'Windows' | |
| run: .\scripts\build-region.ps1 -Test | |
| postgres: | |
| name: PostgreSQL migration and grid probes | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:18.4-alpine | |
| env: | |
| POSTGRES_USER: homeworldz | |
| POSTGRES_PASSWORD: homeworldz-ci | |
| POSTGRES_DB: homeworldz | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U homeworldz -d homeworldz" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| env: | |
| HOMEWORLDZ_DATABASE_URL: postgres://homeworldz:homeworldz-ci@localhost:5432/homeworldz?sslmode=disable | |
| HOMEWORLDZ_TEST_DATABASE_URL: postgres://homeworldz:homeworldz-ci@localhost:5432/homeworldz?sslmode=disable | |
| HOMEWORLDZ_GRID_SERVICE_TOKEN: homeworldz-ci-token | |
| PGPASSWORD: homeworldz-ci | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: grid/go.mod | |
| cache-dependency-path: grid/go.sum | |
| - name: Apply migrations | |
| run: | | |
| for migration in db/migrations/*.up.sql; do | |
| psql -h localhost -U homeworldz -d homeworldz -v ON_ERROR_STOP=1 -f "$migration" | |
| done | |
| - name: Verify schema | |
| run: psql -h localhost -U homeworldz -d homeworldz -v ON_ERROR_STOP=1 -c "SELECT version FROM schema_metadata WHERE version IN (1, 2, 3, 4) ORDER BY version" | |
| - name: Test region lease persistence | |
| working-directory: grid | |
| run: go test ./internal/regions -run TestPostgresRegionLifecycle -count=1 | |
| - name: Test identity and session persistence | |
| working-directory: grid | |
| run: go test ./internal/identity -run TestPostgresIdentityLifecycle -count=1 | |
| - name: Test presence persistence and cleanup | |
| working-directory: grid | |
| run: go test ./internal/presence -run TestPostgresPresenceLifecycle -count=1 | |
| - name: Start grid and verify probes | |
| shell: bash | |
| run: | | |
| go run ./grid/cmd/grid -config config/ci > grid.log 2>&1 & | |
| grid_pid=$! | |
| trap 'kill "$grid_pid" 2>/dev/null || true; cat grid.log' EXIT | |
| for attempt in {1..30}; do | |
| if curl --fail --silent http://localhost:42000/ping > /dev/null; then | |
| break | |
| fi | |
| sleep 1 | |
| done | |
| curl --fail --show-error http://localhost:42000/ping | |
| curl --fail --show-error http://localhost:42000/ready | |
| curl --fail --show-error http://localhost:42000/version | |
| registration=$(curl --fail --show-error \ | |
| -H 'Authorization: Bearer homeworldz-ci-region-key' \ | |
| -H 'Content-Type: application/json' \ | |
| -d '{"publicEndpoint":"http://localhost:42001","viewerPort":42002,"leaseSeconds":60}' \ | |
| http://localhost:42000/api/v1/region-runtime/11111111-1111-4111-8111-111111111111) | |
| region_id=$(echo "$registration" | jq -r .id) | |
| curl --fail --show-error \ | |
| -H 'Authorization: Bearer homeworldz-ci-token' \ | |
| http://localhost:42000/api/v1/regions | |
| curl --fail --show-error -X PUT \ | |
| -H 'Authorization: Bearer homeworldz-ci-region-key' \ | |
| -H 'Content-Type: application/json' \ | |
| -d '{"leaseSeconds":120}' \ | |
| "http://localhost:42000/api/v1/region-runtime/$region_id/lease" | |
| curl --fail --show-error -X DELETE \ | |
| -H 'Authorization: Bearer homeworldz-ci-region-key' \ | |
| "http://localhost:42000/api/v1/region-runtime/$region_id" | |