Skip to content

Commit 615d1b8

Browse files
committed
Removed Docker from the dev stack.
1 parent 5038495 commit 615d1b8

File tree

11 files changed

+195
-152
lines changed

11 files changed

+195
-152
lines changed

.github/workflows/test.yml

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,59 +20,61 @@ jobs:
2020
test:
2121
runs-on: ubuntu-latest
2222

23+
strategy:
24+
matrix:
25+
php-versions: ['8.2', '8.3']
26+
27+
services:
28+
chrome:
29+
image: selenium/standalone-chromium:130.0
30+
ports:
31+
- 4444:4444
32+
2333
steps:
2434
- name: Checkout code
2535
uses: actions/checkout@v4
2636

27-
- name: Set up Docker Buildx
28-
uses: docker/setup-buildx-action@v3
37+
- name: Cache Composer dependencies
38+
uses: actions/cache@v4
39+
with:
40+
path: /tmp/composer-cache
41+
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
2942

30-
- name: Set up Docker Compose
31-
run: docker compose up -d --build
43+
- name: Setup PHP
44+
uses: shivammathur/setup-php@v2
45+
with:
46+
php-version: ${{ matrix.php-versions }}
47+
coverage: pcov
48+
ini-values: pcov.directory=.
3249

33-
- name: Copy codebase into container
34-
run: |
35-
container_id="$(docker compose ps -q phpserver)"
36-
docker cp -L . "${container_id}":/app/
50+
- name: Install dependencies
51+
run: composer install
3752

38-
- name: Install Composer dependencies
39-
run: docker compose exec phpserver composer install --ansi --no-suggest
53+
- name: Validate composer.json
54+
run: |
55+
composer --verbose validate
56+
composer normalize --dry-run
4057
41-
- name: Lint code
42-
run: docker compose exec phpserver composer lint
58+
- name: Check coding standards
59+
run: composer lint
4360
continue-on-error: ${{ vars.CI_LINT_IGNORE_FAILURE == '1' }}
4461

45-
- name: Restart server with Xdebug enabled
46-
run: XDEBUG_ENABLE=true docker compose up -d phpserver
47-
48-
- name: Run tests with PHPUnit
49-
run: docker compose exec -T -e XDEBUG_MODE=coverage phpserver vendor/bin/phpunit
50-
continue-on-error: ${{ vars.CI_TEST_IGNORE_FAILURE == '1' }}
62+
- name: Run unit tests
63+
run: composer test-unit
64+
continue-on-error: ${{ vars.CI_TEST_UNIT_IGNORE_FAILURE == '1' }}
5165

52-
- name: Run tests with Behat
53-
run: docker compose exec -T -e XDEBUG_MODE=coverage phpserver vendor/bin/behat
54-
continue-on-error: ${{ vars.CI_TEST_IGNORE_FAILURE == '1' }}
55-
56-
- name: Process test logs and artifacts
57-
run: |
58-
mkdir -p /tmp/logs
59-
if docker compose ps --services --filter "status=running" | grep -q phpserver && docker compose exec phpserver test -d /app/.logs; then
60-
docker compose cp phpserver:/app/.logs/. "/tmp/logs/"
61-
fi
62-
63-
- name: Upload artifacts
64-
if: always()
65-
uses: actions/upload-artifact@v4
66-
with:
67-
name: artifacts
68-
path: /tmp/logs
66+
- name: Run BDD tests
67+
run: composer test-bdd
68+
continue-on-error: ${{ vars.CI_TEST_BDD_IGNORE_FAILURE == '1' }}
69+
env:
70+
BEHAT_JAVASCRIPT_BASE_URL: http://172.17.0.1:8888
6971

7072
- name: Upload logs as artifacts
7173
if: always()
7274
uses: actions/upload-artifact@v4
7375
with:
74-
name: logs
75-
path: /tmp/logs
76+
name: ${{github.job}}-logs-${{ matrix.php-versions }}
77+
path: .logs
7678
include-hidden-files: true
7779
if-no-files-found: error
7880

@@ -81,8 +83,8 @@ jobs:
8183
if: ${{ env.CODECOV_TOKEN != '' }}
8284
with:
8385
files: |
84-
/tmp/logs/coverage/behat/cobertura.xml
85-
/tmp/logs/coverage/phpunit/cobertura.xml
86+
.logs/coverage/behat/cobertura.xml
87+
.logs/coverage/phpunit/cobertura.xml
8688
fail_ci_if_error: true
8789
token: ${{ secrets.CODECOV_TOKEN }}
8890
env:
@@ -91,4 +93,4 @@ jobs:
9193
- name: Setup tmate session
9294
if: ${{ !cancelled() && github.event.inputs.enable_terminal }}
9395
uses: mxschmitt/action-tmate@v3
94-
timeout-minutes: 5
96+
timeout-minutes: 15

