Skip to content

Commit fd70af4

Browse files
committed
ci: enable E2E tests — requires merod >= 0.10.1-rc.14 with X-Auth-Error header
Made-with: Cursor
1 parent 8b7b909 commit fd70af4

1 file changed

Lines changed: 54 additions & 58 deletions

File tree

.github/workflows/ci.yml

Lines changed: 54 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -68,62 +68,58 @@ jobs:
6868
- run: pnpm install --frozen-lockfile
6969
- run: pnpm test
7070

71+
test-e2e:
72+
name: E2E Tests
73+
runs-on: ubuntu-latest
74+
needs: build
75+
timeout-minutes: 10
76+
steps:
77+
- uses: actions/checkout@v4
78+
- uses: pnpm/action-setup@v4
79+
- uses: actions/setup-node@v4
80+
with:
81+
node-version: ${{ env.NODE_VERSION }}
82+
cache: 'pnpm'
83+
- run: pnpm install --frozen-lockfile
84+
- run: pnpm build
85+
86+
- name: Start merod node
87+
env:
88+
GH_TOKEN: ${{ github.token }}
89+
run: |
90+
DOWNLOAD_URL=$(gh release view --repo calimero-network/core --json assets -q '.assets[] | select(.name | test("merod_x86_64.*linux.*tar.gz")) | .browser_download_url' 2>/dev/null)
91+
if [ -z "$DOWNLOAD_URL" ]; then
92+
DOWNLOAD_URL=$(gh release list --repo calimero-network/core --limit 1 --json tagName -q '.[0].tagName' | xargs -I{} gh release view {} --repo calimero-network/core --json assets -q '.assets[] | select(.name | test("merod_x86_64.*linux.*tar.gz")) | .browser_download_url')
93+
fi
94+
curl -sL "$DOWNLOAD_URL" | tar xz
95+
chmod +x ./merod
96+
97+
./merod --home ./e2e-node --node e2e init \
98+
--server-port 4001 --swarm-port 4002 --auth-mode embedded 2>&1 || true
99+
RUST_LOG=warn ./merod --home ./e2e-node --node e2e run &
100+
echo $! > merod.pid
101+
102+
for i in $(seq 1 30); do
103+
curl -sf http://localhost:4001/admin-api/health >/dev/null 2>&1 && break
104+
sleep 1
105+
done
106+
curl -sf http://localhost:4001/admin-api/health || exit 1
107+
108+
TOKEN=$(curl -sf http://localhost:4001/auth/token \
109+
-H "Content-Type: application/json" \
110+
-d "{\"auth_method\":\"user_password\",\"public_key\":\"dev\",\"client_name\":\"http://localhost:4001\",\"timestamp\":$(date +%s),\"provider_data\":{\"username\":\"dev\",\"password\":\"dev\"}}" \
111+
| python3 -c "import json,sys; print(json.load(sys.stdin)['data']['access_token'])")
112+
curl -sf http://localhost:4001/admin-api/install-dev-application \
113+
-H "Authorization: Bearer $TOKEN" \
114+
-H "Content-Type: application/json" \
115+
-d "{\"path\":\"$(pwd)/tests/e2e/assets/kv-store.mpk\",\"metadata\":[]}"
116+
echo "Node ready with test app"
117+
118+
- name: Run E2E tests
119+
run: npx vitest run --config vitest.e2e.config.ts tests/e2e/full-api.test.ts
120+
env:
121+
NODE_URL: http://localhost:4001
71122

72-
# E2E tests require a running merod node with the X-Auth-Error header fix.
73-
# Uncomment after the next core release.
74-
# test-e2e:
75-
# name: E2E Tests
76-
# runs-on: ubuntu-latest
77-
# needs: build
78-
# timeout-minutes: 10
79-
# steps:
80-
# - uses: actions/checkout@v4
81-
# - uses: pnpm/action-setup@v4
82-
# - uses: actions/setup-node@v4
83-
# with:
84-
# node-version: ${{ env.NODE_VERSION }}
85-
# cache: 'pnpm'
86-
# - run: pnpm install --frozen-lockfile
87-
# - run: pnpm build
88-
#
89-
# - name: Start merod node
90-
# run: |
91-
# # Get merod from Docker image
92-
# docker pull ghcr.io/calimero-network/merod:prerelease
93-
# docker create --name merod-bin ghcr.io/calimero-network/merod:prerelease
94-
# docker cp merod-bin:/usr/local/bin/merod ./merod
95-
# docker rm merod-bin
96-
# chmod +x ./merod
97-
#
98-
# # Init + start
99-
# ./merod --home ./e2e-node --node e2e init \
100-
# --server-port 4001 --swarm-port 4002 --auth-mode embedded 2>&1 || true
101-
# RUST_LOG=warn ./merod --home ./e2e-node --node e2e run &
102-
# echo $! > merod.pid
103-
#
104-
# # Wait for ready
105-
# for i in $(seq 1 30); do
106-
# curl -sf http://localhost:4001/admin-api/health >/dev/null 2>&1 && break
107-
# sleep 1
108-
# done
109-
# curl -sf http://localhost:4001/admin-api/health || exit 1
110-
#
111-
# # Install test app bundle (committed in tests/e2e/assets/)
112-
# TOKEN=$(curl -sf http://localhost:4001/auth/token \
113-
# -H "Content-Type: application/json" \
114-
# -d "{\"auth_method\":\"user_password\",\"public_key\":\"dev\",\"client_name\":\"http://localhost:4001\",\"timestamp\":$(date +%s),\"provider_data\":{\"username\":\"dev\",\"password\":\"dev\"}}" \
115-
# | python3 -c "import json,sys; print(json.load(sys.stdin)['data']['access_token'])")
116-
# curl -sf http://localhost:4001/admin-api/install-dev-application \
117-
# -H "Authorization: Bearer $TOKEN" \
118-
# -H "Content-Type: application/json" \
119-
# -d "{\"path\":\"$(pwd)/tests/e2e/assets/kv-store.mpk\",\"metadata\":[]}"
120-
# echo "Node ready with test app"
121-
#
122-
# - name: Run E2E tests
123-
# run: npx vitest run --config vitest.e2e.config.ts tests/e2e/full-api.test.ts
124-
# env:
125-
# NODE_URL: http://localhost:4001
126-
#
127-
# - name: Stop node
128-
# if: always()
129-
# run: kill $(cat merod.pid) 2>/dev/null || true
123+
- name: Stop node
124+
if: always()
125+
run: kill $(cat merod.pid) 2>/dev/null || true

0 commit comments

Comments
 (0)