Skip to content

Commit 5f238d6

Browse files
chore: use a local image of unleash enterprise for testing FE (#9509)
This removes the need of running a heroku instance with enterprise to run frontend tests. We can also get rid of vercel deployments of the frontend for PRs (ofc we'd be loosing the preview if we do this) It relies on the free enterprise docker image to spin up a clean Unleash instance on each frontend spec test. It also seems to speed up tests, I guess because we don't have to wait for vercel deployment queue: ![image](https://github.com/user-attachments/assets/60a2aef1-9a5a-442d-b241-8c5c145c679e) Compared with other recent PRs: ![image](https://github.com/user-attachments/assets/9a7498aa-26e6-48a4-aba0-c67e5380ced4) Unrelated to this PR but something is making the features spec tests very slow since Cypress upgrade: https://github.com/Unleash/unleash/actions/runs/13784760762/job/38550079932#step:4:138
1 parent 4ffd3e7 commit 5f238d6

File tree

2 files changed

+66
-3
lines changed

2 files changed

+66
-3
lines changed

.github/docker-compose.test.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# This docker compose setup configures:
2+
# - the Unleash enterprise server instance + the necessary backing Postgres database
3+
#
4+
# To learn more about all the parts of Unleash, visit
5+
# https://docs.getunleash.io
6+
#
7+
# NOTE: please do not use this configuration for production setups.
8+
# Unleash does not take responsibility for any data leaks or other
9+
# problems that may arise as a result.
10+
#
11+
# This is intended to be used for demo, development, and learning
12+
# purposes only.
13+
14+
services:
15+
# The Unleash server contains the Unleash configuration and
16+
# communicates with server-side SDKs and the Unleash Proxy
17+
unleash:
18+
image: 726824350591.dkr.ecr.eu-central-1.amazonaws.com/unleash-enterprise:latest
19+
pull_policy: "always"
20+
ports:
21+
- "4242:4242"
22+
environment:
23+
DATABASE_URL: "postgres://postgres:unleash@db/unleash"
24+
DATABASE_SSL: "false"
25+
UNLEASH_LICENSE: "${FRONTEND_TEST_LICENSE}"
26+
depends_on:
27+
db:
28+
condition: service_healthy
29+
healthcheck:
30+
test: wget --no-verbose --tries=1 --spider http://localhost:4242/health || exit 1
31+
interval: 1s
32+
timeout: 1m
33+
retries: 5
34+
start_period: 15s
35+
db:
36+
expose:
37+
- "5432"
38+
image: postgres:16
39+
environment:
40+
POSTGRES_DB: "unleash"
41+
# trust incoming connections blindly (DON'T DO THIS IN PRODUCTION!)
42+
POSTGRES_HOST_AUTH_METHOD: "trust"
43+
healthcheck:
44+
test:
45+
[
46+
"CMD",
47+
"pg_isready",
48+
"--username=postgres",
49+
"--host=127.0.0.1",
50+
"--port=5432",
51+
]
52+
interval: 2s
53+
timeout: 1m
54+
retries: 5
55+
start_period: 10s

.github/workflows/e2e.frontend.yaml

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name: e2e:frontend
2-
on: [deployment_status]
2+
on:
3+
pull_request:
4+
# paths:
5+
# - 'frontend/**'
36
jobs:
47
e2e:
5-
if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success' && contains(github.event.deployment_status.target_url, 'unleash-monorepo-frontend')
68
runs-on: ubuntu-latest
79
strategy:
810
matrix:
@@ -19,11 +21,17 @@ jobs:
1921
echo "$GITHUB_CONTEXT"
2022
- name: Checkout
2123
uses: actions/checkout@v4
24+
- name: Start Unleash test instance
25+
run: |
26+
curl https://app.unleash-hosted.com/docker-login/token/${{ secrets.ECR_ENTERPRISE_TOKEN }} | docker login --username AWS --password-stdin 726824350591.dkr.ecr.eu-central-1.amazonaws.com
27+
docker compose -f .github/docker-compose.test.yml up -d --wait -t 90
28+
env:
29+
FRONTEND_TEST_LICENSE: ${{ secrets.FRONTEND_TEST_LICENSE }}
2230
- name: Run Cypress
2331
uses: cypress-io/github-action@v6
2432
with:
2533
working-directory: frontend
2634
env: AUTH_USER=admin,AUTH_PASSWORD=unleash4all
27-
config: baseUrl=${{ github.event.deployment_status.target_url }}
35+
config: baseUrl=http://localhost:4242
2836
spec: cypress/integration/${{ matrix.test }}
2937
install-command: yarn --immutable

0 commit comments

Comments
 (0)