Merge pull request #14 from thinkgrid-labs/dev #99
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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| pull_request: | |
| branches: | |
| - main | |
| - dev | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # --------------------------------------------------------------------------- | |
| # Rust — test the whole workspace | |
| # --------------------------------------------------------------------------- | |
| rust: | |
| name: Rust tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy, rustfmt | |
| - name: Cache Rust build artifacts | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| - name: Clippy | |
| run: cargo clippy --workspace --all-targets -- -D warnings | |
| - name: Test | |
| run: cargo test --workspace | |
| # --------------------------------------------------------------------------- | |
| # Server integration — spawn the real server binary against a real Postgres | |
| # and Redis and drive the HTTP API end to end (auth, RBAC, flags, segments, | |
| # analytics, A/B experiments, change-request approvals). | |
| # --------------------------------------------------------------------------- | |
| server-integration: | |
| name: Server integration tests | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: checkgate_test | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| redis: | |
| image: redis:7 | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust build artifacts | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Run server integration + SSE e2e tests | |
| env: | |
| CHECKGATE_TEST_DATABASE_URL: postgres://postgres:postgres@localhost:5432/checkgate_test | |
| CHECKGATE_TEST_REDIS_URL: redis://localhost:6379 | |
| run: | | |
| cargo test -p server --test integration -- --nocapture | |
| cargo test -p server --test e2e_sse -- --nocapture | |
| # --------------------------------------------------------------------------- | |
| # Native SDK e2e — build the real @checkgate/node addon and drive it over a | |
| # live SSE connection against a running server (the full application loop). | |
| # --------------------------------------------------------------------------- | |
| sdk-node-e2e: | |
| name: Node SDK e2e (live SSE) | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: checkgate_test | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| redis: | |
| image: redis:7 | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust build artifacts | |
| uses: Swatinem/rust-cache@v2 | |
| - uses: actions/setup-node@v5 | |
| with: | |
| node-version: 22 | |
| - name: Build the server | |
| run: cargo build -p server | |
| - name: Build the Node SDK native addon | |
| working-directory: sdks/nodejs | |
| run: | | |
| npm install | |
| npm run build:debug | |
| - name: Run native SDK e2e over live SSE | |
| env: | |
| DATABASE_URL: postgres://postgres:postgres@localhost:5432/checkgate_test | |
| REDIS_URL: redis://localhost:6379 | |
| run: | | |
| PORT=3111 | |
| SESSION_SECRET=ci-secret-0123456789-0123456789-0123456789-0123456789 \ | |
| COOKIE_SECURE=false PORT=$PORT PUBLIC_DIR="$(mktemp -d)" RUST_LOG=warn \ | |
| ./target/debug/server > server.log 2>&1 & | |
| SRV=$! | |
| for i in $(seq 1 60); do curl -sf "http://127.0.0.1:$PORT/health" >/dev/null && break; sleep 1; done | |
| CHECKGATE_URL="http://127.0.0.1:$PORT" node sdks/nodejs/e2e/e2e.cjs | |
| RC=$? | |
| kill $SRV 2>/dev/null || true | |
| if [ $RC -ne 0 ]; then echo "=== server log ==="; cat server.log; fi | |
| exit $RC | |
| # --------------------------------------------------------------------------- | |
| # Dashboard — TypeScript build check | |
| # --------------------------------------------------------------------------- | |
| dashboard: | |
| name: Dashboard build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: 1.3.14 | |
| - name: Install dependencies | |
| working-directory: dashboard | |
| run: bun install --frozen-lockfile | |
| - name: Type-check and build | |
| working-directory: dashboard | |
| run: bun run build | |
| - name: Run unit and integration tests | |
| working-directory: dashboard | |
| run: bun run test --run | |
| # --------------------------------------------------------------------------- | |
| # CLI — @checkgate/cli codegen tests (zero deps, Node's built-in test runner) | |
| # --------------------------------------------------------------------------- | |
| cli: | |
| name: CLI tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-node@v5 | |
| with: | |
| node-version: 22 | |
| - name: Run tests | |
| working-directory: cli | |
| run: node --test | |
| - name: Smoke-test codegen (ts, dart, rust) | |
| working-directory: cli | |
| run: node bin/checkgate.js typegen --lang ts,dart,rust --input test/fixtures/flags.json --out-dir /tmp/checkgate-gen | |
| # --------------------------------------------------------------------------- | |
| # Edge — @checkgate/edge evaluator tests (zero deps, Node's built-in runner) | |
| # --------------------------------------------------------------------------- | |
| edge: | |
| name: Edge evaluator tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-node@v5 | |
| with: | |
| node-version: 22 | |
| - name: Run tests | |
| working-directory: edge | |
| run: node --test | |
| # --------------------------------------------------------------------------- | |
| # SSR — @checkgate/ssr bootstrap helpers (zero deps, Node's built-in runner) | |
| # --------------------------------------------------------------------------- | |
| ssr: | |
| name: SSR helpers tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-node@v5 | |
| with: | |
| node-version: 22 | |
| - name: Run tests | |
| working-directory: ssr | |
| run: node --test | |
| # --------------------------------------------------------------------------- | |
| # Node SDK — client-logic unit tests (native core + eventsource are mocked, | |
| # so no native build or install is needed) | |
| # --------------------------------------------------------------------------- | |
| sdk-node: | |
| name: Node SDK tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-node@v5 | |
| with: | |
| node-version: 22 | |
| - name: Run tests | |
| working-directory: sdks/nodejs | |
| run: node --test | |
| # --------------------------------------------------------------------------- | |
| # Web + React Native SDKs — client-logic unit tests (vitest; the WASM core is | |
| # stubbed for web, the JSI bridge faked for RN — no native/WASM build needed) | |
| # --------------------------------------------------------------------------- | |
| sdk-web-rn: | |
| name: SDK tests (${{ matrix.sdk }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| sdk: [web, react-native] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-node@v5 | |
| with: | |
| node-version: 22 | |
| - name: Install dependencies | |
| working-directory: sdks/${{ matrix.sdk }} | |
| run: npm install | |
| - name: Run tests | |
| working-directory: sdks/${{ matrix.sdk }} | |
| run: npx vitest run | |
| # --------------------------------------------------------------------------- | |
| # Flutter SDK — Dart client-logic unit tests (native FFI is lazy-loaded and an | |
| # http.Client is injected, so no native library is needed) | |
| # --------------------------------------------------------------------------- | |
| sdk-flutter: | |
| name: Flutter SDK tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: subosito/flutter-action@v2 | |
| with: | |
| channel: stable | |
| - name: Install dependencies | |
| working-directory: sdks/flutter/dart | |
| run: flutter pub get | |
| - name: Run tests | |
| working-directory: sdks/flutter/dart | |
| run: flutter test | |
| # --------------------------------------------------------------------------- | |
| # Go integrations — shared client, Terraform provider, Kubernetes operator | |
| # --------------------------------------------------------------------------- | |
| integrations: | |
| name: Go integrations | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| module: | |
| - integrations/checkgate-go | |
| - integrations/terraform-provider-checkgate | |
| - integrations/kubernetes-operator | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-go@v6 | |
| with: | |
| go-version: "1.25" | |
| cache-dependency-path: ${{ matrix.module }}/go.sum | |
| - name: Build | |
| working-directory: ${{ matrix.module }} | |
| run: go build ./... | |
| - name: Vet | |
| working-directory: ${{ matrix.module }} | |
| run: go vet ./... | |
| - name: Test | |
| working-directory: ${{ matrix.module }} | |
| run: go test ./... |