-
Notifications
You must be signed in to change notification settings - Fork 69
186 lines (163 loc) · 5.97 KB
/
Copy pathci.yml
File metadata and controls
186 lines (163 loc) · 5.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: CI
# Runs on every PR and every push to main. A new push to the same PR/branch
# cancels whatever run is already in flight for it, so we never burn minutes
# on a superseded commit.
on:
pull_request:
push:
branches: [main]
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
# sqlx query! / query_as! macros validate against the committed .sqlx/
# metadata instead of opening a DB connection at compile time. The `sqlx`
# job below is the one place that regenerates/validates that metadata
# against a live database.
SQLX_OFFLINE: "true"
jobs:
fmt:
name: fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust (rustfmt)
run: rustup component add rustfmt
# rustfmt doesn't need dependency compilation, so no rust-cache here —
# keeps this job (the fastest gate) free of cache-restore overhead.
- name: cargo fmt --check
run: cargo fmt --all --check
clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust (clippy)
run: rustup component add clippy
# Swatinem/rust-cache keys on Cargo.lock + rustc version and restores
# ~/.cargo/registry, ~/.cargo/git, and target/ in one step. Combined
# with the shared rust-toolchain.toml (same rustc across all jobs),
# this is what keeps warm-cache runs well under the 20-minute budget —
# clippy and test each skip recompiling the ~250-crate dependency graph
# and only rebuild this crate's own code.
- uses: Swatinem/rust-cache@v2
with:
shared-key: cargo-linux
- name: cargo clippy (deny warnings)
run: cargo clippy --all-targets --all-features -- -D warnings
test:
name: test
runs-on: ubuntu-latest
services:
postgres:
# postgis/postgis bundles the PostGIS extension required by
# migration 0056 (creator_locations); plain postgres:15 lacks it.
image: postgis/postgis:15-3.4-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: tipjar_test
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U postgres -d tipjar_test"
--health-interval=5s
--health-timeout=5s
--health-retries=10
redis:
image: redis:7
ports:
- 6379:6379
options: >-
--health-cmd="redis-cli ping"
--health-interval=5s
--health-timeout=5s
--health-retries=10
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/tipjar_test
TEST_DATABASE_URL: postgres://postgres:password@localhost:5432/tipjar_test
REDIS_URL: redis://127.0.0.1:6379
STELLAR_NETWORK: testnet
STELLAR_RPC_URL: https://soroban-testnet.stellar.org
# Test-only dummy key for EncryptionKeyManager; never use in production.
ENCRYPTION_KEY_CURRENT: "0000000000000000000000000000000000000000000000000000000000000000"
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
shared-key: cargo-linux
- name: Install sqlx-cli
uses: taiki-e/install-action@v2
with:
tool: sqlx-cli@0.8
- name: Run SQL migrations
run: sqlx migrate run --source migrations
# Runs the full suite: unit tests, the integration tests under tests/,
# and doc tests. SQLX_OFFLINE is unset here (not exported above) so any
# ad-hoc query macro added since the last `cargo sqlx prepare` is still
# caught by compiling against the just-migrated live database rather
# than stale cached metadata.
- name: cargo test --all-features
env:
SQLX_OFFLINE: "false"
run: cargo test --all-features -- --nocapture
sqlx:
name: sqlx
runs-on: ubuntu-latest
services:
postgres:
image: postgis/postgis:15-3.4-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: tipjar_test
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U postgres -d tipjar_test"
--health-interval=5s
--health-timeout=5s
--health-retries=10
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/tipjar_test
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
shared-key: cargo-linux
- name: Install sqlx-cli
uses: taiki-e/install-action@v2
with:
tool: sqlx-cli@0.8
- name: Run SQL migrations
run: sqlx migrate run --source migrations
# The actual drift gate: regenerates query metadata from the live,
# fully-migrated schema and fails the build if it differs from what's
# committed under .sqlx/ — i.e. someone changed a query or the schema
# without re-running `cargo sqlx prepare`.
- name: cargo sqlx prepare --check
env:
SQLX_OFFLINE: "false"
run: cargo sqlx prepare --check --workspace -- --all-targets --all-features
docker:
name: docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Build-only (no push): proves the production image still builds.
# cache-from/cache-to gha persists Docker layer cache (including the
# cargo registry/target BuildKit cache mounts declared in the
# Dockerfile) in the GitHub Actions cache backend between runs, so a
# warm-cache rebuild after a small source change only recompiles this
# crate instead of the full dependency graph.
- name: Build production image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: false
cache-from: type=gha
cache-to: type=gha,mode=max