Skip to content

Commit 2e59db9

Browse files
committed
1.0.0
0 parents  commit 2e59db9

35 files changed

+11442
-0
lines changed

.github/workflows/rust.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
check:
14+
name: Check
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: dtolnay/rust-toolchain@stable
19+
- uses: actions/cache@v4
20+
with:
21+
path: |
22+
~/.cargo/registry/
23+
~/.cargo/git/
24+
target/
25+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
26+
- run: cargo check --all-features
27+
28+
fmt:
29+
name: Format
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: dtolnay/rust-toolchain@stable
34+
with:
35+
components: rustfmt
36+
- run: cargo fmt --all -- --check
37+
38+
clippy:
39+
name: Clippy
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: dtolnay/rust-toolchain@stable
44+
with:
45+
components: clippy
46+
- uses: actions/cache@v4
47+
with:
48+
path: |
49+
~/.cargo/registry/
50+
~/.cargo/git/
51+
target/
52+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
53+
- run: cargo clippy --all-features -- -D warnings
54+
55+
test-unit:
56+
name: Unit Tests
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: dtolnay/rust-toolchain@stable
61+
- uses: actions/cache@v4
62+
with:
63+
path: |
64+
~/.cargo/registry/
65+
~/.cargo/git/
66+
target/
67+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
68+
- run: cargo test --lib --all-features
69+
70+
test-integration:
71+
name: Integration Tests
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@v4
75+
- uses: dtolnay/rust-toolchain@stable
76+
- uses: actions/cache@v4
77+
with:
78+
path: |
79+
~/.cargo/registry/
80+
~/.cargo/git/
81+
target/
82+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
83+
- run: cargo test --test '*' --all-features

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Cargo
2+
# will have compiled files and executables
3+
debug/
4+
target/
5+
6+
# These are backup files generated by rustfmt
7+
**/*.rs.bk
8+
9+
# MSVC Windows builds of rustc generate these, which store debugging information
10+
*.pdb
11+
12+
# RustRover
13+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
14+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
15+
# and can be added to the global gitignore or merged into this file. For a more nuclear
16+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
17+
.idea/

AGENTS.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
- Crate source lives in `src/` with one module per Supabase service (`auth.rs`, `postgrest.rs`, `storage.rs`, `functions.rs`, `graphql.rs`, `realtime.rs`, `analytics.rs`); `lib.rs` re-exports them.
5+
- Shared constants and errors sit in `consts.rs` and `error.rs`; add cross-cutting values there before duplicating literals.
6+
- Integration coverage is in `tests/auth_integration.rs` and spins up real containers via Testcontainers, so Docker must be running.
7+
- Reference docs live in `docs/`; `README.md` shows usage patterns. Build artifacts land in `target/` and stay untracked.
8+
9+
## Build, Test, and Development Commands
10+
- `cargo build --all-features` — compile with every service flag to catch cfg gaps; narrow scope with `--features "<list>"` when iterating.
11+
- `cargo fmt --all` — format with rustfmt; run before pushing.
12+
- `cargo clippy --all-targets --all-features -D warnings` — lint everything; prefer fixes over `allow` unless unavoidable.
13+
- `cargo test --features auth,const --test auth_integration -- --nocapture` — integration tests against real containers; first run pulls images and may take minutes.
14+
15+
## Coding Style & Naming Conventions
16+
- Rustfmt defaults (4-space indent); keep imports explicit and prefer early returns over deep nesting.
17+
- Modules/functions use `snake_case`; public structs/enums use `PascalCase`; constants use `SCREAMING_SNAKE_CASE`.
18+
- Keep feature gates tight and named after services (`auth`, `postgrest`, `storage`, etc.); document new flags in `Cargo.toml` and `README.md`.
19+
- Use `anyhow::Result` for setup paths and `thiserror` for user-facing error types; add short doc comments for public items.
20+
21+
## Testing Guidelines
22+
- Docker is mandatory; tests start PostgreSQL and service containers.
23+
- Name new integration files `tests/<service>_integration.rs` and test functions `test_<behavior>` for clarity.
24+
- Include a health or behavior check per service (e.g., `/health` plus one request).
25+
- For parallel runs, generate unique networks/container names (see `unique_test_id()` in the Auth suite) to avoid port collisions.
26+
27+
## Commit & Pull Request Guidelines
28+
- Follow Conventional Commits used here (`feat`, `docs`, `chore`, `fix`, optional scopes); keep messages imperative.
29+
- PRs should note behavior changes, enabled features (if not `--all-features`), and commands run (fmt, clippy, tests).
30+
- Link related issues and attach logs or screenshots for user-visible changes; keep diffs focused and split unrelated tweaks.
31+
32+
## Security & Configuration Tips
33+
- Never commit real credentials; mirror the test pattern of generated passwords and isolated networks.
34+
- Pin explicit image tags instead of `latest`; match versions documented in `README.md`.
35+
- Prefer Testcontainers-managed dynamic ports; expose only what the test actually needs.

CLAUDE.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Build and Test Commands
6+
7+
```bash
8+
# Build the project
9+
cargo build
10+
11+
# Build with all features
12+
cargo build --all-features
13+
14+
# Build with specific feature
15+
cargo build --features auth
16+
17+
# Run all tests
18+
cargo test --all-features
19+
20+
# Run tests for a specific feature
21+
cargo test --features auth
22+
23+
# Run a single test
24+
cargo test --features auth test_auth_default
25+
26+
# Check code without building
27+
cargo check --all-features
28+
29+
# Format code
30+
cargo fmt
31+
32+
# Lint with clippy
33+
cargo clippy --all-features
34+
```
35+
36+
## Architecture
37+
38+
This crate provides testcontainers implementations for Supabase services. Each service module follows the same pattern:
39+
40+
1. **Module structure** (`src/<service>.rs`): Each service implements the `testcontainers::Image` trait with:
41+
- A struct holding `env_vars: HashMap<String, String>` for container configuration
42+
- `Default` impl with pre-configured environment variables
43+
- Builder methods for customization (e.g., `with_postgres_connection`)
44+
- `Image` trait impl defining `name()`, `tag()`, and `ready_conditions()`
45+
46+
2. **Feature-gated modules**: All service modules are conditionally compiled via Cargo features. The `lib.rs` re-exports public types based on enabled features.
47+
48+
3. **Shared constants** (`src/consts.rs`): Common values like `DOCKER_INTERNAL_HOST` and `LOCAL_HOST` for container networking.
49+
50+
## Key Patterns
51+
52+
- Services requiring PostgreSQL use `tokio_postgres` for database initialization (see `Auth::init_db_schema`)
53+
- Container environment variables are stored in a `HashMap<String, String>` and exposed via the `Image::env_vars()` trait method
54+
- Tests use `testcontainers::runners::AsyncRunner` with tokio for async container management
55+
56+
## Available Features
57+
58+
- `auth`, `postgrest`, `storage`, `analytics`, `functions`, `graphql`, `realtime` - Individual service containers
59+
- `const` - Shared constants (auto-enabled by service features)
60+
- `error` - Error types
61+
- `postgres_testcontainer` - PostgreSQL container support

0 commit comments

Comments
 (0)