Skip to content

Commit 83134fd

Browse files
authored
Merge branch 'main' into Unread_notification_count
2 parents e66d31a + 779ac6d commit 83134fd

193 files changed

Lines changed: 26181 additions & 5588 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/SECURITY_SETUP_CHECKLIST.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GitHub Security Setup Checklist
22

3-
This checklist helps ensure that GitHub's security features are properly configured for the FlowFi repository.
3+
This checklist helps repository administrators ensure that GitHub's security features are properly configured for the FlowFi repository. For the canonical security policy (reporting guidelines, supported versions, response timelines), see [SECURITY.md](../SECURITY.md). For the implementation status and next steps, see [SECURITY_IMPLEMENTATION_SUMMARY.md](../SECURITY_IMPLEMENTATION_SUMMARY.md).
44

55
## Repository Security Settings
66

.github/workflows/ci.yml

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ on:
1313
branches: [main, develop]
1414

1515
jobs:
16+
changes:
17+
name: Detect changes
18+
runs-on: ubuntu-latest
19+
outputs:
20+
backend: ${{ steps.filter.outputs.backend }}
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Check changed files
26+
id: filter
27+
uses: dorny/paths-filter@v3
28+
with:
29+
filters: |
30+
backend:
31+
- 'backend/**'
32+
- 'package-lock.json'
33+
1634
frontend:
1735
name: Frontend CI
1836
runs-on: ubuntu-latest
@@ -34,10 +52,6 @@ jobs:
3452
run: npm run lint
3553
working-directory: frontend
3654

37-
- name: Install Rollup Native Binding
38-
run: npm install @rollup/rollup-linux-x64-gnu --no-save
39-
working-directory: frontend
40-
4155
- name: Run Frontend Tests
4256
run: npm run test:coverage
4357
working-directory: frontend
@@ -46,9 +60,17 @@ jobs:
4660
run: npm run build
4761
working-directory: frontend
4862

63+
- name: Check frontend bundle size
64+
run: bash ./scripts/check-bundle-size.sh
65+
working-directory: frontend
66+
4967
backend:
5068
name: Backend CI
5169
runs-on: ubuntu-latest
70+
needs: changes
71+
if: >-
72+
github.event_name == 'push' ||
73+
needs.changes.outputs.backend == 'true'
5274
services:
5375
postgres:
5476
image: postgres:16-alpine@sha256:e013e867e712fec275706a6c51c966f0bb0c93cfa8f51000f85a15f9865a28cb
@@ -90,8 +112,14 @@ jobs:
90112
run: npm run build
91113
working-directory: backend
92114

93-
- name: Install Rollup Native Binding
94-
run: npm install @rollup/rollup-linux-x64-gnu --no-save
115+
- name: OpenAPI spec & API types drift check
116+
run: |
117+
cd backend
118+
npm run codegen:openapi
119+
cd ../frontend
120+
npm run codegen:api-types
121+
cd ..
122+
git diff --exit-code -- backend/swagger/flowfi.openapi.json frontend/src/lib/api-types.generated.ts
95123
96124
- name: Run Backend Tests
97125
run: |
@@ -192,8 +220,16 @@ jobs:
192220
run: cargo test
193221
working-directory: contracts
194222

223+
- name: Cache cargo-tarpaulin
224+
id: tarpaulin-cache
225+
uses: actions/cache@v4
226+
with:
227+
path: ~/.cargo/bin/cargo-tarpaulin
228+
key: cargo-tarpaulin-${{ runner.os }}-0.37.2
229+
195230
- name: Install cargo-tarpaulin
196-
run: cargo install cargo-tarpaulin --locked
231+
if: steps.tarpaulin-cache.outputs.cache-hit != 'true'
232+
run: cargo install cargo-tarpaulin@0.37.2 --locked
197233

198234
- name: Run Contract Coverage
199235
run: cargo tarpaulin --workspace --out Xml --output-dir coverage --fail-under 70
@@ -212,9 +248,26 @@ jobs:
212248

