Skip to content
Open
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
228 changes: 177 additions & 51 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,170 @@ concurrency:

env:
CARGO_TERM_COLOR: always
TEST_DATABASE_URL: postgres://postgres:postgres@localhost:5433/locks_test

jobs:
checks:
name: Checks
style:
name: Style / Compose
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.89.0
with:
components: rustfmt

- name: Format
run: cargo fmt --check

- name: Compose bootstrap regression
run: ./scripts/test-compose-bootstrap.sh

- name: Whitespace check
env:
EVENT_NAME: ${{ github.event_name }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PUSH_BEFORE_SHA: ${{ github.event.before }}
run: |
set -euo pipefail

check_current_commit() {
local fallback_base
fallback_base="$(
git rev-parse --verify "$GITHUB_SHA^" 2>/dev/null ||
git hash-object -t tree /dev/null
)"
git diff --check "$fallback_base..$GITHUB_SHA"
}

case "$EVENT_NAME" in
pull_request)
git diff --check "$PR_BASE_SHA...$PR_HEAD_SHA"
;;
push)
zero_sha='0000000000000000000000000000000000000000'
if [[ -n "$PUSH_BEFORE_SHA" && "$PUSH_BEFORE_SHA" != "$zero_sha" ]]; then
if ! git cat-file -e "$PUSH_BEFORE_SHA^{commit}" 2>/dev/null; then
if ! git fetch --no-tags --depth=1 origin "$PUSH_BEFORE_SHA"; then
printf 'unable to fetch push base commit: %s\n' "$PUSH_BEFORE_SHA" >&2
exit 1
fi
fi
if ! git cat-file -e "$PUSH_BEFORE_SHA^{commit}" 2>/dev/null; then
printf 'unable to fetch push base commit: %s\n' "$PUSH_BEFORE_SHA" >&2
exit 1
fi
git diff --check "$PUSH_BEFORE_SHA..$GITHUB_SHA"
else
check_current_commit
fi
;;
workflow_dispatch)
check_current_commit
;;
*)
printf 'unsupported workflow event: %s\n' "$EVENT_NAME" >&2
exit 1
;;
esac

clippy:
name: Clippy
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.89.0
with:
components: clippy

- name: Cache Cargo
uses: Swatinem/rust-cache@v2

- name: Lint
run: cargo clippy --workspace --all-targets --all-features -- -D warnings

rust-tests:
name: Rust tests
runs-on: ubuntu-latest
timeout-minutes: 45
timeout-minutes: 30

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.89.0

- name: Cache Cargo
uses: Swatinem/rust-cache@v2

- name: Install cargo-nextest
uses: taiki-e/install-action@nextest

- name: Unit and integration tests
run: |
cargo nextest run --workspace --exclude locks-e2e --exclude locks-service --exclude locks-sdk-wasm
cargo nextest run -p locks-service --lib -- --skip infrastructure::postgres
cargo nextest run -p locks-e2e --test creator_publishing_http
cargo nextest run -p locks-e2e --test retrieval_access_http
cargo nextest run -p locks-e2e --test production_creator_publishing_http
cargo nextest run -p locks-e2e --test production_creator_authority_acquisition
cargo nextest run -p locks-e2e --test legacy_connect_shell_http
cargo nextest run -p locks-e2e --test pubky_homeserver_repositories

js-wasm:
name: JS / WASM
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.89.0
with:
targets: wasm32-unknown-unknown

- name: Cache Cargo
uses: Swatinem/rust-cache@v2

- name: Install wasm-pack
uses: taiki-e/install-action@v2
with:
tool: wasm-pack@0.13.1

- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '22'
cache: npm
cache-dependency-path: examples/js-sdk/package-lock.json

- name: Install JS example dependencies
run: npm --prefix examples/js-sdk ci

- name: JS/WASM SDK tests
run: npm --prefix locks-sdk/bindings/js run test

postgres:
name: PostgreSQL
runs-on: ubuntu-latest
timeout-minutes: 30

env:
TEST_DATABASE_URL: postgres://postgres:postgres@localhost:5433/locks_test

services:
postgres:
Expand All @@ -43,31 +200,15 @@ jobs:
- name: Checkout
uses: actions/checkout@v5

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends pkg-config libssl-dev

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.89.0
with:
components: clippy,rustfmt
targets: wasm32-unknown-unknown

- name: Cache Cargo
uses: Swatinem/rust-cache@v2

- name: Install cargo-nextest
uses: taiki-e/install-action@nextest

- name: Install wasm-pack
run: cargo install wasm-pack --version 0.13.1 --locked

- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '22'

- name: Wait for Postgres
env:
PGPASSWORD: postgres
Expand All @@ -81,38 +222,23 @@ jobs:
echo "Postgres did not become ready" >&2
exit 1

- name: Format
run: cargo fmt --check

- name: Compose bootstrap regression
run: ./scripts/test-compose-bootstrap.sh

- name: Lint
run: cargo clippy --workspace --all-targets --all-features -- -D warnings

- name: Unit tests
run: |
cargo nextest run --workspace --exclude locks-e2e --exclude locks-service --exclude locks-sdk-wasm
cargo nextest run -p locks-service --lib -- --skip infrastructure::postgres

