-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathDockerComposeTest.php
More file actions
64 lines (48 loc) · 3.25 KB
/
Copy pathDockerComposeTest.php
File metadata and controls
64 lines (48 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
declare(strict_types=1);
namespace DrevOps\Vortex\Tests\Functional;
use AlexSkrypnyk\File\File;
class DockerComposeTest extends FunctionalTestCase {
public function testDockerCompose(): void {
$this->logSubstep('Building stack with Docker Compose');
$this->cmd('docker compose build --no-cache', txt: 'Build stack images', tio: 15 * 60);
$this->cmd('docker compose up -d --force-recreate', txt: 'Start stack', tio: 15 * 60);
$this->syncToHost();
$this->logSubstep('Installing development dependencies');
$this->cmd('docker compose exec -T cli composer install --prefer-dist', txt: 'Install development dependencies with Composer', tio: 10 * 60);
$this->cmd('docker compose exec -T cli bash -cl "yarn install --frozen-lockfile"', txt: 'Install development dependencies with Yarn', tio: 10 * 60);
$this->logSubstep('Linting backend code');
$this->cmd('docker compose exec -T cli vendor/bin/phpcs', txt: 'Lint code with PHPCS', tio: 10 * 60);
$this->cmd('docker compose exec -T cli vendor/bin/phpstan', txt: 'Lint code with PHPStan', tio: 10 * 60);
$this->cmd('docker compose exec -T cli vendor/bin/rector', txt: 'Lint code with Rector', tio: 10 * 60);
$this->cmd('docker compose exec -T cli vendor/bin/phpmd . text phpmd.xml', txt: 'Lint code with PHPMD', tio: 10 * 60);
$this->logSubstep('Linting front-end code');
$this->cmd('docker compose exec -T cli vendor/bin/twig-cs-fixer lint', txt: 'Lint code with TwigCS', tio: 10 * 60);
$this->cmd('docker compose exec -T cli yarn run lint', txt: 'Lint code with module linters', tio: 10 * 60);
$this->cmd('docker compose exec -T cli bash -cl "yarn run --cwd=\${WEBROOT}/themes/custom/\${DRUPAL_THEME} lint"', txt: 'Lint code with theme linters', tio: 10 * 60);
$this->substepDownloadDb(TRUE);
$this->logSubstep('Provisioning with direct script execution');
$this->cmd('docker compose exec -T cli ./scripts/vortex/provision.sh', txt: 'Run ./scripts/vortex/provision.sh in container', tio: 10 * 60);
$this->logSubstep('Run tests');
$this->cmd('docker compose exec -T cli vendor/bin/phpunit', txt: 'Run PHPUnit tests');
$this->cmd('docker compose exec -T cli vendor/bin/behat', txt: 'Run Behat tests');
}
/**
* Test Package token handling during build.
*
* Make sure to run with TEST_PACKAGE_TOKEN=working_test_token or this test
* will fail.
*/
public function testPackageToken(): void {
$package_token = getenv('TEST_PACKAGE_TOKEN');
$this->assertNotEmpty($package_token, 'TEST_PACKAGE_TOKEN environment variable must be set');
$this->logSubstep('Adding private package to test GitHub token');
File::remove('composer.lock');
$this->cmd('composer config repositories.test-private-package vcs git@github.com:drevops/test-private-package.git');
$this->cmd('composer require --no-update drevops/test-private-package:^1');
$this->logSubstep('Building without PACKAGE_TOKEN - should fail');
$this->cmdFail('docker compose build cil --no-cache', txt: 'Build stack images without token', tio: 15 * 60);
$this->logSubstep('Building with PACKAGE_TOKEN - should succeed');
$this->cmd('docker compose build cli --no-cache', txt: 'Build stack images with token', env: ['PACKAGE_TOKEN' => $package_token], tio: 15 * 60);
}
}