213249
- name: Install Stellar CLI
214250
run: |
215-
curl -fsSL https://github.com/stellar/stellar-cli/raw/main/install.sh | sh -s -- --install-deps
216-
echo "$HOME/.stellar-cli/bin" >> $GITHUB_PATH
251+
set -euo pipefail
252+
# Authenticate the release lookup through the runner's token. The
253+
# upstream installer queries the unauthenticated GitHub API and can
254+
# fail on shared-runner rate limits.
255+
mkdir -p "$RUNNER_TEMP/stellar-cli"
256+
stellar_cli_tag=$(gh release view --repo stellar/stellar-cli --json tagName --jq .tagName)
257+
gh release download "$stellar_cli_tag" \
258+
--repo stellar/stellar-cli \
259+
--pattern 'stellar-cli-*-x86_64-unknown-linux-gnu.tar.gz' \
260+
--dir "$RUNNER_TEMP/stellar-cli" \
261+
--clobber
262+
tar -xzf "$RUNNER_TEMP/stellar-cli/stellar-cli-"*.tar.gz \
263+
-C "$RUNNER_TEMP/stellar-cli"
264+
mkdir -p "$HOME/.stellar-cli/bin"
265+
mv "$RUNNER_TEMP/stellar-cli/stellar" "$HOME/.stellar-cli/bin/stellar"
266+
chmod +x "$HOME/.stellar-cli/bin/stellar"
267+
echo "$HOME/.stellar-cli/bin" >> "$GITHUB_PATH"
217268
shell: bash
269+
env:
270+
GH_TOKEN: ${{ github.token }}
218271

