Skip to content

Commit 5b6b922

Browse files
committed
Séparation des tests behat avec et sans javascript
Cela permet d'avoir du retry auto des tests avec js qui peuvent être un peu flaky de temps en temps.
1 parent 7d3af6d commit 5b6b922

3 files changed

Lines changed: 77 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ jobs:
6464
- name: PHPStan
6565
run: php ./bin/phpstan
6666

67-
functional:
68-
name: "Functional tests"
67+
functional-no-js:
68+
name: "Functional tests (no JS)"
6969
runs-on: ubuntu-22.04
7070

7171
steps:
@@ -85,17 +85,55 @@ jobs:
8585
- name: Delete symfony cache
8686
run: rm -rf var/cache/test
8787

88-
- name: Tests - Functional
89-
run: make test-functional
88+
- name: Tests - Functional (no JS)
89+
run: make test-functional-no-js
9090

9191
- uses: actions/upload-artifact@v4
9292
with:
93-
name: Functional tests - deprecated log - full
93+
name: Functional tests (no JS) - deprecated log - full
9494
path: var/logs/test.deprecations.log
9595

9696
- uses: actions/upload-artifact@v4
9797
with:
98-
name: Functional tests - deprecated log - report
98+
name: Functional tests (no JS) - deprecated log - report
99+
path: var/logs/test.deprecations_grouped.log
100+
101+
functional-js:
102+
name: "Functional tests (JS)"
103+
runs-on: ubuntu-22.04
104+
105+
steps:
106+
- uses: actions/checkout@v6
107+
108+
- name: Cache Docker images.
109+
uses: AndreKurait/docker-cache@0.6.0
110+
with:
111+
key: |
112+
docker-${{ runner.os }}-${{ hashFiles(
113+
'compose.yml',
114+
'docker/dockerfiles/apachephp/Dockerfile',
115+
'docker/dockerfiles/mysql/Dockerfile',
116+
'docker/dockerfiles/mysqltest/Dockerfile'
117+
) }}
118+
119+
- name: Delete symfony cache
120+
run: rm -rf var/cache/test
121+
122+
- name: Tests - Functional (JS)
123+
uses: nick-fields/retry@v4
124+
with:
125+
timeout_minutes: 10
126+
max_attempts: 3
127+
command: make test-functional-js
128+
129+
- uses: actions/upload-artifact@v4
130+
with:
131+
name: Functional tests (JS) - deprecated log - full
132+
path: var/logs/test.deprecations.log
133+
134+
- uses: actions/upload-artifact@v4
135+
with:
136+
name: Functional tests (JS) - deprecated log - report
99137
path: var/logs/test.deprecations_grouped.log
100138

101139
integration:

Makefile

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ help:
3636
} \
3737
{ lastLine = $$0 }' $(MAKEFILE_LIST)
3838

39-
.PHONY: install docker-up docker-stop docker-down test hooks vendors db-seed db-migrations reset-db init console phpstan assets
39+
.PHONY: install docker-up docker-stop docker-down test test-functional test-functional-no-js test-functional-js hooks vendors db-seed db-migrations reset-db init console phpstan assets
4040

4141
##@ Setup
4242

@@ -111,6 +111,26 @@ test-functional: data config htdocs/uploads tmp
111111
make var/logs/test.deprecations_grouped.log
112112
$(DOCKER_COMP) stop dbtest apachephptest mailcatcher
113113

114+
### Tests fonctionnels (scénarios sans JS)
115+
test-functional-no-js: data config htdocs/uploads tmp
116+
$(DOCKER_COMP) stop dbtest apachephptest mailcatcher
117+
$(DOCKER_COMP) up -d dbtest apachephptest mailcatcher
118+
make clean-test-deprecated-log
119+
$(DOCKER_COMP) run --no-deps --rm -u localUser apachephptest ./bin/bdi detect drivers
120+
$(DOCKER_COMP) run --no-deps --rm -u localUser apachephptest ./bin/behat --suite=web_features_no_js
121+
make var/logs/test.deprecations_grouped.log
122+
$(DOCKER_COMP) stop dbtest apachephptest mailcatcher
123+
124+
### Tests fonctionnels (scénarios JS via Panther)
125+
test-functional-js: data config htdocs/uploads tmp
126+
$(DOCKER_COMP) stop dbtest apachephptest mailcatcher
127+
$(DOCKER_COMP) up -d dbtest apachephptest mailcatcher
128+
make clean-test-deprecated-log
129+
$(DOCKER_COMP) run --no-deps --rm -u localUser apachephptest ./bin/bdi detect drivers
130+
$(DOCKER_COMP) run --no-deps --rm -u localUser apachephptest ./bin/behat --suite=web_features_js
131+
make var/logs/test.deprecations_grouped.log
132+
$(DOCKER_COMP) stop dbtest apachephptest mailcatcher
133+
114134
### Tests d'intégration avec start/stop des images docker
115135
test-integration-ci:
116136
$(DOCKER_COMP) stop dbtest apachephptest

behat.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use Afup\Tests\Behat\Bootstrap\FeatureContext;
44
use Behat\Config\Config;
55
use Behat\Config\Extension;
6+
use Behat\Config\Filter\TagFilter;
67
use Behat\Config\Profile;
78
use Behat\Config\Suite;
89
use Behat\MinkExtension\Context\MinkContext;
@@ -59,11 +60,21 @@
5960
],
6061
]))
6162
->withSuite(
62-
(new Suite('web_features'))
63+
(new Suite('web_features_no_js'))
6364
->withContexts(
6465
FeatureContext::class,
6566
MinkContext::class
6667
)
6768
->withPaths('%paths.base%/tests/behat')
69+
->withFilter(new TagFilter('~@javascript'))
70+
)
71+
->withSuite(
72+
(new Suite('web_features_js'))
73+
->withContexts(
74+
FeatureContext::class,
75+
MinkContext::class
76+
)
77+
->withPaths('%paths.base%/tests/behat')
78+
->withFilter(new TagFilter('@javascript'))
6879
)
6980
);

0 commit comments

Comments
 (0)