Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
jobs:
build-and-test:
# Versioned runner label rather than the ubuntu-latest alias: jobs here
# lean on the image-provided baseline (Docker, Node, jq), and an alias
# lean on the image-provided baseline (Node, jq, glibc), and an alias
# migration would swap that baseline with no repository diff. Bumped
# deliberately, like every other pin (see decisions.md).
runs-on: ubuntu-26.04
Expand All @@ -39,7 +39,6 @@ jobs:

# Integration tests run against a local Supabase stack.
# This job's matrix mirrors build-and-test.
# GitHub's Ubuntu runner image ships Docker as part of the trusted image baseline.
integration-test:
runs-on: ubuntu-26.04
strategy:
Expand Down Expand Up @@ -89,8 +88,9 @@ jobs:

# Validates the external URLs in the published modules' comments by probing
# the live websites they point at, via the same script developers run on
# demand (it is deliberately not part of the local check-fast aggregate -
# see DEVELOPMENT.md). Reaching those sites is the check itself, so a
# demand (it is deliberately not part of the local
# check-all-except-integration-tests.sh and check-all.sh aggregates - see
# DEVELOPMENT.md). Reaching those sites is the check itself, so a
# third-party outage can fail this job with no repository change.
comment-check:
runs-on: ubuntu-26.04
Expand All @@ -117,7 +117,7 @@ jobs:

# The repository holds the files its readers look for, where they look,
# and none that would shadow or contradict them. This is the same script
# developers run locally via check-fast.sh.
# developers run locally via check-all-except-integration-tests.sh.
- name: Assert repository structure
run: ./scripts/check-repository-structure.sh

Expand All @@ -127,14 +127,14 @@ jobs:
# script holds the require graph to its layering DAG: core requires
# nothing first-party, domains require only core and only the root
# composes the domains. This is the same script developers run locally
# via check-fast.sh.
# via check-all-except-integration-tests.sh.
- name: Assert published module requires resolve and respect the DAG
run: ./scripts/check-module-paths.sh

# A GOWORK=off tool bump can raise a module's go directive past its
# sibling go.work go line, an invalid state every workspace-mode command
# in that directory then refuses. This is the same script developers run
# locally via check-fast.sh.
# locally via check-all-except-integration-tests.sh.
- name: Assert nested workspaces load
run: ./scripts/check-workspace-consistency.sh

Expand Down
51 changes: 31 additions & 20 deletions DEVELOPMENT.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ A consumer who fetches while only some of the tags exist sees a transient resolu

### The consistency check failed part-way through preparing a release

State: between the per-module commits of a multi-module release, `check-release-consistency.sh` - run directly or through `check-fast.sh` - fails with "a forgotten dep=version pin" complaints against the modules not yet prepared.
State: between the per-module commits of a multi-module release, `check-release-consistency.sh` - run directly or through `check-all-except-integration-tests.sh` - fails with "a forgotten dep=version pin" complaints against the modules not yet prepared.
The check joins the dots across the whole repository, and mid-sequence the dots genuinely do not join: a prepared module's changelog already declares the new version while a dependent yet to be prepared still carries the zero pseudo-version placeholder.
At that moment a forgotten pin and a pin not yet made are indistinguishable, and stopping a half-released state from reaching `main` unnoticed is this check's whole purpose.

Expand Down
2 changes: 1 addition & 1 deletion auth/integrationtest/asproject/admin_links_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestAdminGenerateLinks(t *testing.T) {
}