219272
- name: Optimize WASM files
220273
run: |
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# Contract Deployment Workflow for FlowFi
2+
#
3+
# Compiles the Soroban stream contract to optimized WASM, runs contract tests,
4+
# and deploys + initializes the contract on Stellar Testnet on demand (or on
5+
# Mainnet for release tags). The resulting contract ID is surfaced in the job
6+
# summary and published as a release artifact.
7+
name: Deploy Soroban Contracts
8+
9+
on:
10+
release:
11+
types: [published]
12+
workflow_dispatch:
13+
inputs:
14+
network:
15+
description: "Target network (testnet|mainnet)"
16+
required: true
17+
default: "testnet"
18+
type: choice
19+
options:
20+
- testnet
21+
- mainnet
22+
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ inputs.network || github.ref }}
25+
cancel-in-progress: true
26+
27+
permissions:
28+
contents: write
29+
30+
jobs:
31+
deploy:
32+
name: Build & Deploy stream_contract
33+
runs-on: ubuntu-latest
34+
environment: ${{ github.event_name == 'release' && 'production' || 'staging' }}
35+
36+
env:
37+
NETWORK: ${{ inputs.network || (github.event_name == 'release' && 'mainnet' || 'testnet') }}
38+
DEPLOYER_SECRET: ${{ secrets.DEPLOYER_SECRET }}
39+
ADMIN_ADDRESS: ${{ secrets.ADMIN_ADDRESS }}
40+
TREASURY_ADDRESS: ${{ secrets.TREASURY_ADDRESS }}
41+
FEE_RATE_BPS: ${{ secrets.FEE_RATE_BPS }}
42+
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
47+
- name: Setup Rust toolchain
48+
uses: dtolnay/rust-toolchain@stable
49+
with:
50+
toolchain: stable
51+
targets: wasm32-unknown-unknown
52+
components: rustfmt, clippy
53+
54+
- name: Rust Cache
55+
uses: Swatinem/rust-cache@v2
56+
with:
57+
workspace: "contracts -> target"
58+
59+
- name: Install Stellar CLI
60+
run: |
61+
curl -fsSL https://github.com/stellar/stellar-cli/raw/main/install.sh | sh -s -- --install-deps
62+
echo "$HOME/.stellar-cli/bin" >> $GITHUB_PATH
63+
64+
- name: Run Contract Tests
65+
run: cargo test --package stream_contract
66+
working-directory: contracts
67+
68+
- name: Build & Optimize WASM
69+
run: |
70+
set -euo pipefail
71+
cd contracts
72+
cargo build --target wasm32-unknown-unknown --release
73+
RELEASE_DIR="target/wasm32-unknown-unknown/release"
74+
for w in "$RELEASE_DIR"/stream_contract.wasm; do
75+
stellar contract optimize --wasm "$w" --wasm-out "$RELEASE_DIR/stream_contract.optimized.wasm"
76+
done
77+
ls -la "$RELEASE_DIR"/*.wasm
78+
79+
- name: Inspect Contract Interface & WASM Size
80+
run: |
81+
set -euo pipefail
82+
WASM=contracts/target/wasm32-unknown-unknown/release/stream_contract.optimized.wasm
83+
stellar contract inspect --wasm "$WASM"
84+
SIZE=$(stat -c%s "$WASM")
85+
echo "Optimized WASM size: $SIZE bytes"
86+
if [ "$SIZE" -ge 65536 ]; then
87+
echo "ERROR: optimized WASM exceeds 64KB budget ($SIZE bytes)"
88+
exit 1
89+
fi
90+
echo "WASM_WASM_PATH=$WASM" >> $GITHUB_ENV
91+
92+
- name: Deploy & Initialize Contract
93+
run: ./scripts/deploy.sh --network "$NETWORK"
94+
95+
- name: Read Deployed Contract ID
96+
id: contract
97+
run: |
98+
set -euo pipefail
99+
CONTRACT_ID=$(jq -r --arg net "$NETWORK" '.[$net].contractId' deployment-info.json)
100+
echo "contract_id=$CONTRACT_ID" >> $GITHUB_OUTPUT
101+
echo "deployment-json=$(jq -c . deployment-info.json)" >> $GITHUB_OUTPUT
102+
103+
- name: Emit Deployment Summary
104+
if: always()
105+
run: |
106+
{
107+
echo "## Deployment Summary"
108+
echo ""
109+
echo "- **Network**: \`$NETWORK\`"
110+
echo "- **Contract ID**: \`${{ steps.contract.outputs.contract_id }}\`"
111+
echo "- **WASM**: \`${{ env.WASM_WASM_PATH }}\`"
112+
echo "- **Deployment info**: "
113+
echo '```json'
114+
echo "${{ steps.contract.outputs.deployment-json }}"
115+
echo '```'
116+
} >> "$GITHUB_STEP_SUMMARY"
117+
118+
- name: Upload Optimized WASM Artifact
119+
uses: actions/upload-artifact@v4
120+
with:
121+
name: stream-contract-${{ env.NETWORK }}
122+
path: contracts/target/wasm32-unknown-unknown/optimized/*.wasm
123+
if-no-files-found: error
124+
125+
- name: Upload Deployment Info
126+
uses: actions/upload-artifact@v4
127+
with:
128+
name: deployment-info-${{ env.NETWORK }}
129+
path: deployment-info.json
130+
if-no-files-found: error
131+
132+
- name: Commit Deployment Info
133+
if: github.event_name == 'release'
134+
env:
135+
NETWORK: ${{ env.NETWORK }}
136+
run: |
137+
set -euo pipefail
138+
git config user.name "github-actions[bot]"
139+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
140+
git add deployment-info.json
141+
if git diff --cached --quiet; then
142+
echo "No deployment-info.json changes to commit"
143+
exit 0
144+
fi
145+
git commit -m "chore(contracts): record $NETWORK contract deployment"
146+
git push

.github/workflows/pr-test-gate.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ jobs:
2727
runs-on: ubuntu-latest
2828
services:
2929
postgres:
30-
image: postgres:15
30+
# Pinned to match the version used in ci.yml and docker-compose.yml
31+
# (production target). Keep these in sync — see issue #1282.
32+
image: postgres:16-alpine@sha256:e013e867e712fec275706a6c51c966f0bb0c93cfa8f51000f85a15f9865a28cb
3133
env:
3234
POSTGRES_USER: postgres
3335
POSTGRES_PASSWORD: password
@@ -61,11 +63,6 @@ jobs:
6163
env:
6264
DATABASE_URL: postgresql://postgres:password@127.0.0.1:5432/flowfi_test
6365

64-
- name: Install Native Bindings
65-
run: |
66-
npm install @rollup/rollup-linux-x64-gnu --no-save
67-
working-directory: backend
68-
6966
- name: Run backend tests
7067
run: |
7168
ls -la src/generated/prisma

0 commit comments

Comments
 (0)