Skip to content

Commit 6bf06c9

Browse files
committed
Only build once during CI
1 parent 8439344 commit 6bf06c9

File tree

13 files changed

+458
-121
lines changed

13 files changed

+458
-121
lines changed

.github/workflows/benchmark.yml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
name: 📊 Benchmark
2+
23
on:
3-
push: {}
44
workflow_call: {}
5+
56
permissions:
67
contents: read
8+
79
jobs:
810
benchmark:
911
runs-on: ubuntu-latest
12+
timeout-minutes: 10
1013
services:
1114
mongodb:
1215
image: mongo:5
@@ -23,54 +26,68 @@ jobs:
2326
"POSTGRES_DB": "main_db"
2427
ports:
2528
- "27016:5432"
26-
timeout-minutes: 10
2729
strategy:
2830
fail-fast: false
2931
matrix:
3032
node-version: [20.x, 24.x]
33+
3134
steps:
32-
- uses: actions/checkout@v5
35+
- name: Checkout repository
36+
uses: actions/checkout@v6
37+
3338
- name: Use Node.js ${{ matrix.node-version }}
34-
uses: actions/setup-node@v5
39+
uses: actions/setup-node@v6
3540
with:
3641
node-version: ${{ matrix.node-version }}
3742
cache: "npm"
3843
cache-dependency-path: "**/package-lock.json"
44+
3945
- name: Setup Aikido safe-chain
4046
run: |
4147
npm i -g @aikidosec/safe-chain
4248
safe-chain setup-ci
49+
4350
- name: Downgrade npm for v24 and v25
4451
# https://github.com/npm/cli/issues/8669
4552
if: ${{ matrix.node-version == '24.x' || matrix.node-version == '25.x' }}
4653
run: npm i -g [email protected]
54+
4755
- name: Install K6
4856
uses: grafana/setup-k6-action@ffe7d7290dfa715e48c2ccc924d068444c94bde2 # v1
57+
4958
- name: Install wrk
5059
run: |
5160
sudo apt-get update
5261
sudo apt-get install -y wrk
53-
- name: Set up Rust
54-
run: |
55-
rustup toolchain install stable
56-
rustup default stable
57-
cargo install wasm-pack
58-
- run: npm install
59-
- run: npm run build
62+
63+
- name: Download build artifacts
64+
uses: actions/download-artifact@v5
65+
with:
66+
name: firewall-node-library-${{ github.sha }}
67+
68+
- name: Install dependencies for benchmarks
69+
run: npm run install-benchmarks-only
70+
6071
- name: Run NoSQL Injection Benchmark
6172
run: cd benchmarks/nosql-injection && AIKIDO_CI=true node benchmark.js
73+
6274
- name: Run SQL Injection Benchmark
6375
run: cd benchmarks/sql-injection && node benchmark.js
76+
6477
- name: Run shell injection Benchmark
6578
run: cd benchmarks/shell-injection && node benchmark.js
79+
6680
- name: Run Hono with Postgres Benchmark
6781
run: cd benchmarks/hono-pg && node benchmark.js
82+
6883
- name: Run API Discovery Benchmark
6984
run: cd benchmarks/api-discovery && node benchmark.js
85+
7086
- name: Run Express Benchmark
7187
# Skip on Node 24.x because benchmark currently fails.
7288
# Big performance improve in comparison to older Node.js versions, but higher difference between usage with and without Zen
7389
if: matrix.node-version != '24.x'
7490
run: cd benchmarks/express && node benchmark.js
91+
7592
- name: Check Rate Limiter memory usage
7693
run: cd benchmarks/rate-limiting && node --expose-gc memory.js

.github/workflows/build-and-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
id-token: write
2727
timeout-minutes: 15
2828
steps:
29-
- uses: actions/checkout@v5
30-
- uses: actions/setup-node@v5
29+
- uses: actions/checkout@v6
30+
- uses: actions/setup-node@v6
3131
with:
3232
node-version: "24.x"
3333
registry-url: "https://registry.npmjs.org"