// The email-change pair needs secure email change, which the local
// stack's config.toml enables via double_confirm_changes.
// stack turns on by default through auth.email.double_confirm_changes.
newEmail := testkit.UniqueEmail(t)
toCurrent, err := admin.GenerateLink(ctx, auth.NewLinkRequest(email).EmailChangeToCurrent(newEmail))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion auth/integrationtest/asproject/admin_security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func enrollTOTPFactor(t *testing.T, projectURL, apiKey, accessToken, friendlyNam
t.Fatalf("reading the enroll response body: %v", err)
}
if response.StatusCode != http.StatusOK {
t.Fatalf("enrolling TOTP factor: HTTP %d: %s - is auth.mfa.totp enabled in config.toml?", response.StatusCode, body)
t.Fatalf("enrolling TOTP factor: HTTP %d: %s - is auth.mfa.totp enabled in config.jsonc?", response.StatusCode, body)
}
var factor struct {
ID string `json:"id"`
Expand Down
2 changes: 1 addition & 1 deletion auth/integrationtest/asuser/session_autorefresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestAutoRefreshAgainstStack(t *testing.T) {
t.Fatalf("GetClaims after sign-in: %v", err)
}
if lifetime := time.Until(signedIn.Claims().ExpiresAt()); lifetime > 100*time.Second {
t.Fatalf("access token expires %s after sign-in, want at most 100s: [auth] jwt_expiry in integration-testing/supabase/config.toml must stay at 100", lifetime.Round(time.Second))
t.Fatalf("access token expires %s after sign-in, want at most 100s: auth.jwt_expiry in integration-testing/supabase/config.jsonc must stay at 100", lifetime.Round(time.Second))
}

refreshed := make(chan auth.SessionEvent, 1)
Expand Down
2 changes: 1 addition & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (stampingTransport) RoundTrip(request *http.Request) (*http.Response, error
// reach the wire, through both composed domains of one root client. This is
// exactly what an OpenTelemetry otelhttp transport does - read the active
// span from the request context, write the traceparent header - simulated
// here without the dependency so the guarantee stays pinned in the fast tier.
// here without the dependency so the guarantee stays pinned in the unit tests.
func TestInjectedTransportReceivesCallContext(t *testing.T) {
received := map[string]string{}
server := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
Expand Down
15 changes: 8 additions & 7 deletions decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ This follows Supabase's org-wide policy ([Git & GitHub](https://app.notion.com/p
Every `runs-on` names a versioned image label (currently `ubuntu-26.04`), bumped deliberately when a new image is ready.

**Why**:
Jobs lean on the image-provided baseline (Docker for the integration stack, Node for cspell and jq), and an alias migration swaps that baseline with no repository diff.
Jobs lean on the image-provided baseline (Node for cspell, plus jq and the glibc some of the integration stack's services use), and an alias migration swaps that baseline with no repository diff.
A versioned label turns the OS move into a reviewable one-line bump - the digest-pinning discipline above at the coarser granularity GitHub offers for images.

## `setup-go`'s implicit cache is disabled
Expand Down Expand Up @@ -501,13 +501,14 @@ Distinguishing "the server answered with an error" (`*Error`) from "we never got
## Integration harness: pinned-binary Supabase CLI, minimal services, floor + stable matrix

**What**:
CI's integration job and local runs share [`scripts/integration-test.sh`](scripts/integration-test.sh): a pinned, checksum-verified Supabase CLI release binary starts a disposable local stack from committed configuration (minimal `config.toml`, schema migrations, data-only `seed.sql`), then env-gated integration tests run under `-race` on the same floor + stable matrix as build-and-test.
The tests live in `integrationtest` modules beside the code they exercise, consuming only the public API, and selection is by the package boundary alone: the script runs every package in each, with no `-run` name filter, under the key posture its `asuser` or `asproject` directory declares, while the fast tier additionally vets the modules for compile signal.
The mechanics whose reasons concern single files - the CLI fetch route, the disposable project-directory copy, which services run - carry those reasons as comments in the script and in [`config.toml`](integration-testing/supabase/config.toml).
CI's integration job and local runs share [`scripts/integration-test.sh`](scripts/integration-test.sh): a pinned, checksum-verified Supabase CLI release binary starts a disposable local stack from committed configuration (minimal `config.jsonc`, schema migrations, data-only `seed.sql`), then env-gated integration tests run under `-race` on the same floor + stable matrix as build-and-test.
The tests live in `integrationtest` modules beside the code they exercise, consuming only the public API, and selection is by the package boundary alone: the script runs every package in each, with no `-run` name filter, under the key posture its `asuser` or `asproject` directory declares, while [`scripts/build-and-test.sh`](scripts/build-and-test.sh) additionally vets the modules for compile signal.
The mechanics whose reasons concern single files - the CLI fetch route, the disposable project-directory copy, which services run - carry those reasons as comments in the script and in [`config.jsonc`](integration-testing/supabase/config.jsonc).

**Why**:
Every unused service stays disabled because this harness's startup time and flakiness set the floor for all future CI.
Schema lives in `migrations/` and only data in `seed.sql` because the CLI applies the seed as a single batch whose statements are prepared before earlier ones execute, so DDL cannot ride with inserts that depend on it (SQLSTATE 42P01 on a fresh stack).
Schema lives in `migrations/` and only data in `seed.sql` because Supabase's seeding guidance keeps seed files to data.
Declarative schema files under `supabase/schemas/` would not remove the migrations, because the CLI turns them into more migration files rather than applying them, adding a generated copy of the schema to keep in step and a diff engine between the SQL the tests depend on and the database they run against.
A name-anchored `-run` filter (`^TestIntegration`) would spare the unit-tier re-run, but its failure mode is silence - a test named outside the anchor compiles cleanly, never runs and lets the suite pass vacuously - whereas the re-run it prevents is hermetic and costs seconds.
The dedicated test-only package makes the consumer stance structural (every test package is external, so unexported access never exists to lose) and keeps suite selection independent of function names.
The floor leg exists because only a live-stack run exercises the consumer floor end to end on the floor toolchain, and the legs run in parallel so wall-clock cost is unchanged.
Expand All @@ -517,7 +518,7 @@ The floor leg exists because only a live-stack run exercises the consumer floor
**What**:
The `telemetrytest/` module is a stand-in consumer, outside `go.work`: it requires the SDK modules at fabricated, self-labeled versions (`v1.999.1-fabricated` supabase, `v1.999.2-fabricated` postgrest), `replace`s them to the local working tree and its main program asserts the exact `X-Client-Info` value each entry point sends to a local HTTP server, with `TELEMETRY_TEST_MODE` naming the expectations to hold.
[`scripts/telemetry-test.sh`](scripts/telemetry-test.sh) runs that module-mode leg and a GOPATH-mode leg (`GO111MODULE=off`), where binaries carry build information without module records, asserting the version-unknowable `0.0.0` fallback in every header.
The probe is a plain program, not a `go test` suite, and the check runs in the fast tier and on CI's floor + stable matrix.
The probe is a plain program, not a `go test` suite, and the check runs in [`scripts/check-all-except-integration-tests.sh`](scripts/check-all-except-integration-tests.sh) and on CI's floor + stable matrix.

**Why**:
Every binary the in-repo suites produce has one of this repository's modules as its main module, so header resolution takes the in-tree branch and reports the unknown-version `0.0.0`: the branch every published-module consumer exercises - reading client versions from build-information dependency records - is reachable only from a main module outside the SDK's module tree.
Expand Down Expand Up @@ -666,7 +667,7 @@ Issued tokens travel the same path a production consumer's do.
## Example programs are non-published modules run by the integration tier

**What**:
`examples/` holds standalone main-package modules outside `go.work` with replace directives to the local tree. The fast tier compiles them (vet), lint covers them and `scripts/integration-test.sh` runs each against the local stack.
`examples/` holds standalone main-package modules outside `go.work` with replace directives to the local tree. `scripts/build-and-test.sh` compiles them (vet), lint covers them and `scripts/integration-test.sh` runs each against the local stack.

**Why**:
`Example` test functions cannot demonstrate a consumer-shaped module graph - a dependency quarantine or a scoped import is a property of a separate `go.mod`'s requires - nor run against a live stack, and a separate non-published module keeps example-only dependencies (OpenTelemetry, for `tracing-otel`) out of every consumer's graph.
Expand Down
63 changes: 63 additions & 0 deletions integration-testing/supabase/config.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Minimal local stack for the SDK integration tests, matching the CLI version
// pinned in scripts/integration-test.sh (SUPABASE_CLI_VERSION).
//
// The tests exercise Postgres + PostgREST (the api service) and the auth
// service, whose end-user sign-in, session and administration endpoints they
// call. Every other service is disabled. No port is set, so the CLI gives each
// stack free ports of its own.
{
"$schema": "https://supabase.com/schemas/config/v1.json",

"api": {
// Only the schemas the tests query. The CLI default also exposes
// graphql_public.
"schemas": ["public", "personal"]
},

"auth": {
// Access tokens expire 100 seconds after issue: above the SDK's 90-second
// background-refresh lead, and close to it, so that a background refresh
// happens about ten seconds after sign-in.
"jwt_expiry": 100,

// The MFA admin capabilities need an enrolled factor to act on, and the
// test fixtures enroll a TOTP factor for a throwaway user. verify_enabled
// is required by the CLI whenever enroll_enabled is set.
"mfa": {
"totp": {
"enroll_enabled": true,
"verify_enabled": true
}
}
},

"studio": {
"enabled": false
},

"local_smtp": {
"enabled": false
},

"realtime": {
"enabled": false
},

"storage": {
"enabled": false
},

"edge_runtime": {
"enabled": false
},

"analytics": {
"enabled": false
},

"experimental": {
// Runs start, status and stop on the CLI's stack backend and turns on its
// stack commands.
"stack": true
}
}
58 changes: 0 additions & 58 deletions integration-testing/supabase/config.toml

This file was deleted.

9 changes: 4 additions & 5 deletions integration-testing/supabase/migrations/0_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,10 @@ as $$
where title = piece_title returning *;
$$;

-- Per-user table for the Row Level Security integration tests, applied after
-- 0_schema.sql in lexicographic order. Policies are granted to the
-- authenticated role only and keyed on the JWT's subject, so each signed-in
-- user reads and writes their own rows alone and the anonymous role sees
-- nothing.
-- Per-user table for the Row Level Security integration tests. Policies are
-- granted to the authenticated role only and keyed on the JWT's subject, so
-- each signed-in user reads and writes their own rows alone and the anonymous
-- role sees nothing.
create table public.practice_logs (
id uuid primary key default gen_random_uuid(),
user_id uuid not null references auth.users (id),
Expand Down
71 changes: 10 additions & 61 deletions postgrest/integrationtest/asuser/reads_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,16 @@ func TestDelimitedIdentifierTableNames(t *testing.T) {
name: "embedded ampersand",
table: "e&f",
},
// The SDK sends "." and ".." as %2E and %2E%2E, which reach their
// tables only through a gateway that forwards them as written.
{
name: "single dot",
table: ".",
},
{
name: "double dot",
table: "..",
},
{
name: "double double dot",
table: "../..",
Expand Down Expand Up @@ -782,67 +792,6 @@ func TestDelimitedIdentifierTableNames(t *testing.T) {
}
}

func TestDelimitedIdentifierTableNameSingleDot(t *testing.T) {
client := newIntegrationClient(t)

rows, response, err := postgrest.Collect(
t.Context(),
client,
postgrest.From[struct{}]("."),
)

if rows != nil {
t.Errorf("rows = %+v, want nil on error", rows)
}
if response != (postgrest.Response{}) {
t.Errorf("response = %+v, want zero value on error", response)
}
if err == nil {
t.Fatal("Collect: want an error - Kong normalizes `.` to the PostgREST OpenAPI root")
}
// The root answers HTTP 200 with the OpenAPI object, so the SDK fails while
// decoding it into a row slice rather than returning an *Error. A decode
// failure (not an HTTP error) is the observable signature of `.` here, and
// the contrast with the double-dot 404 is the point of having both tests
// (see TestDelimitedIdentifierTableNameDoubleDot).
if typedError, ok := errors.AsType[*postgrest.Error](err); ok {
t.Fatalf("got *postgrest.Error %v, want a decoding error (200 OpenAPI object)", typedError)
}
}

func TestDelimitedIdentifierTableNameDoubleDot(t *testing.T) {
client := newIntegrationClient(t)

rows, response, err := postgrest.Collect(
t.Context(),
client,
postgrest.From[struct{}](".."),
)

var typedError *postgrest.Error
if !errors.As(err, &typedError) {
t.Fatalf("want *postgrest.Error, got %T: %v", err, err)
}
// This 404 is Kong's router error, not PostgREST's: `..` normalizes to
// `/rest/` upstream, matching no route. Kong's body carries no PostgREST
// code, so Code is empty - the discriminator from a genuine PGRST205.
if typedError.Code != "" {
t.Errorf("Code = %q, want empty (Kong router 404 carries no PostgREST code)", typedError.Code)
}
if typedError.Message != "no Route matched with those values" {
t.Errorf("Message = %q, want Kong's no-route message", typedError.Message)
}
if typedError.HTTPStatus != http.StatusNotFound {
t.Errorf("HTTPStatus = %d, want 404", typedError.HTTPStatus)
}
if rows != nil {
t.Errorf("rows = %+v, want nil on error", rows)
}
if response != (postgrest.Response{}) {
t.Errorf("response = %+v, want zero value on error", response)
}
}

func newIndexSlice(id int, decimalNumber, character, phonetic string) seededIndexSlice {
return seededIndexSlice{
seededEntity: seededEntity{ID: id},
Expand Down
Loading
Loading