DEV Community

Tomas Norre Mikkelsen
Tomas Norre Mikkelsen

Posted on

1

Codeception tests in Travis CI with DDEV and Selenium

Recently I posted about how to run codeception with DDEV.
https://dev.to/tomasnorre/codeception-ddev-selenium-docker-36kk

This is of course really nice, but having it as part of the CI pipeline is even better.

So I decided to try to make it run within Travis CI which is my preferred public CI at the moment.

What to do?

  1. Signup with travis-ci and registre your repository
  2. Add a .travis.yml to your github repository
  3. Make changes and push, and wait for the results of the tests.

You can see the step in the Travis CI Tutorial

The advantages here is that you will have your behaviour driven tests executed on every commit and pull request, to make sure you or others don't break functionality.

Configuring Travis CI

The .travis.yml is the configuration file for Travis CI. I contains different step and instructions to enable travis to do what you want.

This can be used to run PHPUnit, Checking Coding Standard, Codeception tests and so on, only your imagination is the limit.

This is how the .travis.yml looks like for my https://github.com/tomasnorre/ddev-codeception-poc

language: php
dist: bionic

notifications:
  email:
    on_success: never
    on_failure: never

before_install:
  # turn off XDebug for speed up
  - phpenv config-rm xdebug.ini || return 0

php:
  - '7.4'

services:
  - docker

cache:
  directories:
    - $HOME/.composer/cache

before_script:
  - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
  - sudo apt update
  - sudo apt install docker-ce
  - sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  - sudo chmod +x /usr/local/bin/docker-compose
  - docker-compose --version
  - wget https://github.com/drud/ddev/releases/download/v1.13.1/ddev_linux.v1.13.1.tar.gz
  - tar vxzf ddev_linux.v1.13.1.tar.gz
  - sudo chmod +x ddev
  - sudo chmod +x mkcert
  - ./mkcert -install

jobs:
  fast_finish: true
  include:
    -
      stage: Tests
      name: "Code ception"
      script:
        - composer install
        - ./ddev --version
        - ./ddev start
        - php vendor/bin/codecept run
Enter fullscreen mode Exit fullscreen mode

I had to install a never version of docker, manually to meet the requirements from ddev.

The result

Codeception in Travis CI output console

Have fun.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (1)

Collapse
 
tyler36 profile image
tyler36

Curious, do you have a "current" version?

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more