.github/workflows/build.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: ⚙️ Build library
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
env:
10+
node_version: 24.x
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 15
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v6
19+
20+
- name: Use Node.js ${{ env.node_version }}
21+
22+
uses: actions/setup-node@v6
23+
with:
24+
node-version: ${{ env.node_version }}
25+
cache: "npm"
26+
cache-dependency-path: "**/package-lock.json"
27+
28+
- name: Setup Aikido safe-chain
29+
run: |
30+
npm i -g @aikidosec/safe-chain
31+
safe-chain setup-ci
32+
33+
- name: Downgrade npm for v24 and v25
34+
# https://github.com/npm/cli/issues/8669
35+
if: ${{ env.node_version == '24.x' || env.node_version == '25.x' }}
36+
run: npm i -g [email protected]
37+
38+
- name: Set up Rust
39+
run: |
40+
rustup toolchain install stable
41+
rustup default stable
42+
43+
- name: Install wasm-pack
44+
run: bash ./.github/workflows/utils/install-wasm-pack.sh
45+
46+
- name: Install dependencies (library only)
47+
run: npm run install-lib-only
48+
49+
- name: Build complete library
50+
run: npm run build
51+
52+
- name: Upload build artifacts
53+
uses: actions/upload-artifact@v5
54+
with:
55+
name: firewall-node-library-${{ github.sha }}
56+
if-no-files-found: error
57+
retention-days: 7
58+
path: |
59+
build/
60+
library/internals/
61+
library/agent/hooks/instrumentation/wasm/
Lines changed: 28 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,14 @@
11
name: 🕵️ End to end tests
2+
23
on:
3-
push: {}
44
workflow_call: {}
5+
56
permissions:
67
contents: read
8+
79
jobs:
810
test:
911
runs-on: ubuntu-latest
10-
services:
11-
mongodb:
12-
image: mongo:5
13-
env:
14-
"MONGO_INITDB_ROOT_USERNAME": "root"
15-
"MONGO_INITDB_ROOT_PASSWORD": "password"
16-
ports:
17-
- 27017:27017
18-
postgres:
19-
image: postgres:14-alpine
20-
env:
21-
"POSTGRES_PASSWORD": "password"
22-
"POSTGRES_USER": "root"
23-
"POSTGRES_DB": "main_db"
24-
ports:
25-
- "27016:5432"
26-
mysql:
27-
image: mysql:8.0
28-
# NOTE: use of "mysql_native_password" is not recommended: https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password
29-
# We need to use this long command in order to execute the last part : mysql_native_password
30-
# https://stackoverflow.com/questions/60902904/how-to-pass-mysql-native-password-to-mysql-service-in-github-actions
31-
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=mypassword -e MYSQL_DATABASE=catsdb --entrypoint sh mysql:8.0 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
32-
ports:
33-
- "27015:3306"
34-
mariadb:
35-
image: mariadb:11
36-
env:
37-
MARIADB_ROOT_PASSWORD: mypassword
38-
MARIADB_DATABASE: catsdb
39-
ports:
40-
- "27018:3306"
41-
clickhouse:
42-
image: clickhouse/clickhouse-server:24
43-
env:
44-
"CLICKHOUSE_USER": "clickhouse"
45-
"CLICKHOUSE_PASSWORD": "clickhouse"
46-
"CLICKHOUSE_DB": "main_db"
47-
"CLICKHOUSE_DEFAULT_ACCESS": "MANAGEMENT=1"
48-
ports:
49-
- "27019:8123"
5012
timeout-minutes: 15
5113
strategy:
5214
fail-fast: false
@@ -60,36 +22,47 @@ jobs:
6022
mode: "new"
6123
- node-version: 25.x
6224
mode: "new"
25+
6326
steps:
64-
- uses: actions/checkout@v5
27+
- name: Checkout repository
28+
uses: actions/checkout@v6
29+
6530
- name: Use Node.js ${{ matrix.node-version }}
66-
uses: actions/setup-node@v5
31+
uses: actions/setup-node@v6
6732
with:
6833
node-version: ${{ matrix.node-version }}
6934
cache: "npm"
7035
cache-dependency-path: "**/package-lock.json"
36+
7137
- name: Setup Aikido safe-chain
7238
run: |
7339
npm i -g @aikidosec/safe-chain
7440
safe-chain setup-ci
41+
7542
- name: Downgrade npm for v24 and v25
7643
# https://github.com/npm/cli/issues/8669
7744
if: ${{ matrix.node-version == '24.x' || matrix.node-version == '25.x' }}
7845
run: npm i -g [email protected]
46+
7947
- name: Add local.aikido.io to /etc/hosts
8048
run: |
8149
sudo echo "127.0.0.1 local.aikido.io" | sudo tee -a /etc/hosts
82-
- name: Build and run server
83-
run: |
84-
cd end2end/server && docker build -t server . && docker run -d -p 5874:3000 server
85-
- name: Set up Rust
86-
run: |
87-
rustup toolchain install stable
88-
rustup default stable
89-
cargo install wasm-pack
90-
- run: npm install
91-
- run: npm run build
92-
- if: matrix.mode == 'old'
50+
51+
- name: Run Containers
52+
run: npm run containers
53+
54+
- name: Install dependencies (end-to-end only)
55+
run: npm run install-e2e-only
56+
57+
- name: Download build artifacts
58+
uses: actions/download-artifact@v5
59+
with:
60+
name: firewall-node-library-${{ github.sha }}
61+
62+
- name: Run end-to-end tests
63+
if: matrix.mode == 'old'
9364
run: npm run end2end
94-
- if: matrix.mode == 'new'
65+
66+
- name: Run new end-to-end tests
67+
if: matrix.mode == 'new'
9568
run: npm run end2end:new

.github/workflows/lint-code.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
name: 🧹 Lint code
2-
on: push
2+
3+
on:
4+
workflow_call: {}
5+
36
permissions:
47
contents: read
8+
59
jobs:
610
lint:
711
runs-on: ubuntu-latest
@@ -10,34 +14,48 @@ jobs:
1014
matrix:
1115
node-version: [24.x]
1216
steps:
13-
- uses: actions/checkout@v5
17+
- name: Checkout repository
18+
uses: actions/checkout@v6
19+
1420
- name: Use Node.js ${{ matrix.node-version }}
15-
uses: actions/setup-node@v5
21+
uses: actions/setup-node@v6
1622
with:
1723
node-version: ${{ matrix.node-version }}
1824
cache: "npm"
1925
cache-dependency-path: "**/package-lock.json"
26+
2027
- name: Set up Rust
2128
run: |
2229
rustup toolchain install stable
2330
rustup default stable
2431
rustup component add rustfmt clippy
25-
cargo install wasm-pack
32+
2633
- name: Setup Aikido safe-chain
2734
run: |
2835
npm i -g @aikidosec/safe-chain
2936
safe-chain setup-ci
37+
3038
- name: Downgrade npm for v24 and v25
3139
# https://github.com/npm/cli/issues/8669
3240
if: ${{ matrix.node-version == '24.x' || matrix.node-version == '25.x' }}
3341
run: npm i -g [email protected]
34-
- run: npm run install-lib-only
35-
- run: npm run build
42+
43+
- name: Install dependencies (library only)
44+
run: npm run install-lib-only
45+
46+
- name: Download build artifacts
47+
uses: actions/download-artifact@v5
48+
with:
49+
name: firewall-node-library-${{ github.sha }}
50+
3651
- name: Run Linter for JavaScript/TypeScript
3752
run: npm run lint
53+
3854
- name: Check formatting
3955
run: npm run format:check
56+
4057
- name: Check Rust formatting
4158
run: cd instrumentation-wasm && cargo fmt --check
59+
4260
- name: Run Rust Linter
4361
run: cd instrumentation-wasm && cargo clippy

.github/workflows/main.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Main Workflow
2+
3+
on:
4+
push: {}
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
build:
11+
name: ⚙️ Build library
12+
uses: ./.github/workflows/build.yml
13+
lint-code:
14+
name: 🧹 Lint code
15+
uses: ./.github/workflows/lint-code.yml
16+
needs: build
17+
unit-tests:
18+
name: 🧪 Unit tests
19+
uses: ./.github/workflows/unit-test.yml
20+
needs: build
21+
end-to-end-tests:
22+
name: 🕵️ End to end tests
23+
uses: ./.github/workflows/end-to-end-tests.yml
24+
needs: build
25+
benchmark:
26+
name: 📊 Benchmark
27+
uses: ./.github/workflows/benchmark.yml
28+
needs: build
29+
qa-tests:
30+
name: 🧪 QA Tests
31+
uses: ./.github/workflows/qa-tests.yml
32+
needs: build

0 commit comments

Comments
 (0)