Skip to content

Commit d7c223d

Browse files
authored
feat: playwright test speed improvement (#5388)
1 parent df49172 commit d7c223d

File tree

1 file changed

+137
-77
lines changed

1 file changed

+137
-77
lines changed

.github/workflows/pr-playwright-tests.yml

Lines changed: 137 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -6,112 +6,172 @@ concurrency:
66
on: push
77

88
env:
9+
# AWS ECR Configuration
10+
AWS_REGION: ${{ secrets.AWS_REGION || 'us-west-2' }}
11+
ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }}
12+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_ECR }}
13+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_ECR }}
14+
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
15+
16+
# Test Environment Variables
917
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
1018
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
1119
GEN_AI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
1220
MOCK_LLM_RESPONSE: true
1321

1422
jobs:
15-
playwright-tests:
16-
name: Playwright Tests
17-
18-
# See https://runs-on.com/runners/linux/
19-
runs-on:
20-
[
21-
runs-on,
22-
runner=32cpu-linux-x64,
23-
disk=large,
24-
"run-id=${{ github.run_id }}",
25-
]
23+
build-web-image:
24+
runs-on: blacksmith-8vcpu-ubuntu-2404-arm
2625
steps:
2726
- name: Checkout code
2827
uses: actions/checkout@v4
28+
29+
- name: Configure AWS credentials
30+
uses: aws-actions/configure-aws-credentials@v4
2931
with:
30-
fetch-depth: 0
32+
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
33+
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
34+
aws-region: ${{ env.AWS_REGION }}
3135

32-
- name: Set up Python
33-
uses: actions/setup-python@v5
36+
- name: Login to Amazon ECR
37+
id: login-ecr
38+
uses: aws-actions/amazon-ecr-login@v2
39+
40+
- name: Set up Docker Buildx
41+
uses: useblacksmith/setup-docker-builder@v1
42+
43+
- name: Build and push Web Docker image
44+
uses: useblacksmith/build-push-action@v2
3445
with:
35-
python-version: "3.11"
36-
cache: "pip"
37-
cache-dependency-path: |
38-
backend/requirements/default.txt
39-
backend/requirements/dev.txt
40-
backend/requirements/model_server.txt
41-
- run: |
42-
python -m pip install --upgrade pip
43-
pip install --retries 5 --timeout 30 -r backend/requirements/default.txt
44-
pip install --retries 5 --timeout 30 -r backend/requirements/dev.txt
45-
pip install --retries 5 --timeout 30 -r backend/requirements/model_server.txt
46+
context: ./web
47+
file: ./web/Dockerfile
48+
platforms: linux/arm64
49+
tags: ${{ env.ECR_REGISTRY }}/integration-test-onyx-web-server:playwright-test-${{ github.run_id }}
50+
provenance: false
51+
sbom: false
52+
push: true
53+
54+
build-backend-image:
55+
runs-on: blacksmith-8vcpu-ubuntu-2404-arm
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v4
4659

47-
- name: Setup node
48-
uses: actions/setup-node@v4
60+
- name: Configure AWS credentials
61+
uses: aws-actions/configure-aws-credentials@v4
4962
with:
50-
node-version: 22
63+
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
64+
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
65+
aws-region: ${{ env.AWS_REGION }}
5166

52-
- name: Install node dependencies
53-
working-directory: ./web
54-
run: npm ci
67+
- name: Login to Amazon ECR
68+
id: login-ecr
69+
uses: aws-actions/amazon-ecr-login@v2
5570

56-
- name: Install playwright browsers
57-
working-directory: ./web
58-
run: npx playwright install --with-deps
71+
- name: Set up Docker Buildx
72+
uses: useblacksmith/setup-docker-builder@v1
73+
74+
- name: Build and push Backend Docker image
75+
uses: useblacksmith/build-push-action@v2
76+
with:
77+
context: ./backend
78+
file: ./backend/Dockerfile
79+
platforms: linux/arm64
80+
tags: ${{ env.ECR_REGISTRY }}/integration-test-onyx-backend:playwright-test-${{ github.run_id }}
81+
provenance: false
82+
sbom: false
83+
push: true
84+
85+
build-model-server-image:
86+
runs-on: blacksmith-8vcpu-ubuntu-2404-arm
87+
steps:
88+
- name: Checkout code
89+
uses: actions/checkout@v4
90+
91+
- name: Configure AWS credentials
92+
uses: aws-actions/configure-aws-credentials@v4
93+
with:
94+
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
95+
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
96+
aws-region: ${{ env.AWS_REGION }}
97+
98+
- name: Login to Amazon ECR
99+
id: login-ecr
100+
uses: aws-actions/amazon-ecr-login@v2
59101

60102
- name: Set up Docker Buildx
61-
uses: docker/setup-buildx-action@v3
103+
uses: useblacksmith/setup-docker-builder@v1
104+
105+
- name: Build and push Model Server Docker image
106+
uses: useblacksmith/build-push-action@v2
107+
with:
108+
context: ./backend
109+
file: ./backend/Dockerfile.model_server
110+
platforms: linux/arm64
111+
tags: ${{ env.ECR_REGISTRY }}/integration-test-onyx-model-server:playwright-test-${{ github.run_id }}
112+
provenance: false
113+
sbom: false
114+
push: true
62115

