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

Add No Docker Mode #109

Merged
merged 26 commits into from
Nov 27, 2023
Merged

Add No Docker Mode #109

merged 26 commits into from
Nov 27, 2023

Conversation

jasonagnew
Copy link
Member

@jasonagnew jasonagnew commented Jul 29, 2022

Add No Docker Mode

Description

Running Docker on a CI can be tricky, there is often limitations due to security. Most notable CircleCI doesn't support volumes unless you use a VM which is very slow. As most CIs allow you to load docker image there should be option to start WP Cypress without docker as CI image should have everything needed to run WordPress & Cypress.

Change Log

  • Adds no docker mode

Types of changes (if applicable):

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

How to use.

The feature can be tested/used easily on CircleCI. There is Big Bite docker image that can be used as example of what you need. Replacing << parameters.host >> with cypress domain for example project.client.co and replacing << parameters.port >> with port being used (defaults to 80)

version: 2.1

jobs:
  main:
    docker:
      - image: 'bigbite/ci-orb-project:php-7.4'
      - image: 'cimg/mysql:8.0'
    steps:
      - checkout
      - run: |
          echo 'export NVM_DIR=$HOME/.nvm' >> $BASH_ENV
          echo 'source $NVM_DIR/nvm.sh' >> $BASH_ENV
      - run: npm ci
      - run: |
          echo 127.0.0.1 << parameters.host >> | tee -a /etc/hosts
          sed -i 's/80/<< parameters.port >>/' /etc/apache2/ports.conf
          sed -i 's/80/<< parameters.port >>/' /etc/apache2/sites-enabled/000-default.conf
          service apache2 start
          echo 'export WP_CYPRESS_WORKING_DIR="/var/www"' >> $BASH_ENV
          echo 'export WP_CYPRESS_NO_DOCKER_MODE="true"' >> $BASH_ENV
          echo 'export WP_CYPRESS_DB_HOST="127.0.0.1"' >> $BASH_ENV
          echo 'export WP_CYPRESS_DB_NAME="circle_test"' >> $BASH_ENV
          echo 'export WP_CYPRESS_DB_USER="root"' >> $BASH_ENV
          echo 'export WP_CYPRESS_DB_PASS=""' >> $BASH_ENV
      - run: npx wp-cypress start
      - run: npx cypress run

workflows:
  workflow:
    jobs:
      - build:
          filters:
            branches:
              ignore: /^.*-built$/

You can also use the bigbite orb which makes it even easier to use:

version: 2.1

orbs:
  project: bigbite/project@0.0.39

jobs:
  build:
    executor:
      name: project/default
      php: '7.4'
    steps:
      - checkout
      - project/setup
      - project/npm-install:
          path: "./"
      - project/wp-cypress-start:
          path: "./"
          host: "project.client.co"
          port: 3333
      - project/cypress-run:
          path: "./"

workflows:
  workflow:
    jobs:
      - build:
          filters:
            branches:
              ignore: /^.*-built$/

@g-elwell
Copy link
Member

This works great for both myself and @chrishbite on separate repos with a variety of tests. Good to merge!

We should ensure this feature is covered in docs at some point, ref #76

@g-elwell g-elwell merged commit c725628 into release/1.0.0 Nov 27, 2023
@g-elwell g-elwell mentioned this pull request Nov 27, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants