Skip to content

Commit

Permalink
Update test suites to run in docker containers
Browse files Browse the repository at this point in the history
The existing setup where it builds in travis is now failing due to some dependency i've not traced updating and not being compatible with the old version of php. This is expected as I was running the tests with `--ignore-platform-reqs` and tbh i'm a bit surprised its taken this long to fail in a way that forced me to refactor the process. Just 3 and a half years :)

We need old and new versions of magento to composer install for the existing test coverage, we cannot rely on the versions of php supplied in phpenv within native travis as they're not always available. So I've built an image that does what we need.

- To support this I've had to rename the test envs from `24` to `m24` so they could live in a docker compose file (as they can't just be numeric)
    - This also means the test files have had to move about a bit too.
- You can now run the same setup locally without too much faffing about, although it is much slower on my macbook than in travis (likely because of the volume)
- I ensured support for PHP 8.1 and latest version of magento as part of this, this meant bumping some dependencies like symfony/console and php-cs-fixer
    - I have the composer.json a little modified actually so it technically could still run older symfony console version, but thats not the version we've locked it to. This is because I have some tests that still do a 2.2.0 to -> 2.2.11, I need to verify all override types and tests are reflected in 2.4 series before I move these test cases about a little, see the TODO in `.travis.yml`
  • Loading branch information
convenient committed Jun 13, 2022
1 parent 2bdaa1d commit d2ce9a2
Show file tree
Hide file tree
Showing 21 changed files with 2,361 additions and 934 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/.idea
/vendor/
dev/instances/magento*
.php_cs.cache
.php_cs.cache
dev/vendor/
dev/phpunit/functional/.phpunit.result.cache
31 changes: 31 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

$finder = PhpCsFixer\Finder::create()
->exclude('dev/instances')
->exclude('dev/phpunit/unit/resources/')
->in(__DIR__ . '/src');

$config = new PhpCsFixer\Config();
$config->setUsingCache(false);
$config->setFinder($finder)->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'include' => true,
'new_with_braces' => true,
'no_empty_statement' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'multiline_whitespace_before_semicolons' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unused_imports' => true,
'no_whitespace_in_blank_line' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => true,
'standardize_not_equals' => true,
'ternary_operator_spaces' => true
]);

return $config;
11 changes: 0 additions & 11 deletions .php_cs

This file was deleted.

35 changes: 15 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,36 @@
language: php
php: 7.4.22
dist: xenial
php:
- 8.1
dist: focal

env:
- TEST_GROUP=22
- TEST_GROUP=23
- TEST_GROUP=24
- TEST_GROUP=24nodb
- TEST_GROUP=m22
- TEST_GROUP=m23
- TEST_GROUP=m24
- TEST_GROUP=m24nodb

before_install:
- phpenv config-rm xdebug.ini || true

install:
- composer self-update 1.10.16
- composer self-update --2
- composer install
# Run static analysis tests before trying to install the modules in magento
- vendor/bin/php-cs-fixer fix --diff --dry-run
# Run unit tests before trying to install magento
- vendor/bin/phpunit -c dev/phpunit/unit/phpunit.xml --verbose;
- if [[ $TEST_GROUP = m22 ]]; then rm -rf composer.lock ./vendor/ ; fi # todo ensure all 22 test cases are covered in 24
- cd dev
- if [[ $TEST_GROUP = 22 ]]; then phpenv global 7.2; fi
- if [[ $TEST_GROUP = 22 ]]; then ./setup-magento-with-diff.sh 2.2.0 2.2.11 $TEST_GROUP; fi
- if [[ $TEST_GROUP = 23 ]]; then phpenv global 7.2; fi
- if [[ $TEST_GROUP = 23 ]]; then ./setup-magento-with-diff.sh 2.3.0 2.3.6-p1 $TEST_GROUP; fi
- if [[ $TEST_GROUP = 24 ]]; then ./setup-magento-with-diff.sh 2.3.5 2.4.2 $TEST_GROUP; fi
- if [[ $TEST_GROUP = 24nodb ]]; then NODB=1 ./setup-magento-with-diff.sh 2.3.5 2.4.2 $TEST_GROUP; fi
- cd -
- docker --version
- make docker-up ENV=$TEST_GROUP
- docker ps
- make docker-install ENV=$TEST_GROUP

script:
- if [[ $TEST_GROUP = 22 ]]; then vendor/bin/phpunit -c dev/phpunit/functional/phpunit.xml --exclude-group=v23,v24,v24nodb --verbose; fi
- if [[ $TEST_GROUP = 23 ]]; then vendor/bin/phpunit -c dev/phpunit/functional/phpunit.xml --exclude-group=v22,v24,v24nodb --verbose; fi
- if [[ $TEST_GROUP = 24 ]]; then vendor/bin/phpunit -c dev/phpunit/functional/phpunit.xml --exclude-group=v22,v23,v24nodb --verbose; fi
- if [[ $TEST_GROUP = 24nodb ]]; then vendor/bin/phpunit -c dev/phpunit/functional/phpunit.xml --exclude-group=v22,v23,v24 --verbose; fi
- make docker-test ENV=$TEST_GROUP

services:
- mysql
- elasticsearch
- docker

cache:
apt: true
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
}
],
"require": {
"symfony/console": "^3.4",
"php": "~7.1|~7.2|~7.3|~7.4"
"symfony/console": "^3.4|^4.0",
"php": "~7.2|~7.3|~7.4|~8.1"
},
"autoload": {
"classmap": ["src/"],
"files": ["src/functions.php"]
},
"require-dev": {
"phpunit/phpunit": "^7.5",
"friendsofphp/php-cs-fixer": "^2.14"
"phpunit/phpunit": "^8.5|^9.5",
"friendsofphp/php-cs-fixer": "^3.0"
}
}
Loading

0 comments on commit d2ce9a2

Please sign in to comment.