diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1f999a7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,84 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +env: + CARGO_TERM_COLOR: always + DATABASE_URL: postgresql://pointer:pointer@localhost:5432/pointer + +jobs: + test: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:18 + ports: + - 5432:5432 + env: + POSTGRES_USER: pointer + POSTGRES_PASSWORD: pointer + POSTGRES_DB: pointer + options: >- + --health-cmd="pg_isready -U pointer -d pointer" + --health-interval=10s + --health-timeout=5s + --health-retries=5 + steps: + - uses: actions/checkout@v4 + + - name: Set up Rust + uses: dtolnay/rust-toolchain@nightly + with: + targets: wasm32-unknown-unknown + + - name: Cache cargo data + uses: Swatinem/rust-cache@v2 + + - name: Install build tooling + run: | + sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql-client + + - name: Install cargo-leptos (prebuilt) + uses: taiki-e/install-action@v2 + with: + tool: cargo-leptos + + - name: Cache sqlx-cli + uses: actions/cache@v4 + with: + path: ~/.cargo/bin/sqlx + key: ${{ runner.os }}-sqlx-cli-${{ hashFiles('Cargo.lock', 'backend/Cargo.lock') }} + + - name: Install sqlx-cli + run: | + if ! command -v sqlx >/dev/null; then + cargo install --locked sqlx-cli --no-default-features --features postgres,rustls + fi + + - name: Wait for Postgres + run: pg_isready -h localhost -p 5432 -U pointer -d pointer + env: + PGUSER: pointer + PGPASSWORD: pointer + + - name: Apply migrations + working-directory: backend + run: sqlx migrate run --source migrations + env: + PGUSER: pointer + PGPASSWORD: pointer + + - name: cargo leptos test + run: cargo leptos test + + - name: Backend tests + run: cargo test + working-directory: backend + + - name: Indexer tests + run: cargo test + working-directory: indexer diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ecb7eea --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,110 @@ +name: Release + +on: + push: + tags: + - "v*" + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + DATABASE_URL: postgresql://pointer:pointer@localhost:5432/pointer + +jobs: + build-musl: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:18 + ports: + - 5432:5432 + env: + POSTGRES_USER: pointer + POSTGRES_PASSWORD: pointer + POSTGRES_DB: pointer + options: >- + --health-cmd="pg_isready -U pointer -d pointer" + --health-interval=10s + --health-timeout=5s + --health-retries=5 + steps: + - uses: actions/checkout@v4 + + - name: Set up Rust + uses: dtolnay/rust-toolchain@nightly + with: + targets: wasm32-unknown-unknown,x86_64-unknown-linux-musl + + - name: Cache cargo data + uses: Swatinem/rust-cache@v2 + + - name: Install build tooling + run: | + sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql-client build-essential musl-tools + + - name: Install cargo-leptos (prebuilt) + uses: taiki-e/install-action@v2 + with: + tool: cargo-leptos + + - name: Cache sqlx-cli + uses: actions/cache@v4 + with: + path: ~/.cargo/bin/cargo-sqlx + key: ${{ runner.os }}-sqlx-cli-${{ hashFiles('Cargo.lock', 'backend/Cargo.lock') }} + + - name: Install sqlx-cli + run: | + if ! command -v sqlx >/dev/null; then + cargo install --locked sqlx-cli --no-default-features --features postgres,rustls + fi + + - name: Wait for Postgres + run: pg_isready -h localhost -p 5432 -U pointer -d pointer + env: + PGUSER: pointer + PGPASSWORD: pointer + + - name: Apply migrations + working-directory: backend + run: sqlx migrate run --source migrations + env: + PGUSER: pointer + PGPASSWORD: pointer + + - name: Build pointer (wasm + binary) + env: + LEPTOS_BIN_TARGET_TRIPLE: x86_64-unknown-linux-musl + run: cargo leptos build --release -P --bin-features vendored,ssr + + - name: Build pointer-backend + run: cargo build --locked --release -p pointer-backend --target x86_64-unknown-linux-musl --features vendored + + - name: Build pointer-indexer + run: cargo build --locked --release -p pointer-indexer --target x86_64-unknown-linux-musl --features vendored + + - name: Package artifacts + run: | + set -euo pipefail + mkdir -p artifacts pointer/target + + # Package pointer assets + binary + POINTER_BIN="$(find target -path '*/release/pointer' -type f | head -n1)" + cp "$POINTER_BIN" pointer/pointer + cp -r target/site pointer/target/site + cp Cargo.toml pointer/Cargo.toml + tar -czf artifacts/pointer.tar.gz -C pointer . + + # Package backend and indexer binaries + for bin in pointer-backend pointer-indexer; do + BIN_PATH="$(find target -path "*/release/${bin}" -type f | head -n1)" + cp "$BIN_PATH" "artifacts/${bin}" + tar -czf "artifacts/${bin}.tar.gz" -C artifacts "${bin}" + done + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: pointer-release-artifacts + path: artifacts/*.tar.gz diff --git a/Cargo.toml b/Cargo.toml index 7bcdbfe..56da968 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -134,6 +134,7 @@ thiserror = ["dep:thiserror"] server_fn_macro_default = ["dep:server_fn_macro_default"] autumnus = ["dep:autumnus"] +vendored = ["pointer-indexer/vendored"] # Defines a size-optimized profile for the WASM bundle in release mode [profile.wasm-release] diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 84e5461..d1665f3 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -24,3 +24,6 @@ syntect = { version = "5", default-features = false, features = ["default-fancy" futures = "0.3" tempfile = "3" chrono = { version = "0.4", features = ["serde"] } + +[features] +vendored = ["pointer-indexer/vendored"] \ No newline at end of file diff --git a/indexer/Cargo.toml b/indexer/Cargo.toml index fe579d6..f82f60f 100644 --- a/indexer/Cargo.toml +++ b/indexer/Cargo.toml @@ -40,5 +40,10 @@ tree-sitter-glsl = "0.2.0" crossbeam-channel = "0.5" humantime = "2.1" +[features] +vendored = [ + "git2/vendored-openssl" +] + [dev-dependencies] pretty_assertions = "1"