From f81406fb496efd9ada6d995b72940c22e61927b9 Mon Sep 17 00:00:00 2001 From: Isidro Date: Tue, 28 Nov 2023 21:30:48 -0600 Subject: [PATCH 1/2] ci: Add Github actions --- .circleci/config.yml | 81 ------------------------------- .github/workflows/action.yml | 45 +++++++++++++++++ packages/app/package.json | 1 + packages/app/tests/e2e-ui.test.ts | 2 + test-app-e2e.sh | 4 ++ 5 files changed, 52 insertions(+), 81 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/action.yml create mode 100644 test-app-e2e.sh diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index ec210a9..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,81 +0,0 @@ -version: 2.1 -orbs: - node: circleci/node@5.1.0 - rust: circleci/rust@1.6.0 -jobs: - run_twitter_circuit_tests: - docker: - - image: saleel/circom:2.1.6 - steps: - - checkout: - path: ~/proof-of-twitter - - node/install-packages: - pkg-manager: yarn - app-dir: ~/proof-of-twitter - - run: - command: yarn test - name: Run circom tests - working_directory: ~/proof-of-twitter/packages/circuits - - run_forge_tests: - docker: - - image: ghcr.io/foundry-rs/foundry:latest - steps: - - checkout: - path: ~/proof-of-twitter - - run: - command: | - apk add nodejs npm && npm install --global yarn - - node/install-packages: - pkg-manager: yarn - app-dir: ~/proof-of-twitter - - run: - name: run foundry tests - working_directory: ~/proof-of-twitter/packages/contracts - command: forge test --fork-url https://eth-goerli.g.alchemy.com/v2/${ALCHEMY_API_KEY} - - run_unit_and_e2e_tests: - docker: - - image: cimg/node:16.19-browsers - steps: - - checkout: - path: ~/proof-of-twitter - - run: node --version - - node/install-packages: - pkg-manager: yarn - app-dir: ~/proof-of-twitter - - run: yarn --version - - run: - command: yarn test - name: Run unit tests - working_directory: ~/proof-of-twitter/packages/app - environment: - JEST_JUNIT_OUTPUT: reports/unit-test-results.xml - - run: - command: CI=false yarn run build - name: Build app - working_directory: ~/proof-of-twitter/packages/app - - run: - command: yarn run start-e2e-test-server - name: Start test server - working_directory: ~/proof-of-twitter/packages/app - background: true - - run: - command: yarn test:e2e-ui - name: Run e2e tests for UI - working_directory: ~/proof-of-twitter/packages/app - environment: - JEST_JUNIT_OUTPUT: reports/e2e-ui-test-results.xml - # - run: - # command: yarn test:e2e-zkp - # name: Run e2e tests for zkp - # environment: - # JEST_JUNIT_OUTPUT: reports/e2e-zkp-test-results.xml - - store_test_results: - path: reports/ -workflows: - build_test: - jobs: - # - run_twitter_circuit_tests - - run_unit_and_e2e_tests - - run_forge_tests \ No newline at end of file diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml new file mode 100644 index 0000000..3c7ba1c --- /dev/null +++ b/.github/workflows/action.yml @@ -0,0 +1,45 @@ +on: [push] +jobs: + run_twitter_circuit_tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set Node.js 16.x + uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + - name: Install Yarn dependencies + working-directory: ./packages/circuits + run: yarn install --immutable + - name: Run Tests + run: forge test --root ./packages/contracts --fork-url https://eth-goerli.g.alchemy.com/v2/${{vars.ALCHEMY_API_KEY}} + + run_unit_and_e2e_tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set Node.js 16.x + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'yarn' + env: + PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 'true' + - name: Install Yarn dependencies + working-directory: ./packages/app + run: yarn install + - name: Run test + working-directory: ./packages/app + run: yarn test + - name: Run build + working-directory: ./packages/app + run: yarn build + - name: Test Code + uses: mujo-code/puppeteer-headful@16.6.0 + env: + CI: "true" + with: + args: yarn workspace @zk-email/twitter-verifier test:full-e2e + \ No newline at end of file diff --git a/packages/app/package.json b/packages/app/package.json index c7e5b2c..936abe6 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -34,6 +34,7 @@ "test": "jest --runInBand --testPathIgnorePatterns='e2e' --reporters=default --reporters=jest-junit", "start-e2e-test-server": "serve -s dist -p 3000", "test:e2e-ui": "CI=true jest ./tests/e2e-ui*.test.*", + "test:full-e2e": "bash scripts/full-e2e.sh", "test:e2e-zkp": "CI=true jest ./tests/e2e-dl-zkp.test.ts" }, "eslintConfig": { diff --git a/packages/app/tests/e2e-ui.test.ts b/packages/app/tests/e2e-ui.test.ts index efd6d2f..3f83fda 100644 --- a/packages/app/tests/e2e-ui.test.ts +++ b/packages/app/tests/e2e-ui.test.ts @@ -60,6 +60,8 @@ describe("App.js", () => { browser = await puppeteer.launch({ // headless: true, headless: false, + args: ['--no-sandbox'], + executablePath: process.env.PUPPETEER_EXEC_PATH, slowMo: 100 }); page = await browser.newPage(); diff --git a/test-app-e2e.sh b/test-app-e2e.sh new file mode 100644 index 0000000..3945e11 --- /dev/null +++ b/test-app-e2e.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Execute E2E test +cd packages/app && (yarn start-e2e-test-server & yarn test:e2e-ui) \ No newline at end of file From 4142aa0de0b75bcd87f23638e8cccc050916757a Mon Sep 17 00:00:00 2001 From: Isidro Date: Tue, 28 Nov 2023 21:30:48 -0600 Subject: [PATCH 2/2] ci: Add Github actions --- .circleci/config.yml | 81 ------------------------------- .github/workflows/action.yml | 45 +++++++++++++++++ packages/app/package.json | 1 + packages/app/tests/e2e-ui.test.ts | 2 + test-app-e2e.sh | 4 ++ 5 files changed, 52 insertions(+), 81 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/action.yml create mode 100644 test-app-e2e.sh diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index ec210a9..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,81 +0,0 @@ -version: 2.1 -orbs: - node: circleci/node@5.1.0 - rust: circleci/rust@1.6.0 -jobs: - run_twitter_circuit_tests: - docker: - - image: saleel/circom:2.1.6 - steps: - - checkout: - path: ~/proof-of-twitter - - node/install-packages: - pkg-manager: yarn - app-dir: ~/proof-of-twitter - - run: - command: yarn test - name: Run circom tests - working_directory: ~/proof-of-twitter/packages/circuits - - run_forge_tests: - docker: - - image: ghcr.io/foundry-rs/foundry:latest - steps: - - checkout: - path: ~/proof-of-twitter - - run: - command: | - apk add nodejs npm && npm install --global yarn - - node/install-packages: - pkg-manager: yarn - app-dir: ~/proof-of-twitter - - run: - name: run foundry tests - working_directory: ~/proof-of-twitter/packages/contracts - command: forge test --fork-url https://eth-goerli.g.alchemy.com/v2/${ALCHEMY_API_KEY} - - run_unit_and_e2e_tests: - docker: - - image: cimg/node:16.19-browsers - steps: - - checkout: - path: ~/proof-of-twitter - - run: node --version - - node/install-packages: - pkg-manager: yarn - app-dir: ~/proof-of-twitter - - run: yarn --version - - run: - command: yarn test - name: Run unit tests - working_directory: ~/proof-of-twitter/packages/app - environment: - JEST_JUNIT_OUTPUT: reports/unit-test-results.xml - - run: - command: CI=false yarn run build - name: Build app - working_directory: ~/proof-of-twitter/packages/app - - run: - command: yarn run start-e2e-test-server - name: Start test server - working_directory: ~/proof-of-twitter/packages/app - background: true - - run: - command: yarn test:e2e-ui - name: Run e2e tests for UI - working_directory: ~/proof-of-twitter/packages/app - environment: - JEST_JUNIT_OUTPUT: reports/e2e-ui-test-results.xml - # - run: - # command: yarn test:e2e-zkp - # name: Run e2e tests for zkp - # environment: - # JEST_JUNIT_OUTPUT: reports/e2e-zkp-test-results.xml - - store_test_results: - path: reports/ -workflows: - build_test: - jobs: - # - run_twitter_circuit_tests - - run_unit_and_e2e_tests - - run_forge_tests \ No newline at end of file diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml new file mode 100644 index 0000000..3c7ba1c --- /dev/null +++ b/.github/workflows/action.yml @@ -0,0 +1,45 @@ +on: [push] +jobs: + run_twitter_circuit_tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set Node.js 16.x + uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + - name: Install Yarn dependencies + working-directory: ./packages/circuits + run: yarn install --immutable + - name: Run Tests + run: forge test --root ./packages/contracts --fork-url https://eth-goerli.g.alchemy.com/v2/${{vars.ALCHEMY_API_KEY}} + + run_unit_and_e2e_tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set Node.js 16.x + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'yarn' + env: + PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 'true' + - name: Install Yarn dependencies + working-directory: ./packages/app + run: yarn install + - name: Run test + working-directory: ./packages/app + run: yarn test + - name: Run build + working-directory: ./packages/app + run: yarn build + - name: Test Code + uses: mujo-code/puppeteer-headful@16.6.0 + env: + CI: "true" + with: + args: yarn workspace @zk-email/twitter-verifier test:full-e2e + \ No newline at end of file diff --git a/packages/app/package.json b/packages/app/package.json index 3168b7f..43efeb1 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -33,6 +33,7 @@ "test": "jest --runInBand --testPathIgnorePatterns='e2e' --reporters=default --reporters=jest-junit", "start-e2e-test-server": "serve -s dist -p 3000", "test:e2e-ui": "CI=true jest ./tests/e2e-ui*.test.*", + "test:full-e2e": "bash scripts/full-e2e.sh", "test:e2e-zkp": "CI=true jest ./tests/e2e-dl-zkp.test.ts" }, "eslintConfig": { diff --git a/packages/app/tests/e2e-ui.test.ts b/packages/app/tests/e2e-ui.test.ts index efd6d2f..3f83fda 100644 --- a/packages/app/tests/e2e-ui.test.ts +++ b/packages/app/tests/e2e-ui.test.ts @@ -60,6 +60,8 @@ describe("App.js", () => { browser = await puppeteer.launch({ // headless: true, headless: false, + args: ['--no-sandbox'], + executablePath: process.env.PUPPETEER_EXEC_PATH, slowMo: 100 }); page = await browser.newPage(); diff --git a/test-app-e2e.sh b/test-app-e2e.sh new file mode 100644 index 0000000..3945e11 --- /dev/null +++ b/test-app-e2e.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Execute E2E test +cd packages/app && (yarn start-e2e-test-server & yarn test:e2e-ui) \ No newline at end of file