From 7d92996f5d25673100ad2bedc95c4ea8e5443fb8 Mon Sep 17 00:00:00 2001 From: frazarshad Date: Wed, 6 Mar 2024 03:58:36 -0800 Subject: [PATCH] Updates to CI/CD flow (#20) * ci: new docker ci file for keplr * ci: using docker workflow instead of debug workflow temporarily * ci: updated config to have not retires in ci --- .../workflows/{ => disabled}/e2e_debug.yml | 5 +- .../workflows/{disabled => }/e2e_docker.yml | 4 +- docker-compose.ci.keplr.yml | 126 ++++++++++++++++++ package.json | 3 +- synpress.config.js | 7 +- 5 files changed, 137 insertions(+), 8 deletions(-) rename .github/workflows/{ => disabled}/e2e_debug.yml (98%) rename .github/workflows/{disabled => }/e2e_docker.yml (91%) create mode 100644 docker-compose.ci.keplr.yml diff --git a/.github/workflows/e2e_debug.yml b/.github/workflows/disabled/e2e_debug.yml similarity index 98% rename from .github/workflows/e2e_debug.yml rename to .github/workflows/disabled/e2e_debug.yml index 5d0ac623b..f74ad984b 100644 --- a/.github/workflows/e2e_debug.yml +++ b/.github/workflows/disabled/e2e_debug.yml @@ -1,6 +1,9 @@ name: E2E (debug) -on: [push, pull_request] +on: + push: + pull_request: + branches: [master, dev] concurrency: group: diff --git a/.github/workflows/disabled/e2e_docker.yml b/.github/workflows/e2e_docker.yml similarity index 91% rename from .github/workflows/disabled/e2e_docker.yml rename to .github/workflows/e2e_docker.yml index b40b583d0..38fd44336 100644 --- a/.github/workflows/disabled/e2e_docker.yml +++ b/.github/workflows/e2e_docker.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - resolution: ['low', 'medium', 'high'] + resolution: ['high'] steps: - name: Checkout @@ -41,7 +41,7 @@ jobs: - name: Run e2e tests (${{ matrix.resolution }} res) run: | - docker-compose -f docker-compose.ci.yml --env-file ${{ matrix.resolution }}-res.env --profile synpress --profile foundry up --build --exit-code-from synpress + docker-compose -f docker-compose.ci.keplr.yml --env-file ${{ matrix.resolution }}-res.env --profile synpress up --build --exit-code-from synpress env: COMPOSE_DOCKER_CLI_BUILD: 1 DOCKER_BUILDKIT: 1 diff --git a/docker-compose.ci.keplr.yml b/docker-compose.ci.keplr.yml new file mode 100644 index 000000000..7e2dfa29a --- /dev/null +++ b/docker-compose.ci.keplr.yml @@ -0,0 +1,126 @@ +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} + 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 && pnpm test:e2e:ci:keplr' + networks: + - x11 + + display: + profiles: + - synpress + container_name: display + image: synthetixio/display:016121eafdfff448414894d0ca5a50b1d72b62eb-base + environment: + - RUN_XTERM=no + - DISPLAY_WIDTH=${DISPLAY_WIDTH} + - DISPLAY_HEIGHT=${DISPLAY_HEIGHT} + 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-ci:/videos + environment: + - FILE_NAME=CI-full-video.mp4 + - SE_SCREEN_WIDTH=${SE_SCREEN_WIDTH} + - SE_SCREEN_HEIGHT=${SE_SCREEN_HEIGHT} + depends_on: + - display + networks: + - x11 + + agd: + profiles: + - synpress + container_name: agoric_chain + image: frazarshad/offerup-test-chain:1.0.0 + logging: + driver: none + platform: linux/amd64 + ports: + - 26656:26656 + - 26657:26657 + - 1317:1317 + environment: + DEST: 1 + DEBUG: "SwingSet:ls,SwingSet:vat" + volumes: + - ./tools/contract:/workspace + entrypoint: /workspace/scripts/run-chain.sh + networks: + - x11 + +networks: + x11: diff --git a/package.json b/package.json index 886a46ea2..c47e1fca1 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,8 @@ "test:e2e:anvil": "start-server-and-test 'turbo start:server' http-get://localhost:3000 'CYPRESS_USE_ANVIL=true pnpm synpress:run'", "test:e2e:headless": "start-server-and-test 'turbo start:server' http-get://localhost:3000 'pnpm synpress:run --headless'", "test:e2e:headless:anvil": "start-server-and-test 'turbo start:server' http-get://localhost:3000 'CYPRESS_USE_ANVIL=true pnpm synpress:run --headless'", - "test:e2e:ci": "start-server-and-test 'VITE_LOCAL_ENV=agoric_chain pnpm start:ui' http-get://localhost:3000 'pnpm start:json-server' http-get://localhost:3004 'pnpm synpress:run --record --group'", + "test:e2e:ci": "start-server-and-test 'VITE_RUN_ENV=agoric_chain pnpm start:ui' http-get://localhost:3000 'pnpm start:json-server' http-get://localhost:3004 'pnpm synpress:run --record --group'", + "test:e2e:ci:keplr": "start-server-and-test 'VITE_RUN_ENV=agoric_chain pnpm start:ui' http-get://localhost:3000 'pnpm start:json-server' http-get://localhost:3004 'pnpm synpress:run:keplr'", "test:e2e:ci:anvil": "start-server-and-test 'turbo start:server' http-get://localhost:3000 'CYPRESS_USE_ANVIL=true pnpm synpress:run --record --group'", "test:e2e:ci:cypress-action": "CYPRESS_USE_ANVIL=true pnpm synpress:run", "synpress:run:keplr": "EXTENSION=keplr SKIP_EXTENSION_SETUP=true SYNPRESS_LOCAL_TEST=true node synpress.js run --configFile=synpress.config.js", diff --git a/synpress.config.js b/synpress.config.js index a28755ea3..361b563ec 100644 --- a/synpress.config.js +++ b/synpress.config.js @@ -11,16 +11,15 @@ const fixturesFolder = `${synpressPath}/fixtures`; log(`Detected synpress fixtures path is: ${fixturesFolder}`); const supportFile = 'tests/e2e/support.js'; - const specPattern = { metamask: 'tests/e2e/specs/metamask/**/*.{js,jsx,ts,tsx}', - keplr : 'tests/e2e/specs/keplr/**/*.{js,jsx,ts,tsx}' -} + keplr: 'tests/e2e/specs/keplr/**/*.{js,jsx,ts,tsx}', +}; module.exports = defineConfig({ userAgent: 'synpress', retries: { - runMode: process.env.CI ? 1 : 0, + runMode: 0, openMode: 0, }, fixturesFolder,