Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: added ci flow for e2e tests #89

Merged
merged 3 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
64 changes: 64 additions & 0 deletions .github/workflows/e2e_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: E2E tests

on:
push:
branches: [main]
pull_request:
branches: [main]

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label ||
github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
e2e:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Run e2e tests
run: |
docker-compose -f tests/e2e/docker-compose.yml --profile synpress up --build --exit-code-from synpress
env:
COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_BUILDKIT: 1
DOCKER_DEFAULT_PLATFORM: linux/amd64
NGROK_AUTH: ${{ secrets.NGROK_AUTH }}
NGROK_BASIC_AUTH: ${{ secrets.NGROK_BASIC_AUTH }}
CYPRESS_PRIVATE_KEY_WITH_FUNDS: ${{ secrets.CYPRESS_PRIVATE_KEY_WITH_FUNDS }}
ANVIL_FORK_URL: ${{ secrets.ANVIL_FORK_URL }}
GH_PAT: ${{ secrets.GH_PAT }}
GH_USERNAME: ${{ secrets.GH_USERNAME }}
# cypress dashboard
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }}

- name: Archive e2e artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: e2e-artifacts
path: |
tests/e2e/docker/videos
tests/e2e/docker/screenshots
continue-on-error: true
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ dist-ssr

# E2E tests
screenshots
videos
videos
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# syntax=docker/dockerfile:1
FROM --platform=linux/amd64 synthetixio/docker-e2e:18.16-ubuntu as base

RUN mkdir /app
WORKDIR /app

RUN apt update && apt install -y nginx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there an upstream that has nginx installed? that would save some time in the job.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think there is one by synthetixio. we're using their images at the moment to avoid any problems with missing or conflicting dependencies.
We can look into either using another image for this or creating a custom image for our own requirements


COPY tests/e2e/nginx.conf /etc/nginx/sites-available/default

COPY . .

RUN yarn install --frozen-lockfile
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"postinstall": "patch-package",
"test": "vitest",
"coverage": "vitest run --coverage",
"test:e2e": "EXTENSION=keplr SKIP_EXTENSION_SETUP=true synpress run --configFile=tests/e2e/synpress.config.cjs"
"test:e2e": "EXTENSION=keplr SKIP_EXTENSION_SETUP=true synpress run --configFile=tests/e2e/synpress.config.cjs",
"test:e2e:ci": "start-server-and-test 'yarn dev' http-get://localhost:5173 'yarn test:e2e'"
},
"dependencies": {
"@agoric/rpc": "^0.0.2-dev-2c6fbc5.0",
Expand Down Expand Up @@ -71,6 +72,7 @@
"patch-package": "^6.5.0",
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.7.1",
"start-server-and-test": "^2.0.3",
"typescript": "^4.9.3",
"vite": "^3.2.7",
"vite-tsconfig-paths": "^3.5.1",
Expand Down
117 changes: 117 additions & 0 deletions tests/e2e/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
version: '3.9'

services:
synpress:
profiles:
- synpress
container_name: synpress
build: ../..
environment:
- DISPLAY=display:0.0
- CYPRESS_PRIVATE_KEY_WITH_FUNDS=${CYPRESS_PRIVATE_KEY_WITH_FUNDS}
- DEBUG=${DEBUG}
- CYPRESS_DOCKER_RUN=true
- GH_PAT=${GH_PAT}
- GH_USERNAME=${GH_USERNAME}
- CI=${CI}
# cypress dashboard
- CYPRESS_GROUP=${CYPRESS_GROUP}
- GITHUB_TOKEN=${GITHUB_TOKEN}
- CYPRESS_PROJECT_ID=${CYPRESS_PROJECT_ID}
- CYPRESS_RECORD_KEY=${CYPRESS_RECORD_KEY}
- COMMIT_INFO_MESSAGE=${COMMIT_INFO_MESSAGE}
- COMMIT_INFO_SHA=${COMMIT_INFO_SHA}
# passing required CI variables
- GITHUB_ACTIONS=${GITHUB_ACTIONS}
- GITHUB_WORKFLOW=${GITHUB_WORKFLOW}
- GITHUB_ACTION=${GITHUB_ACTION}
- GITHUB_EVENT_NAME=${GITHUB_EVENT_NAME}
- GITHUB_RUN_ID=${GITHUB_RUN_ID}
- GITHUB_RUN_ATTEMPT=${GITHUB_RUN_ATTEMPT}
- GITHUB_REPOSITORY=${GITHUB_REPOSITORY}
- GH_BRANCH=${GH_BRANCH}
- GITHUB_SHA=${GITHUB_SHA}
- GITHUB_REF=${GITHUB_REF}
- GITHUB_BASE_REF=${GITHUB_BASE_REF}
- GITHUB_HEAD_REF=${GITHUB_HEAD_REF}
- 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"
depends_on:
- display
- video
- agd
entrypoint: []
working_dir: /app
volumes:
- ./docker/videos:/app/tests/e2e/videos
- ./docker/screenshots:/app/tests/e2e/screenshots
command: >
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'
networks:
- x11

display:
profiles:
- synpress
container_name: display
image: synthetixio/display:016121eafdfff448414894d0ca5a50b1d72b62eb-base
environment:
- RUN_XTERM=no
- DISPLAY_WIDTH=1920
- DISPLAY_HEIGHT=1080
ports:
- '8080:8080'
networks:
- x11

ngrok:
profiles:
- ngrok
container_name: ngrok
image: synthetixio/ngrok:016121eafdfff448414894d0ca5a50b1d72b62eb-base
ports:
- '4040:4040'
command: ['ngrok', 'http', 'display:8080', '--authtoken', '${NGROK_AUTH}']
environment:
- NGROK_AUTH=${NGROK_AUTH}
- NGROK_BASIC_AUTH=${NGROK_BASIC_AUTH}
depends_on:
- display
networks:
- x11

video:
profiles:
- synpress
container_name: video
image: synthetixio/video:457bb48776c3b14de232d9dda620ba9188dc40ac-base
volumes:
- ./docker/videos:/videos
environment:
- FILE_NAME=CI-full-video.mp4
- SE_SCREEN_WIDTH=1920
- SE_SCREEN_HEIGHT=1080
depends_on:
- display
networks:
- x11

agd:
profiles:
- synpress
container_name: agoric_chain
image: ghcr.io/agoric/agoric-3-proposals:main
logging:
driver: none
platform: linux/amd64
ports:
- 26656:26656
- 26657:26657
- 1317:1317
environment:
DEST: 1
DEBUG: 'SwingSet:ls,SwingSet:vat'
networks:
- x11

networks:
x11:
39 changes: 39 additions & 0 deletions tests/e2e/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
server {
listen 26656;
server_name localhost;

location / {
proxy_pass http://agoric_chain:26656;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

server {
listen 26657;
server_name localhost;

location / {
proxy_pass http://agoric_chain:26657;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}


server {
listen 1317;
server_name localhost;

location / {
proxy_pass http://agoric_chain:1317;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
2 changes: 0 additions & 2 deletions tests/e2e/specs/proposal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ describe('Make Proposal Tests', () => {
});

it('should allow gov1 to create a proposal', () => {
cy.visit('/?agoricNet=local');

// open PSM and select USDT_axl
cy.get('button').contains('PSM').click();
cy.get('button').contains('AUSD').click();
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/synpress.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { defineConfig } = require('cypress');

module.exports = defineConfig({
...config,
trashAssetsBeforeRuns: false,
e2e: {
...config.e2e,
baseUrl: 'http://localhost:5173',
Expand Down
Loading
Loading