Skip to content

Commit 9bb8342

Browse files
authored
gh: Add workflows
1 parent 4276997 commit 9bb8342

5 files changed

Lines changed: 203 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
DATABASE_URL: postgresql://pointer:pointer@localhost:5432/pointer
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
services:
16+
postgres:
17+
image: postgres:18
18+
ports:
19+
- 5432:5432
20+
env:
21+
POSTGRES_USER: pointer
22+
POSTGRES_PASSWORD: pointer
23+
POSTGRES_DB: pointer
24+
options: >-
25+
--health-cmd="pg_isready -U pointer -d pointer"
26+
--health-interval=10s
27+
--health-timeout=5s
28+
--health-retries=5
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Set up Rust
33+
uses: dtolnay/rust-toolchain@nightly
34+
with:
35+
targets: wasm32-unknown-unknown
36+
37+
- name: Cache cargo data
38+
uses: Swatinem/rust-cache@v2
39+
40+
- name: Install build tooling
41+
run: |
42+
sudo apt-get update
43+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql-client
44+
45+
- name: Install cargo-leptos (prebuilt)
46+
uses: taiki-e/install-action@v2
47+
with:
48+
tool: cargo-leptos
49+
50+
- name: Cache sqlx-cli
51+
uses: actions/cache@v4
52+
with:
53+
path: ~/.cargo/bin/sqlx
54+
key: ${{ runner.os }}-sqlx-cli-${{ hashFiles('Cargo.lock', 'backend/Cargo.lock') }}
55+
56+
- name: Install sqlx-cli
57+
run: |
58+
if ! command -v sqlx >/dev/null; then
59+
cargo install --locked sqlx-cli --no-default-features --features postgres,rustls
60+
fi
61+
62+
- name: Wait for Postgres
63+
run: pg_isready -h localhost -p 5432 -U pointer -d pointer
64+
env:
65+
PGUSER: pointer
66+
PGPASSWORD: pointer
67+
68+
- name: Apply migrations
69+
working-directory: backend
70+
run: sqlx migrate run --source migrations
71+
env:
72+
PGUSER: pointer
73+
PGPASSWORD: pointer
74+
75+
- name: cargo leptos test
76+
run: cargo leptos test
77+
78+
- name: Backend tests
79+
run: cargo test
80+
working-directory: backend
81+
82+
- name: Indexer tests
83+
run: cargo test
84+
working-directory: indexer

.github/workflows/release.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
DATABASE_URL: postgresql://pointer:pointer@localhost:5432/pointer
12+
13+
jobs:
14+
build-musl:
15+
runs-on: ubuntu-latest
16+
services:
17+
postgres:
18+
image: postgres:18
19+
ports:
20+
- 5432:5432
21+
env:
22+
POSTGRES_USER: pointer
23+
POSTGRES_PASSWORD: pointer
24+
POSTGRES_DB: pointer
25+
options: >-
26+
--health-cmd="pg_isready -U pointer -d pointer"
27+
--health-interval=10s
28+
--health-timeout=5s
29+
--health-retries=5
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Set up Rust
34+
uses: dtolnay/rust-toolchain@nightly
35+
with:
36+
targets: wasm32-unknown-unknown,x86_64-unknown-linux-musl
37+
38+
- name: Cache cargo data
39+
uses: Swatinem/rust-cache@v2
40+
41+
- name: Install build tooling
42+
run: |
43+
sudo apt-get update
44+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql-client build-essential musl-tools
45+
46+
- name: Install cargo-leptos (prebuilt)
47+
uses: taiki-e/install-action@v2
48+
with:
49+
tool: cargo-leptos
50+
51+
- name: Cache sqlx-cli
52+
uses: actions/cache@v4
53+
with:
54+
path: ~/.cargo/bin/cargo-sqlx
55+
key: ${{ runner.os }}-sqlx-cli-${{ hashFiles('Cargo.lock', 'backend/Cargo.lock') }}
56+
57+
- name: Install sqlx-cli
58+
run: |
59+
if ! command -v sqlx >/dev/null; then
60+
cargo install --locked sqlx-cli --no-default-features --features postgres,rustls
61+
fi
62+
63+
- name: Wait for Postgres
64+
run: pg_isready -h localhost -p 5432 -U pointer -d pointer
65+
env:
66+
PGUSER: pointer
67+
PGPASSWORD: pointer
68+
69+
- name: Apply migrations
70+
working-directory: backend
71+
run: sqlx migrate run --source migrations
72+
env:
73+
PGUSER: pointer
74+
PGPASSWORD: pointer
75+
76+
- name: Build pointer (wasm + binary)
77+
env:
78+
LEPTOS_BIN_TARGET_TRIPLE: x86_64-unknown-linux-musl
79+
run: cargo leptos build --release -P --bin-features vendored,ssr
80+
81+
- name: Build pointer-backend
82+
run: cargo build --locked --release -p pointer-backend --target x86_64-unknown-linux-musl --features vendored
83+
84+
- name: Build pointer-indexer
85+
run: cargo build --locked --release -p pointer-indexer --target x86_64-unknown-linux-musl --features vendored
86+
87+
- name: Package artifacts
88+
run: |
89+
set -euo pipefail
90+
mkdir -p artifacts pointer/target
91+
92+
# Package pointer assets + binary
93+
POINTER_BIN="$(find target -path '*/release/pointer' -type f | head -n1)"
94+
cp "$POINTER_BIN" pointer/pointer
95+
cp -r target/site pointer/target/site
96+
cp Cargo.toml pointer/Cargo.toml
97+
tar -czf artifacts/pointer.tar.gz -C pointer .
98+
99+
# Package backend and indexer binaries
100+
for bin in pointer-backend pointer-indexer; do
101+
BIN_PATH="$(find target -path "*/release/${bin}" -type f | head -n1)"
102+
cp "$BIN_PATH" "artifacts/${bin}"
103+
tar -czf "artifacts/${bin}.tar.gz" -C artifacts "${bin}"
104+
done
105+
106+
- name: Upload artifacts
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: pointer-release-artifacts
110+
path: artifacts/*.tar.gz

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ thiserror = ["dep:thiserror"]
134134

135135
server_fn_macro_default = ["dep:server_fn_macro_default"]
136136
autumnus = ["dep:autumnus"]
137+
vendored = ["pointer-indexer/vendored"]
137138

138139
# Defines a size-optimized profile for the WASM bundle in release mode
139140
[profile.wasm-release]

backend/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ syntect = { version = "5", default-features = false, features = ["default-fancy"
2424
futures = "0.3"
2525
tempfile = "3"
2626
chrono = { version = "0.4", features = ["serde"] }
27+
28+
[features]
29+
vendored = ["pointer-indexer/vendored"]

indexer/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,10 @@ tree-sitter-glsl = "0.2.0"
4040
crossbeam-channel = "0.5"
4141
humantime = "2.1"
4242

43+
[features]
44+
vendored = [
45+
"git2/vendored-openssl"
46+
]
47+
4348
[dev-dependencies]
4449
pretty_assertions = "1"

0 commit comments

Comments
 (0)