- name: E2E tests
- name: PostgreSQL-backed tests
run: |
cargo nextest run -p locks-e2e --test creator_publishing_http
cargo nextest run -p locks-e2e --test retrieval_access_http
cargo nextest run -p locks-e2e --test production_creator_publishing_http
cargo nextest run -p locks-e2e --test production_creator_authority_acquisition

- name: JS/WASM SDK tests
run: npm --prefix locks-sdk/bindings/js run test
cargo nextest run -p locks-service --lib infrastructure::postgres
cargo nextest run -p locks-e2e --test postgres_runtime

- name: Postgres-backed tests
run: cargo nextest run -p locks-service --lib infrastructure::postgres
checks:
name: Checks
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [style, clippy, rust-tests, js-wasm, postgres]
if: always()

- name: Additional integration tests
steps:
- name: Require successful lanes
run: |
cargo nextest run -p locks-e2e --test legacy_connect_shell_http
cargo nextest run -p locks-e2e --test postgres_runtime
cargo nextest run -p locks-e2e --test pubky_homeserver_repositories

- name: Whitespace check
run: git diff --check
test "${{ needs.style.result }}" = "success"
test "${{ needs.clippy.result }}" = "success"
test "${{ needs['rust-tests'].result }}" = "success"
test "${{ needs['js-wasm'].result }}" = "success"
test "${{ needs.postgres.result }}" = "success"
29 changes: 27 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,33 @@ npm --prefix locks-sdk/bindings/js run test
git diff --check
```

PostgreSQL and E2E tests require `TEST_DATABASE_URL`; CI uses an ephemeral local
PostgreSQL service. Do not claim the full suite passed when only a subset ran.
CI runs five lanes in parallel:

| Lane | Ownership |
| --- | --- |
| `Style / Compose` | Formatting, Compose bootstrap regression, and whitespace |
| `Clippy` | Workspace lint across all targets and features |
| `Rust tests` | Non-PostgreSQL Rust tests and fake/in-memory E2E tests |
| `JS / WASM` | Native bindings, wasm target, generated package, demo, and example smokes |
| `PostgreSQL` | PostgreSQL-backed service tests and runtime E2E |

The `Checks` result aggregates all five lanes. The effective `master` ruleset currently
requires one approving review but does not enforce status checks, so a failing `Checks`
result does not by itself block a merge. Maintainers should add `Checks` as a required
status before treating it as a merge gate. `scripts/check` remains the sequential local
umbrella.

PostgreSQL-backed tests and `postgres_runtime` require `TEST_DATABASE_URL`; CI uses an
Comment thread
ben-kaufman marked this conversation as resolved.
ephemeral local PostgreSQL service. Do not claim the full suite passed when only a subset
ran.

`./scripts/check` preserves a caller-provided `TEST_DATABASE_URL`. When it is unset, the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scripts/check still omits legacy_connect_shell_http and pubky_homeserver_repositories when TEST_DATABASE_URL is unset, even though both are non-PostgreSQL and the CI Rust lane runs them. Could we run those two unconditionally with the other E2E targets so this documented no-database path covers all non-database checks?

script runs the non-database checks and skips the full PostgreSQL-backed workspace run. To
use the repository's default Compose database, run:

```bash
TEST_DATABASE_URL='postgres://locks:locks@localhost:55433/locks_test' ./scripts/check
```

## Pull requests

Expand Down
2 changes: 1 addition & 1 deletion docs/SDK.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ cargo check -p locks-sdk-wasm --target wasm32-unknown-unknown
Full workspace verification additionally requires the local Postgres test database:

```bash
TEST_DATABASE_URL='postgres://postgres:postgres@localhost:5433/locks_test' cargo test --workspace
TEST_DATABASE_URL='postgres://locks:locks@localhost:55433/locks_test' cargo test --workspace
cargo clippy --workspace --all-targets --all-features -- -D warnings
git diff --check
```
2 changes: 1 addition & 1 deletion docs/SDK_RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ npm --prefix locks-sdk/bindings/js publish --dry-run

```bash
cargo fmt
TEST_DATABASE_URL='postgres://postgres:postgres@localhost:5433/locks_test' cargo test --workspace
TEST_DATABASE_URL='postgres://locks:locks@localhost:55433/locks_test' cargo test --workspace
cargo clippy --workspace --all-targets --all-features -- -D warnings
git diff --check
```
Expand Down
4 changes: 1 addition & 3 deletions scripts/check
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail

TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5433/locks_test

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"

Expand All @@ -25,7 +23,7 @@ run cargo nextest run -p locks-e2e --test production_creator_authority_acquisiti
run npm --prefix locks-sdk/bindings/js run test

if [[ -n "${TEST_DATABASE_URL:-}" ]]; then
run env TEST_DATABASE_URL="$TEST_DATABASE_URL" cargo nextest run --workspace
run cargo nextest run --workspace
else
printf '\n==> skipping Postgres-backed full workspace checks: TEST_DATABASE_URL is not set\n'
printf ' Set TEST_DATABASE_URL=postgres://user:pass@host:port/db to include them.\n'
Expand Down