e3c75b8
commit e3c75b8
5 files changed
+324 -0
Showing 5 changed files+324-0
▼.github/dependabot.yml
+26-0
| @@ -0,0 +1,26 @@ | ||
1 | +version: 2 | |
2 | +updates: | |
3 | + - package-ecosystem: cargo | |
4 | + directory: "/" | |
5 | + schedule: | |
6 | + interval: weekly | |
7 | + day: monday | |
8 | + open-pull-requests-limit: 10 | |
9 | + labels: | |
10 | + - dependencies | |
11 | + - security | |
12 | + commit-message: | |
13 | + prefix: deps | |
14 | + groups: | |
15 | + rust-deps: | |
16 | + patterns: | |
17 | + - "*" | |
18 | + | |
19 | + - package-ecosystem: github-actions | |
20 | + directory: "/" | |
21 | + schedule: | |
22 | + interval: weekly | |
23 | + day: monday | |
24 | + labels: | |
25 | + - ci | |
26 | + - security | |
0 | 27 | |
▼.github/workflows/bench.yml
+58-0
| @@ -0,0 +1,58 @@ | ||
1 | +name: Benchmark Regression Gate | |
2 | + | |
3 | +on: | |
4 | + pull_request: | |
5 | + branches: [main] | |
6 | + push: | |
7 | + branches: [main] | |
8 | + | |
9 | +jobs: | |
10 | + benchmark: | |
11 | + name: RPS Regression Check | |
12 | + runs-on: ubuntu-latest | |
13 | + steps: | |
14 | + - uses: actions/checkout@v4 | |
15 | + with: | |
16 | + fetch-depth: 0 | |
17 | + | |
18 | + - name: Install Rust | |
19 | + uses: dtolnay/rust-toolchain@stable | |
20 | + | |
21 | + - name: Cache cargo registry | |
22 | + uses: actions/cache@v4 | |
23 | + with: | |
24 | + path: | | |
25 | + ~/.cargo/registry | |
26 | + ~/.cargo/git | |
27 | + target | |
28 | + key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }} | |
29 | + | |
30 | + - name: Run Regression Check | |
31 | + run: | | |
32 | + # 1. Build and run on PR branch | |
33 | + cargo build --release -p justapi-bench | |
34 | + cargo run --release -p justapi-bench -- --duration 10 > pr_bench.txt | |
35 | + PR_RPS=$(grep -oP 'Requests per second:\s*\K[0-9]+' pr_bench.txt || echo "0") | |
36 | + | |
37 | + # 2. Checkout main branch and run | |
38 | + git checkout main | |
39 | + cargo build --release -p justapi-bench | |
40 | + cargo run --release -p justapi-bench -- --duration 10 > main_bench.txt | |
41 | + MAIN_RPS=$(grep -oP 'Requests per second:\s*\K[0-9]+' main_bench.txt || echo "0") | |
42 | + | |
43 | + echo "Main RPS: $MAIN_RPS" | |
44 | + echo "PR RPS: $PR_RPS" | |
45 | + | |
46 | + if [ "$MAIN_RPS" -eq 0 ]; then | |
47 | + echo "Failed to extract main RPS" | |
48 | + exit 1 | |
49 | + fi | |
50 | + | |
51 | + # 3. Compare (Fail if PR_RPS < 0.95 * MAIN_RPS) | |
52 | + THRESHOLD=$(echo "$MAIN_RPS * 0.95" | bc | cut -d. -f1) | |
53 | + if [ "$PR_RPS" -lt "$THRESHOLD" ]; then | |
54 | + echo "RPS dropped by >5%! Expected at least $THRESHOLD, got $PR_RPS" | |
55 | + exit 1 | |
56 | + else | |
57 | + echo "RPS is within acceptable bounds." | |
58 | + fi | |
0 | 59 | |
▼.github/workflows/ci.yml
+173-0
| @@ -0,0 +1,173 @@ | ||
1 | +name: CI | |
2 | + | |
3 | +on: | |
4 | + push: | |
5 | + branches: [main] | |
6 | + tags: ["v*"] | |
7 | + pull_request: | |
8 | + branches: [main] | |
9 | + | |
10 | +env: | |
11 | + CARGO_TERM_COLOR: always | |
12 | + RUSTFLAGS: "-D warnings" | |
13 | + | |
14 | +jobs: | |
15 | + check: | |
16 | + name: Build & Lint | |
17 | + runs-on: ubuntu-latest | |
18 | + steps: | |
19 | + - uses: actions/checkout@v4 | |
20 | + | |
21 | + - name: Install Rust toolchain | |
22 | + uses: dtolnay/rust-toolchain@stable | |
23 | + with: | |
24 | + components: rustfmt, clippy | |
25 | + | |
26 | + - name: Install Python (for PyO3) | |
27 | + uses: actions/setup-python@v5 | |
28 | + with: | |
29 | + python-version: "3.12" | |
30 | + | |
31 | + - name: Cache cargo registry | |
32 | + uses: actions/cache@v4 | |
33 | + with: | |
34 | + path: | | |
35 | + ~/.cargo/registry | |
36 | + ~/.cargo/git | |
37 | + target | |
38 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
39 | + restore-keys: | | |
40 | + ${{ runner.os }}-cargo- | |
41 | + | |
42 | + - name: Format check | |
43 | + run: cargo fmt --check | |
44 | + | |
45 | + - name: Clippy | |
46 | + run: cargo clippy --workspace -- -D warnings | |
47 | + | |
48 | + - name: Build | |
49 | + run: cargo build --workspace | |
50 | + | |
51 | + - name: Test | |
52 | + run: cargo test --workspace | |
53 | + | |
54 | + miri: | |
55 | + name: Miri (justapi-core) | |
56 | + runs-on: ubuntu-latest | |
57 | + steps: | |
58 | + - uses: actions/checkout@v4 | |
59 | + | |
60 | + - name: Install Rust nightly + Miri | |
61 | + uses: dtolnay/rust-toolchain@nightly | |
62 | + with: | |
63 | + components: miri | |
64 | + | |
65 | + - name: Cache cargo registry | |
66 | + uses: actions/cache@v4 | |
67 | + with: | |
68 | + path: | | |
69 | + ~/.cargo/registry | |
70 | + ~/.cargo/git | |
71 | + target | |
72 | + key: ${{ runner.os }}-miri-${{ hashFiles('**/Cargo.lock') }} | |
73 | + restore-keys: | | |
74 | + ${{ runner.os }}-miri- | |
75 | + | |
76 | + - name: Run Miri on justapi-core | |
77 | + run: cargo +nightly miri test -p justapi-core | |
78 | + env: | |
79 | + MIRIFLAGS: "-Zmiri-disable-isolation" | |
80 | + pytest: | |
81 | + name: Pytest (justapi-py) | |
82 | + runs-on: ubuntu-latest | |
83 | + steps: | |
84 | + - uses: actions/checkout@v4 | |
85 | + | |
86 | + - name: Install Python | |
87 | + uses: actions/setup-python@v5 | |
88 | + with: | |
89 | + python-version: "3.12" | |
90 | + | |
91 | + - name: Install dependencies | |
92 | + run: | | |
93 | + python -m pip install --upgrade pip | |
94 | + pip install pytest httpx pydantic typing_extensions uv maturin | |
95 | + | |
96 | + - name: Build and install justapi | |
97 | + run: | | |
98 | + maturin develop -m crates/justapi-py/Cargo.toml | |
99 | + | |
100 | + - name: Run pytest | |
101 | + run: | | |
102 | + PYTHONPATH=./crates/justapi-py/python pytest | |
103 | + | |
104 | + audit: | |
105 | + name: Security Audit (cargo-audit) | |
106 | + runs-on: ubuntu-latest | |
107 | + steps: | |
108 | + - uses: actions/checkout@v4 | |
109 | + | |
110 | + - name: Install cargo-audit | |
111 | + run: cargo install cargo-audit --locked | |
112 | + | |
113 | + - name: Cache cargo registry | |
114 | + uses: actions/cache@v4 | |
115 | + with: | |
116 | + path: | | |
117 | + ~/.cargo/registry | |
118 | + ~/.cargo/git | |
119 | + key: ${{ runner.os }}-audit-${{ hashFiles('**/Cargo.lock') }} | |
120 | + | |
121 | + - name: Run audit | |
122 | + run: cargo audit | |
123 | + | |
124 | + deny: | |
125 | + name: License & Dependency Check (cargo-deny) | |
126 | + runs-on: ubuntu-latest | |
127 | + steps: | |
128 | + - uses: actions/checkout@v4 | |
129 | + | |
130 | + - name: Install cargo-deny | |
131 | + uses: EmbarkStudios/cargo-deny-action@v2 | |
132 | + with: | |
133 | + command: check | |
134 | + arguments: --all-features | |
135 | + | |
136 | + docker: | |
137 | + name: Build & Push Docker Image | |
138 | + runs-on: ubuntu-latest | |
139 | + needs: [check] | |
140 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) | |
141 | + steps: | |
142 | + - uses: actions/checkout@v4 | |
143 | + | |
144 | + - name: Set up Docker Buildx | |
145 | + uses: docker/setup-buildx-action@v3 | |
146 | + | |
147 | + - name: Log in to GitHub Container Registry | |
148 | + uses: docker/login-action@v3 | |
149 | + with: | |
150 | + registry: ghcr.io | |
151 | + username: ${{ github.actor }} | |
152 | + password: ${{ secrets.GITHUB_TOKEN }} | |
153 | + | |
154 | + - name: Extract metadata (tags, labels) for Docker | |
155 | + id: meta | |
156 | + uses: docker/metadata-action@v5 | |
157 | + with: | |
158 | + images: ghcr.io/${{ github.repository }} | |
159 | + tags: | | |
160 | + type=ref,event=branch | |
161 | + type=semver,pattern={{version}} | |
162 | + type=semver,pattern={{major}}.{{minor}} | |
163 | + type=sha,format=long | |
164 | + | |
165 | + - name: Build and push Docker image | |
166 | + uses: docker/build-push-action@v5 | |
167 | + with: | |
168 | + context: . | |
169 | + push: true | |
170 | + tags: ${{ steps.meta.outputs.tags }} | |
171 | + labels: ${{ steps.meta.outputs.labels }} | |
172 | + cache-from: type=gha | |
173 | + cache-to: type=gha,mode=max | |
0 | 174 | |
▼.github/workflows/fuzz.yml
+22-0
| @@ -0,0 +1,22 @@ | ||
1 | +name: Fuzzing | |
2 | + | |
3 | +on: | |
4 | + schedule: | |
5 | + - cron: '0 2 * * *' # Run at 2 AM every day | |
6 | + workflow_dispatch: | |
7 | + | |
8 | +jobs: | |
9 | + fuzz: | |
10 | + name: cargo-fuzz | |
11 | + runs-on: ubuntu-latest | |
12 | + steps: | |
13 | + - uses: actions/checkout@v4 | |
14 | + | |
15 | + - name: Install Rust nightly | |
16 | + uses: dtolnay/rust-toolchain@nightly | |
17 | + | |
18 | + - name: Install cargo-fuzz | |
19 | + run: cargo install cargo-fuzz | |
20 | + | |
21 | + - name: Run HTTP Parser Fuzzer | |
22 | + run: cargo +nightly fuzz run fuzz_http_parser -- -max_total_time=300 | |
0 | 23 | |
▼.github/workflows/publish.yml
+45-0
| @@ -0,0 +1,45 @@ | ||
1 | +name: Publish to PyPI | |
2 | + | |
3 | +on: | |
4 | + release: | |
5 | + types: [published] | |
6 | + push: | |
7 | + tags: | |
8 | + - 'v*' | |
9 | + | |
10 | +jobs: | |
11 | + build-wheels: | |
12 | + runs-on: ubuntu-latest | |
13 | + steps: | |
14 | + - uses: actions/checkout@v4 | |
15 | + - name: Build wheels | |
16 | + uses: PyO3/maturin-action@v1 | |
17 | + with: | |
18 | + target: x86_64 | |
19 | + args: --release --out dist -m crates/justapi-py/Cargo.toml | |
20 | + - name: Upload wheels | |
21 | + uses: actions/upload-artifact@v4 | |
22 | + with: | |
23 | + name: wheels | |
24 | + path: dist | |
25 | + | |
26 | + publish: | |
27 | + name: Publish to PyPI | |
28 | + needs: [build-wheels] | |
29 | + runs-on: ubuntu-latest | |
30 | + environment: | |
31 | + name: pypi | |
32 | + url: https://pypi.org/p/justapi | |
33 | + permissions: | |
34 | + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
35 | + contents: read | |
36 | + steps: | |
37 | + - name: Download wheels | |
38 | + uses: actions/download-artifact@v4 | |
39 | + with: | |
40 | + name: wheels | |
41 | + path: dist | |
42 | + - name: Publish package to PyPI | |
43 | + uses: pypa/gh-action-pypi-publish@release/v1 | |
44 | + with: | |
45 | + packages-dir: dist | |
0 | 46 | |