counterfactual / monorepo

Home for all packages related to the Counterfactual project
https://counterfactual.com
MIT License
187 stars 44 forks source link

[testing] Implement a job for running E2E tests on CI #2076

Open joelalejandro opened 5 years ago

joelalejandro commented 5 years ago

1906 intended to include a CI configuration. However, Selenium is proving more difficult to implement than anticipated. To prevent further blocking that PR, we've decided to split off the CI configuration task as a separate PR. This issue reflects the latest state of the work.

These are the necessary jobs to prepare the greenboard environment for testing:


  greenboard-prepare:
    <<: *defaults
    docker:
      # TODO: Update Node version in this image to whatever MM uses.
      - image: circleci/node:8.15
    steps:
      - <<: *restore_code

      - checkout

      - <<: *restore_dep

      - attach_workspace:
          at: /home/circleci/project

      - run:
          name: Clone Metamask fork
          # TODO: Change the branch to whatever
          # we use as a source for downloading our MM fork
          command: git clone --depth 1 --single-branch --branch joel/for-wallet-ui git@github.com:prototypal/metamask-extension ./metamask
      - run:
          name: Update CF.js IIFE
          command: cp packages/cf.js/dist/index-iife.js metamask/app/vendor/counterfactual/node/cf.js.iife.js
      - run:
          name: Update Firebase Client IIFE
          command: cp packages/firebase-client/dist/index.iife.js metamask/app/vendor/counterfactual/node/firebase-client.iife.js
      - run:
          name: Update Node IIFE
          command: cp packages/node/dist/index.iife.js metamask/app/vendor/counterfactual/node/node.iife.js
      - run:
          name: Install dependencies
          command: cd metamask && npm ci
      - run:
          name: Build Metamask extension with CF IIFEs
          command: cd metamask && npx gulp build

      - persist_to_workspace:
          root: /home/circleci/project
          paths:
            - packages/*/dist
            - packages/*/build
            - metamask/dist/chrome

  greenboard-run:
    <<: *defaults
    docker:
      - image: circleci/node:10.15.3-jessie-browsers
    steps:
      - <<: *restore_code

      - checkout

      - <<: *restore_dep

      - attach_workspace:
          at: /home/circleci/project

      - run: sudo npm i -g yarn@1.12.3 # because docker image uses 1.13.0

      - run: yarn --frozen-lockfile # symlink packages' node_modules

      - run:
          name: Link Metamask dist into extension
          command: ln -s metamask/dist/chrome packages/greenboard/extension

      - run:
          name: Serve Wallet UI
          shell: /bin/sh
          command: cd packages/wallet-ui && yarn start
          background: true

      - run:
          name: Serve Simple Hub Server
          shell: /bin/sh
          command: cd packages/simple-hub-server && yarn start:e2e
          background: true

      - run:
          name: Run Greenboard (E2E tests)
          command: cd packages/greenboard && yarn test

Inside the jobs list for the run-tests workflow, we'd add:

      - greenboard-prepare:
          requires:
            - build

      - greenboard-run:
          requires:
            - build
            - greenboard-prepare

With this configuration, Selenium throws either chrome not reachable or DevToolsActivePort file doesn't exist. After extensive research and debugging, we still haven't figured out the missing piece in the configuration to make Selenium work with the Chrome driver in CircleCI.

joelalejandro commented 5 years ago

Will attempt to create a new Docker image specifically suited for what Greenboard needs.