From 05439390cc45109224afa9d59af87341133222c0 Mon Sep 17 00:00:00 2001 From: Leonardo de Jesus Diz Conde Date: Mon, 18 Sep 2023 16:40:39 -0300 Subject: [PATCH] CU-86a0jg60u - Setup CI/CD on WcSdk repository to check the build and the e2e tests on the pullrequest --- .circleci/config.yml | 86 ------------------- .github/workflows/check-build-and-test.yml | 51 +++++++++++ .gitignore | 7 ++ examples/wc-dapp-react/playwright.config.ts | 4 +- .../wc-dapp-vite-vanilla/playwright.config.js | 5 +- .../tests/walletConnect.spec.js | 2 +- examples/wc-wallet-react/playwright.config.ts | 3 +- 7 files changed, 66 insertions(+), 92 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/check-build-and-test.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 885052c..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,86 +0,0 @@ -version: 2.1 - -defaults: &defaults - working_directory: ~/project - docker: - - image: circleci/node:14.18.0 - -jobs: - test: - <<: *defaults - steps: - - checkout - - - restore_cache: - key: dependency-cache-{{ checksum "common/config/rush/npm-shrinkwrap.json" }} - - - run: - name: install rush - command: sudo npm install -g @microsoft/rush - - - run: - name: rush update - command: rush update - - - save_cache: - key: dependency-cache-{{ checksum "common/config/rush/npm-shrinkwrap.json" }} - paths: - - ./common/temp - - - run: - name: Verify Change - command: rush change --verify - - - run: - name: rebuild - command: rush rebuild - - - run: - name: Publish Dry-Run - command: rush publish --include-all - - - persist_to_workspace: - root: ~/project - paths: . - - deploy: - <<: *defaults - steps: - - attach_workspace: - at: ~/project - - - run: - name: install rush - command: | - sudo npm install -g @microsoft/rush - rush update - rush rebuild - - - run: - name: Authenticate - command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/project/common/config/rush/.npmrc-publish - - - run: - name: Publish package - command: rush publish --include-all --publish - - -workflows: - version: 2 - build_test_deploy: - jobs: - - test: - filters: - tags: - only: /.*/ - - deploy: - context: npm_prod - requires: - - test - filters: - tags: - only: - - /^v.*/ - branches: - ignore: - - /.*/ \ No newline at end of file diff --git a/.github/workflows/check-build-and-test.yml b/.github/workflows/check-build-and-test.yml new file mode 100644 index 0000000..86985f3 --- /dev/null +++ b/.github/workflows/check-build-and-test.yml @@ -0,0 +1,51 @@ +name: Check Build and Test +on: + pull_request: + branches: + - main + +env: + NODE_VERSION: 16.x + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 2 + - name: Setup Node Version ${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + - name: Install PNPM + run: npm install -g pnpm + - name: Install RushJS + run: npm install -g @microsoft/rush + - name: Install Yarn + run: npm install --global yarn + - name: Verify Change Logs + run: rush change --verify + - name: Install Dependencies + run: rush update + - name: Build Projects + run: rush rebuild --verbose + - name: Install Examples Dependencies + working-directory: ./examples + run: | + for dir in */; do + if [ -d "$dir" ]; then + (cd "$dir" && yarn install && yarn build && yarn playwright install) + fi + done + - name: Run E2E Tests + working-directory: ./examples + run: | + yarn global add serve + for dir in */; do + if [ -d "$dir" ]; then + (cd "$dir" && yarn test:e2e:headless) + fi + done + diff --git a/.gitignore b/.gitignore index 870ff22..611bc46 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,10 @@ common/autoinstallers/*/.npmrc # jetbrains .idea + +# Examples build +examples/*/build/ +examples/*/dist/ + +# Examples test result +examples/*/test-results/ diff --git a/examples/wc-dapp-react/playwright.config.ts b/examples/wc-dapp-react/playwright.config.ts index 9e69b80..741a17c 100644 --- a/examples/wc-dapp-react/playwright.config.ts +++ b/examples/wc-dapp-react/playwright.config.ts @@ -1,12 +1,14 @@ import type { PlaywrightTestConfig } from '@playwright/test' const config: PlaywrightTestConfig = { + fullyParallel: true, testMatch: '**/*.ts', webServer: { - command: 'yarn start', + command: 'npx serve -s build', port: 3000, }, testDir: 'tests', + timeout: 4000 } export default config diff --git a/examples/wc-dapp-vite-vanilla/playwright.config.js b/examples/wc-dapp-vite-vanilla/playwright.config.js index 5e5bb78..b8b7184 100644 --- a/examples/wc-dapp-vite-vanilla/playwright.config.js +++ b/examples/wc-dapp-vite-vanilla/playwright.config.js @@ -1,9 +1,8 @@ - - const config = { + fullyParallel: true, testMatch: '**/*.js', webServer: { - command: 'yarn run build && yarn run preview', + command: 'yarn preview', port: 4173, }, testDir: 'tests', diff --git a/examples/wc-dapp-vite-vanilla/tests/walletConnect.spec.js b/examples/wc-dapp-vite-vanilla/tests/walletConnect.spec.js index f61f43d..ea596fa 100644 --- a/examples/wc-dapp-vite-vanilla/tests/walletConnect.spec.js +++ b/examples/wc-dapp-vite-vanilla/tests/walletConnect.spec.js @@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test' test('Dapp connect to wallet', async ({context, page}) => { await page.goto('/') // Go home page - await page.waitForTimeout(500) // Await home to load + await page.waitForTimeout(750) // Await home to load const [newPage] = await Promise.all([ context.waitForEvent('page'), page.getByTestId('app__wallet-connect').click() // Click to connect diff --git a/examples/wc-wallet-react/playwright.config.ts b/examples/wc-wallet-react/playwright.config.ts index 9e69b80..80617c8 100644 --- a/examples/wc-wallet-react/playwright.config.ts +++ b/examples/wc-wallet-react/playwright.config.ts @@ -1,9 +1,10 @@ import type { PlaywrightTestConfig } from '@playwright/test' const config: PlaywrightTestConfig = { + fullyParallel: true, testMatch: '**/*.ts', webServer: { - command: 'yarn start', + command: 'npx serve -s build', port: 3000, }, testDir: 'tests',