Skip to content

Commit fdc0ebb

Browse files
test: CI/CD workflow for e2e tests (#126)
* test: docker set up for e2e tests * test: added github workflow for e2e tests * fix: added secret_words to synpress container * refactor: moved docker-compose and nginx.conf * fixup! test: added github workflow for e2e tests chore: renamed e2e_docker to e2e_tests * fixup! test: added github workflow for e2e tests refactor: using version tags instead of shas * fixup! test: added github workflow for e2e tests refactor: used simpler tag versions * fixup! test: added github workflow for e2e tests refactor: simplified condition * fixup! refactor: moved docker-compose and nginx.conf fix: fix path for artifacts --------- Co-authored-by: Samuel Siegart <[email protected]>
1 parent 4234ef7 commit fdc0ebb

File tree

8 files changed

+330
-21
lines changed

8 files changed

+330
-21
lines changed

Diff for: .dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
docker

Diff for: .github/workflows/e2e_tests.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: E2E tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label ||
11+
github.head_ref || github.ref }}'
12+
cancel-in-progress: true
13+
14+
jobs:
15+
e2e:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v3
21+
22+
- name: Set up QEMU
23+
uses: docker/setup-qemu-action@v2
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v2
27+
28+
- name: Cache Docker layers
29+
uses: actions/cache@v3
30+
with:
31+
path: /tmp/.buildx-cache
32+
key: ${{ runner.os }}-buildx-${{ github.sha }}
33+
restore-keys: |
34+
${{ runner.os }}-buildx-
35+
36+
- name: Run e2e tests
37+
run: |
38+
docker-compose -f tests/e2e/docker-compose.yml --profile synpress up --build --exit-code-from synpress
39+
env:
40+
COMPOSE_DOCKER_CLI_BUILD: 1
41+
DOCKER_BUILDKIT: 1
42+
DOCKER_DEFAULT_PLATFORM: linux/amd64
43+
NGROK_AUTH: ${{ secrets.NGROK_AUTH }}
44+
NGROK_BASIC_AUTH: ${{ secrets.NGROK_BASIC_AUTH }}
45+
CYPRESS_PRIVATE_KEY_WITH_FUNDS: ${{ secrets.CYPRESS_PRIVATE_KEY_WITH_FUNDS }}
46+
ANVIL_FORK_URL: ${{ secrets.ANVIL_FORK_URL }}
47+
GH_PAT: ${{ secrets.GH_PAT }}
48+
GH_USERNAME: ${{ secrets.GH_USERNAME }}
49+
# cypress dashboard
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
52+
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
53+
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
54+
COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }}
55+
56+
- name: Archive e2e artifacts
57+
uses: actions/upload-artifact@v3
58+
if: always()
59+
with:
60+
name: e2e-artifacts
61+
path: |
62+
tests/e2e/docker/videos
63+
tests/e2e/docker/videos-ci
64+
tests/e2e/docker/screenshots
65+
continue-on-error: true

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ dist-ssr
2626

2727
# E2E tests
2828
tests/e2e/screenshots
29-
tests/e2e/videos
29+
tests/e2e/videos
30+
docker

Diff for: Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# syntax=docker/dockerfile:1
2+
FROM --platform=linux/amd64 synthetixio/docker-e2e:18.16-ubuntu as base
3+
4+
RUN mkdir /app
5+
WORKDIR /app
6+
7+
RUN apt update && apt install -y nginx
8+
9+
COPY tests/e2e/nginx.conf /etc/nginx/sites-available/default
10+
11+
COPY . .
12+
13+
RUN yarn install --frozen-lockfile