README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,39 +128,35 @@ You may optionally specify size of browser window in the screenshot step:
128128

129129
### Local development setup
130130

131-
```bash
132-
docker compose up -d
133-
docker compose exec phpserver composer install --ansi
134-
```
135-
136-
### Lint code
131+
### Install dependencies.
137132

138133
```bash
139-
docker compose exec phpserver composer lint
134+
composer install
140135
```
141136

142-
### Lint fix
137+
### Start Chrome container.
143138

144139
```bash
145-
docker compose exec phpserver composer lint-fix
140+
docker run -d -p 4444:4444 selenium/standalone-chromium:130.0
146141
```
147142

148-
### Run tests
143+
### Lint code
149144

150145
```bash
151-
docker compose exec phpserver composer test
146+
composer lint
152147
```
153148

154-
### Enable Xdebug
149+
### Fix code style
155150

156151
```bash
157-
XDEBUG_ENABLE=true docker compose up -d phpserver
152+
composer lint-fix
158153
```
159154

160-
To disable, run
155+
### Run tests
161156

162157
```bash
163-
docker compose up -d phpserver
158+
composer test-unit # Run unit tests.
159+
composer test-bdd # Run BDD tests.
164160
```
165161

166162
---

behat.yml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
11
default:
2-
autoload: [ "%paths.base%/tests/behat/bootstrap" ]
2+
autoload: ["%paths.base%/tests/behat/bootstrap"]
33
suites:
44
default:
5-
paths: [ "%paths.base%/tests/behat/features" ]
5+
paths: ["%paths.base%/tests/behat/features"]
66
contexts:
7+
- FeatureContext:
8+
- screenshot_dir: '%paths.base%/.logs/screenshots'
79
- BehatCliContext
8-
- DrevOps\BehatPhpServer\PhpServerContext:
9-
-
10-
docroot: "%paths.base%/tests/behat/features/fixtures"
11-
host: "phpserver"
1210
- DrevOps\BehatScreenshotExtension\Context\ScreenshotContext
13-
- FeatureContext:
14-
-
15-
screenshot_dir: '%paths.base%/.logs/screenshots'
16-
17-
formatters:
18-
pretty: true
19-
# Disable JUnit formatter if memory leaks start to occur.
20-
# See @https://github.com/Behat/Behat/pull/1423
21-
junit:
22-
output_path: '%paths.base%/.logs/test_results/behat'
11+
- DrevOps\BehatPhpServer\PhpServerContext:
12+
- docroot: "%paths.base%/tests/behat/features/fixtures"
13+
host: "0.0.0.0"
14+
port: 8888
2315

2416
extensions:
2517
Behat\MinkExtension:
2618
browserkit_http: ~
2719
files_path: "%paths.base%/tests/behat/features/fixtures"
20+
base_url: http://0.0.0.0:8888
2821
browser_name: chrome
29-
base_url: http://phpserver:8888
3022
javascript_session: selenium2
3123
selenium2:
32-
wd_host: "http://chrome:4444/wd/hub"
24+
wd_host: "http://localhost:4444/wd/hub"
3325
capabilities:
3426
browser: chrome
3527
extra_capabilities:
@@ -43,10 +35,12 @@ default:
4335
- '--disable-translate' # Disables the built-in translation feature, preventing Chrome from offering to translate pages.
4436
- '--no-first-run' # Skips the initial setup screen that Chrome typically shows when running for the first time.
4537
- '--test-type' # Disables certain security features and UI components that are unnecessary for automated testing, making Chrome more suitable for test environments.
38+
4639
DrevOps\BehatScreenshotExtension:
4740
dir: '%paths.base%/.logs/screenshots'
4841
fail: true
4942
purge: true
43+
5044
DVDoug\Behat\CodeCoverage\Extension:
5145
filter:
5246
include:
@@ -60,3 +54,10 @@ default:
6054
target: .logs/coverage/behat/.coverage-html
6155
cobertura:
6256
target: .logs/coverage/behat/cobertura.xml
57+
58+
formatters:
59+
pretty: true
60+
# Disable JUnit formatter if memory leaks start to occur.
61+
# See @https://github.com/Behat/Behat/pull/1423
62+
junit:
63+
output_path: '%paths.base%/.logs/test_results/behat'

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@
6666
"rector --clear-cache",
6767
"phpcbf"
6868
],
69-
"test": [
70-
"if [ \"${XDEBUG_MODE}\" = 'coverage' ]; then phpunit; else phpunit --no-coverage; fi",
71-
"behat"
72-
]
69+
"reset": "rm -Rf vendor vendor-bin composer.lock",
70+
"test-bdd": "behat --colors",
71+
"test-unit": "phpunit"
7372
}
7473
}

