CI / CD w/ Codeception

23
CI / CD with Codeception Tudor Barbu @motanelu || @CodeVoyagers #phpbc n

Transcript of CI / CD w/ Codeception

Page 1: CI / CD w/ Codeception

CI / CD with Codeception

Tudor Barbu@motanelu || @CodeVoyagers

#phpbcn

Page 2: CI / CD w/ Codeception

Development Quality Assurance Delivery

Code freeze*

Estimated time

* this how you know you’re old

Page 3: CI / CD w/ Codeception

Development Quality Assurance

More development QA again Nervous

breakdownLast minute

fixes Delivery

Estimated time Estimated time

Code freeze The “real” code freeze 3rd time’s a charm

Almost doneMeanwhile

in reality

Page 4: CI / CD w/ Codeception
Page 5: CI / CD w/ Codeception

Software as a Product

Software as a Service

Page 6: CI / CD w/ Codeception

Development Delivery Observation Decide on

next features

Rinse and repeat

1 – 4 weeks iterations

Page 7: CI / CD w/ Codeception
Page 8: CI / CD w/ Codeception

You’re not really agile!

it takes 1 more week to release you have parallel sprints new iterations break existing functionality you have “bug fixing” sprints or other such practices…

However if

Page 9: CI / CD w/ Codeception

Development INT tests Merge to master

Deploy to stg/pre

Deploy to prod

Continuous Integration

Continuous Delivery

Continuous Deployment

Page 10: CI / CD w/ Codeception
Page 12: CI / CD w/ Codeception

When tested individually, units of code are not guaranteed to work together

Page 13: CI / CD w/ Codeception

Functional & Acceptance testing

www.codeception.com

Page 14: CI / CD w/ Codeception

Functional tests*

run without a web server bootstrap the framework with the required $_* variables may yield false results when the framework’s

specifications are not followed to the letter

* in this context

Page 15: CI / CD w/ Codeception

Acceptance testing

emulate RL (server & browser) PhpBrowser – cURL & crawl Selenium Webdriver PhantomJS

Page 16: CI / CD w/ Codeception

$ composer global require codeception/codeception$ export PATH="$PATH:$HOME/.composer/vendor/bin”$ cd /path/to/project$ codecept bootstrap$ codecept run

Installation

*should* work!

Page 18: CI / CD w/ Codeception

$ codecept generate:cept acceptance FirstPage$ vim tests/acceptance/FirstPageCept.php$ codecept run

<?php $I = new AcceptanceTester($scenario); $I->wantTo('See what the fuss is about'); $I->amOnPage('/'); $I->see('Hello there', 'h1'); $I->see('Click here', 'a'); $I->click('Click here'); $I->amOnPage('/login'); $I->see('Log in here'); $I->fillField('name','Tudor'); $I->fillField('password','1234'); $I->click('Submit'); $I->see('Welcome');

Page 19: CI / CD w/ Codeception

$ php vendor/bin/doctrine orm:schema-tool:create --dump-sql > tests/_data/dump.sql

Test me like one of your French girls

$I->haveInDatabase( 'item', ['id' => 1, 'name' => 'first item’]);

$I->amOnPage('/items/');$I->see('first item');$I->see('Add new item');$I->click('Add new item');$I->fillField('name','second item');$I->click('Submit');

$I->seeInDatabase( 'item', ['id' => 2, 'name' => 'second item’]);

Page 20: CI / CD w/ Codeception

DB-CI

DB-STG

ci.my-project.tld

demo.my-project.tld

Page 21: CI / CD w/ Codeception

https://travis-ci.org - Open Sourcehttps://travis-ci.com - Commercial Projects

https://circleci.com/

Page 22: CI / CD w/ Codeception
Page 23: CI / CD w/ Codeception

Thank you

@[email protected]@tudorbarbu.ninja

@CodeVoyagerswww.codevoyagers.com