Diff for: package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"format": "prettier --write . && yarn lint --fix",
1212
"test": "vitest",
1313
"coverage": "vitest run --coverage",
14-
"test:e2e": "EXTENSION=keplr synpress run --configFile=tests/e2e/synpress.config.cjs"
14+
"test:e2e": "EXTENSION=keplr synpress run --configFile=tests/e2e/synpress.config.cjs",
15+
"test:e2e:ci": "start-server-and-test 'yarn dev' http-get://localhost:5173 'yarn test:e2e'"
1516
},
1617
"dependencies": {
1718
"react": "^18.2.0",
@@ -53,6 +54,7 @@
5354
"react-icons": "^4.4.0",
5455
"react-loader-spinner": "~5.4.5",
5556
"react-toastify": "^9.0.8",
57+
"start-server-and-test": "^2.0.3",
5658
"tailwindcss": "^3.1.8",
5759
"typescript": "^4.6.4",
5860
"vite": "^3.2.7",

Diff for: tests/e2e/docker-compose.yml

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
version: '3.9'
2+
3+
services:
4+
synpress:
5+
profiles:
6+
- synpress
7+
container_name: synpress
8+
build: ../..
9+
environment:
10+
- DISPLAY=display:0.0
11+
- CYPRESS_PRIVATE_KEY_WITH_FUNDS=${CYPRESS_PRIVATE_KEY_WITH_FUNDS}
12+
- DEBUG=${DEBUG}
13+
- CYPRESS_DOCKER_RUN=true
14+
- GH_PAT=${GH_PAT}
15+
- GH_USERNAME=${GH_USERNAME}
16+
- CI=${CI}
17+
# cypress dashboard
18+
- CYPRESS_GROUP=${CYPRESS_GROUP}
19+
- GITHUB_TOKEN=${GITHUB_TOKEN}
20+
- CYPRESS_PROJECT_ID=${CYPRESS_PROJECT_ID}
21+
- CYPRESS_RECORD_KEY=${CYPRESS_RECORD_KEY}
22+
- COMMIT_INFO_MESSAGE=${COMMIT_INFO_MESSAGE}
23+
- COMMIT_INFO_SHA=${COMMIT_INFO_SHA}
24+
# passing required CI variables
25+
- GITHUB_ACTIONS=${GITHUB_ACTIONS}
26+
- GITHUB_WORKFLOW=${GITHUB_WORKFLOW}
27+
- GITHUB_ACTION=${GITHUB_ACTION}
28+
- GITHUB_EVENT_NAME=${GITHUB_EVENT_NAME}
29+
- GITHUB_RUN_ID=${GITHUB_RUN_ID}
30+
- GITHUB_RUN_ATTEMPT=${GITHUB_RUN_ATTEMPT}
31+
- GITHUB_REPOSITORY=${GITHUB_REPOSITORY}
32+
- GH_BRANCH=${GH_BRANCH}
33+
- GITHUB_SHA=${GITHUB_SHA}
34+
- GITHUB_REF=${GITHUB_REF}
35+
- GITHUB_BASE_REF=${GITHUB_BASE_REF}
36+
- GITHUB_HEAD_REF=${GITHUB_HEAD_REF}
37+
- SECRET_WORDS="orbit bench unit task food shock brand bracket domain regular warfare company announce wheel grape trust sphere boy doctor half guard ritual three ecology"
38+
depends_on:
39+
- display
40+
- video
41+
- agd
42+
entrypoint: []
43+
working_dir: /app
44+
volumes:
45+
- ./docker/videos:/app/tests/e2e/videos
46+
- ./docker/screenshots:/app/tests/e2e/screenshots
47+
command: >
48+
bash -c 'echo -n "======> local noVNC URL: http://localhost:8080/vnc.html?autoconnect=true " && pnpm wait-on http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && nginx && yarn test:e2e:ci'
49+
networks:
50+
- x11
51+
52+
display:
53+
profiles:
54+
- synpress
55+
container_name: display
56+
image: synthetixio/display:016121eafdfff448414894d0ca5a50b1d72b62eb-base
57+
environment:
58+
- RUN_XTERM=no
59+
- DISPLAY_WIDTH=1920
60+
- DISPLAY_HEIGHT=1080
61+
ports:
62+
- '8080:8080'
63+
networks:
64+
- x11
65+
66+
ngrok:
67+
profiles:
68+
- ngrok
69+
container_name: ngrok
70+
image: synthetixio/ngrok:016121eafdfff448414894d0ca5a50b1d72b62eb-base
71+
ports:
72+
- '4040:4040'
73+
command: ['ngrok', 'http', 'display:8080', '--authtoken', '${NGROK_AUTH}']
74+
environment:
75+
- NGROK_AUTH=${NGROK_AUTH}
76+
- NGROK_BASIC_AUTH=${NGROK_BASIC_AUTH}
77+
depends_on:
78+
- display
79+
networks:
80+
- x11
81+
82+
video:
83+
profiles:
84+
- synpress
85+
container_name: video
86+
image: synthetixio/video:457bb48776c3b14de232d9dda620ba9188dc40ac-base
87+
volumes:
88+
- ./docker/videos-ci:/videos
89+
environment:
90+
- FILE_NAME=CI-full-video.mp4
91+
- SE_SCREEN_WIDTH=1920
92+
- SE_SCREEN_HEIGHT=1080
93+
depends_on:
94+
- display
95+
networks:
96+
- x11
97+
98+
agd:
99+
profiles:
100+
- synpress
101+
container_name: agoric_chain
102+
image: ghcr.io/agoric/agoric-3-proposals:main
103+
logging:
104+
driver: none
105+
platform: linux/amd64
106+
ports:
107+
- 26656:26656
108+
- 26657:26657
109+
- 1317:1317
110+
environment:
111+
DEST: 1
112+
DEBUG: 'SwingSet:ls,SwingSet:vat'
113+
networks:
114+
- x11
115+
116+
networks:
117+
x11:

Diff for: tests/e2e/nginx.conf

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
server {
2+
listen 26656;
3+
server_name localhost;
4+
5+
location / {
6+
proxy_pass http://agoric_chain:26656;
7+
proxy_set_header Host $host;
8+
proxy_set_header X-Real-IP $remote_addr;
9+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
10+
proxy_set_header X-Forwarded-Proto $scheme;
11+
}
12+
}
13+
14+
server {
15+
listen 26657;
16+
server_name localhost;
17+
18+
location / {
19+
proxy_pass http://agoric_chain:26657;
20+
proxy_set_header Host $host;
21+
proxy_set_header X-Real-IP $remote_addr;
22+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
23+
proxy_set_header X-Forwarded-Proto $scheme;
24+
}
25+
}
26+
27+
28+
server {
29+
listen 1317;
30+
server_name localhost;
31+
32+
location / {
33+
proxy_pass http://agoric_chain:1317;
34+
proxy_set_header Host $host;
35+
proxy_set_header X-Real-IP $remote_addr;
36+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
37+
proxy_set_header X-Forwarded-Proto $scheme;
38+
}
39+
}

0 commit comments

Comments
 (0)