docker-compose.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/DrevOps/BehatScreenshotExtension/Context/ScreenshotContext.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
1919
*/
2020
class ScreenshotContext extends RawMinkContext implements ScreenshotAwareContextInterface {
21+
2122
/**
2223
* Screenshot step line.
2324
*/
@@ -87,13 +88,13 @@ public function beforeScenarioInit(BeforeScenarioScope $scope): void {
8788
}
8889
catch (\Exception $exception) {
8990
throw new \RuntimeException(
90-
sprintf(
91-
'Please make sure that Selenium server is running. %s',
92-
$exception->getMessage(),
93-
),
94-
$exception->getCode(),
95-
$exception,
96-
);
91+
sprintf(
92+
'Please make sure that Selenium server is running. %s',
93+
$exception->getMessage(),
94+
),
95+
$exception->getCode(),
96+
$exception,
97+
);
9798
}
9899
}
99100
}
@@ -299,6 +300,13 @@ protected function makeFileName(string $ext, ?string $filename = NULL, bool $fai
299300
$url = NULL;
300301
}
301302

303+
if (!empty($url) && !empty(getenv('BEHAT_SCREENSHOT_TOKEN_HOST'))) {
304+
$host = parse_url($url, PHP_URL_HOST);
305+
if ($host) {
306+
$url = str_replace($host, getenv('BEHAT_SCREENSHOT_TOKEN_HOST'), $url);
307+
}
308+
}
309+
302310
$data = [
303311
'ext' => $ext,
304312
'step_name' => $step->getText(),

src/DrevOps/BehatScreenshotExtension/ServiceContainer/BehatScreenshotExtension.php

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,36 @@ public function initialize(ExtensionManager $extensionManager): void {
4343
* {@inheritdoc}
4444
*/
4545
public function configure(ArrayNodeDefinition $builder): void {
46-
$definitionChildren = $builder->children();
46+
// @phpcs:disable Drupal.WhiteSpace.ObjectOperatorIndent.Indent
47+
// @formatter:off
4748
// @phpstan-ignore-next-line
48-
$definitionChildren
49-
->scalarNode('dir')->cannotBeEmpty()->defaultValue('%paths.base%/screenshots')->end()
50-
->scalarNode('fail')->cannotBeEmpty()->defaultValue(TRUE)->end()
51-
->scalarNode('fail_prefix')->cannotBeEmpty()->defaultValue('failed_')->end()
52-
->scalarNode('purge')->cannotBeEmpty()->defaultValue(FALSE)->end()
49+
$builder->children()
50+
->scalarNode('dir')
51+
->cannotBeEmpty()
52+
->defaultValue('%paths.base%/screenshots')
53+
->end()
54+
->scalarNode('fail')
55+
->cannotBeEmpty()
56+
->defaultValue(TRUE)
57+
->end()
58+
->scalarNode('fail_prefix')
59+
->cannotBeEmpty()
60+
->defaultValue('failed_')
61+
->end()
62+
->scalarNode('purge')
63+
->cannotBeEmpty()
64+
->defaultValue(FALSE)
65+
->end()
5366
->scalarNode('filenamePattern')
54-
->cannotBeEmpty()
55-
->defaultValue('{datetime:U}.{feature_file}.feature_{step_line}.{ext}')->end()
67+
->cannotBeEmpty()
68+
->defaultValue('{datetime:U}.{feature_file}.feature_{step_line}.{ext}')
69+
->end()
5670
->scalarNode('filenamePatternFailed')
57-
->cannotBeEmpty()
58-
->defaultValue('{datetime:U}.{fail_prefix}{feature_file}.feature_{step_line}.{ext}')->end();
71+
->cannotBeEmpty()
72+
->defaultValue('{datetime:U}.{fail_prefix}{feature_file}.feature_{step_line}.{ext}')
73+
->end();
74+
// @formatter:on
75+
// @phpcs:enable Drupal.WhiteSpace.ObjectOperatorIndent.Indent
5976
}
6077

6178
/**

0 commit comments

Comments
 (0)