116+
playwright-tests:
117+
needs: [build-web-image, build-backend-image, build-model-server-image]
118+
name: Playwright Tests
119+
runs-on: blacksmith-8vcpu-ubuntu-2404-arm
120+
steps:
121+
- name: Checkout code
122+
uses: actions/checkout@v4
123+
with:
124+
fetch-depth: 0
125+
126+
- name: Configure AWS credentials
127+
uses: aws-actions/configure-aws-credentials@v4
128+
with:
129+
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
130+
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
131+
aws-region: ${{ env.AWS_REGION }}
132+
133+
- name: Login to Amazon ECR
134+
id: login-ecr
135+
uses: aws-actions/amazon-ecr-login@v2
136+
137+
# needed for pulling Vespa, Redis, Postgres, and Minio images
138+
# otherwise, we hit the "Unauthenticated users" limit
139+
# https://docs.docker.com/docker-hub/usage/
63140
- name: Login to Docker Hub
64141
uses: docker/login-action@v3
65142
with:
66143
username: ${{ secrets.DOCKER_USERNAME }}
67144
password: ${{ secrets.DOCKER_TOKEN }}
68145

69-
# tag every docker image with "test" so that we can spin up the correct set
70-
# of images during testing
146+
- name: Pull Docker images
147+
run: |
148+
# Pull all images from ECR in parallel
149+
echo "Pulling Docker images in parallel..."
150+
(docker pull ${{ env.ECR_REGISTRY }}/integration-test-onyx-web-server:playwright-test-${{ github.run_id }}) &
151+
(docker pull ${{ env.ECR_REGISTRY }}/integration-test-onyx-backend:playwright-test-${{ github.run_id }}) &
152+
(docker pull ${{ env.ECR_REGISTRY }}/integration-test-onyx-model-server:playwright-test-${{ github.run_id }}) &
71153
72-
# we use the runs-on cache for docker builds
73-
# in conjunction with runs-on runners, it has better speed and unlimited caching
74-
# https://runs-on.com/caching/s3-cache-for-github-actions/
75-
# https://runs-on.com/caching/docker/
76-
# https://github.com/moby/buildkit#s3-cache-experimental
154+
# Wait for all background jobs to complete
155+
wait
156+
echo "All Docker images pulled successfully"
77157
78-
# images are built and run locally for testing purposes. Not pushed.
158+
# Re-tag with expected names for docker-compose
159+
docker tag ${{ env.ECR_REGISTRY }}/integration-test-onyx-web-server:playwright-test-${{ github.run_id }} onyxdotapp/onyx-web-server:test
160+
docker tag ${{ env.ECR_REGISTRY }}/integration-test-onyx-backend:playwright-test-${{ github.run_id }} onyxdotapp/onyx-backend:test
161+
docker tag ${{ env.ECR_REGISTRY }}/integration-test-onyx-model-server:playwright-test-${{ github.run_id }} onyxdotapp/onyx-model-server:test
79162
80-
- name: Build Web Docker image
81-
uses: ./.github/actions/custom-build-and-push
82-
with:
83-
context: ./web
84-
file: ./web/Dockerfile
85-
platforms: linux/amd64
86-
tags: onyxdotapp/onyx-web-server:test
87-
push: false
88-
load: true
89-
cache-from: type=s3,prefix=cache/${{ github.repository }}/integration-tests/web-server/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }}
90-
cache-to: type=s3,prefix=cache/${{ github.repository }}/integration-tests/web-server/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }},mode=max
91-
92-
- name: Build Backend Docker image
93-
uses: ./.github/actions/custom-build-and-push
94-
with:
95-
context: ./backend
96-
file: ./backend/Dockerfile
97-
platforms: linux/amd64
98-
tags: onyxdotapp/onyx-backend:test
99-
push: false
100-
load: true
101-
cache-from: type=s3,prefix=cache/${{ github.repository }}/integration-tests/backend/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }}
102-
cache-to: type=s3,prefix=cache/${{ github.repository }}/integration-tests/backend/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }},mode=max
103-
104-
- name: Build Model Server Docker image
105-
uses: ./.github/actions/custom-build-and-push
163+
- name: Setup node
164+
uses: actions/setup-node@v4
106165
with:
107-
context: ./backend
108-
file: ./backend/Dockerfile.model_server
109-
platforms: linux/amd64
110-
tags: onyxdotapp/onyx-model-server:test
111-
push: false
112-
load: true
113-
cache-from: type=s3,prefix=cache/${{ github.repository }}/integration-tests/model-server/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }}
114-
cache-to: type=s3,prefix=cache/${{ github.repository }}/integration-tests/model-server/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }},mode=max
166+
node-version: 22
167+
168+
- name: Install node dependencies
169+
working-directory: ./web
170+
run: npm ci
171+
172+
- name: Install playwright browsers
173+
working-directory: ./web
174+
run: npx playwright install --with-deps
115175

116176
- name: Start Docker containers
117177
run: |

0 commit comments

Comments
 (0)