Skip to content

Commit 6364c49

Browse files
[#398] Add Drupal 9 readiness checks to CI. (#404)
* [#398] Add Drupal 9 readiness checks to CI. * [#398] Add Drupal 9 readiness checks to CI - updates. * [#398] Allow build against D9. * [#398] Testing matrix w/D8 and D9. * [#398] Testing matrix w/D8 and D9 - adding back rest of steps. * [#398] Fixing EdgeExceptionSubscriber and EdgeExceptionSubscriberTest for D9 (due to drupal.org/project/drupal/issues/3113876). * [#398] Fixing functional tests for D9. * [#398] Order of execution of jobs in CircleCI. * [#398] Fixes tests. * [#398] Fixing matrix of jobs in CircleCI. * [#398] Fixing matrix of jobs in CircleCI. * [#398] Fixing matrix of jobs in CircleCI. * [#398] Fixing matrix of jobs in CircleCI. * [#398] Fixing matrix of jobs in CircleCI. * [#398] Fixing matrix of jobs in CircleCI. * [#398] Fixing composer issue. * [#398] Use d8 for tests. * [#398] enable code sniffer and drupal-check. * [#398] Fix deprecations from drupal-check. * [#398] Reenable functional JS tests. * [#398] Fix deprecation comment format.
1 parent 453354d commit 6364c49

17 files changed

+321
-114
lines changed

.circleci/RoboFile.php

+61-13
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,15 @@ public function setupSkeleton()
5555
->mkdir('artifacts/phpcs')
5656
->mkdir('artifacts/phpmd')
5757
->mkdir('artifacts/phpmetrics')
58+
->mkdir('artifacts/d9')
5859
->mkdir('/tmp/artifacts/phpunit')
5960
->mkdir('/tmp/artifacts/phpmd')
6061
->run();
6162

6263
$this->taskFilesystemStack()
6364
->chown('/tmp/artifacts', 'www-data', TRUE)
65+
->copy('modules/apigee_edge/.circleci/d9.sh', '/var/www/html/d9.sh')
66+
->chmod('/var/www/html/d9.sh', 0777)
6467
->run();
6568
}
6669

@@ -95,6 +98,7 @@ public function addBehatDeps()
9598
public function addModules(array $modules)
9699
{
97100
$config = json_decode(file_get_contents('composer.json'));
101+
$config->extra->{"merge-plugin"}->{"ignore-duplicates"} = TRUE;
98102

99103
foreach ($modules as $module) {
100104
list($module,) = explode(':', $module);
@@ -172,7 +176,11 @@ public function updateDependencies()
172176
// on it fails for the first time.
173177
$this->taskFilesystemStack()->remove('composer.lock')->run();
174178

175-
$this->taskDeleteDir('vendor/')->run();
179+
// Remove all core files and vendor.
180+
$this->taskFilesystemStack()
181+
->taskDeleteDir('core')
182+
->taskDeleteDir('vendor')
183+
->run();
176184

177185
// Composer often runs out of memory when installing drupal.
178186
$this->taskComposerInstall('php -d memory_limit=-1 /usr/local/bin/composer')
@@ -196,6 +204,8 @@ public function updateDependencies()
196204
->run();
197205

198206
// Add composer version info to an artifact file.
207+
$this->taskExec('composer show')
208+
->run();
199209
$this->taskExec('composer show > /tmp/artifacts/composer-show.txt')
200210
->run();
201211
}
@@ -401,22 +411,47 @@ public function extractCoverageStats($path)
401411
}
402412

403413
/**
404-
* Adds modules to the merge section.
414+
* Set the Drupal core version.
415+
*
416+
* @param int $drupalCoreVersion
417+
* The major version of Drupal required.
405418
*/
406-
public function configureModuleDependencies()
419+
public function drupalVersion($drupalCoreVersion)
407420
{
408421
$config = json_decode(file_get_contents('composer.json'));
409422

410-
// The Drupal core image might need updating. Request the newest stable.
411423
unset($config->require->{"drupal/core"});
412-
$config->require->{"drupal/core-recommended"} = "~8.8";
413424

414-
// Add rules for testing apigee_edge_actions.
415-
$config->require->{"drupal/rules"} = "3.0.0-alpha5";
425+
switch ($drupalCoreVersion) {
426+
case '9':
427+
$config->require->{"drupal/core-recommended"} = '^9';
428+
$config->require->{"drupal/core-dev"} = '^9';
429+
430+
break;
431+
432+
case '8':
433+
$config->require->{"drupal/core-recommended"} = '~8';
434+
$config->require->{"drupal/core-dev"} = '~8';
416435

417-
// We require Drupal console and drush for some tests.
418-
$config->require->{"drupal/console"} = "~1.0";
419-
$config->require->{"drush/drush"} = "^9.7";
436+
// Add rules for testing apigee_edge_actions (only for D8).
437+
$config->require->{"drupal/rules"} = "3.0.0-alpha5";
438+
439+
// We require Drupal drush and console for some tests.
440+
$config->require->{"drupal/console"} = "~1.0";
441+
442+
default:
443+
break;
444+
}
445+
446+
file_put_contents('composer.json', json_encode($config, JSON_PRETTY_PRINT));
447+
}
448+
449+
/**
450+
* Adds modules to the merge section.
451+
*/
452+
public function configureModuleDependencies()
453+
{
454+
$config = json_decode(file_get_contents('composer.json'));
420455

421456
// If you require core, you must not replace it.
422457
unset($config->replace);
@@ -433,10 +468,23 @@ public function configureModuleDependencies()
433468
}
434469
$config->extra->{"merge-plugin"}->include = array_values($config->extra->{"merge-plugin"}->include);
435470

436-
// Add dependencies for phpunit tests.
437-
$config->require->{"drupal/core-dev"} = "~8.8";
438-
439471
file_put_contents('composer.json', json_encode($config, JSON_PRETTY_PRINT));
440472
}
441473

474+
/**
475+
* Perform extra tasks per Drupal core version.
476+
*
477+
* @param int $drupalCoreVersion
478+
* The major version of Drupal required.
479+
*/
480+
public function doExtra($drupalCoreVersion) {
481+
if ($drupalCoreVersion > 8) {
482+
483+
// Delete D8 only modules.
484+
$this->taskFilesystemStack()
485+
->taskDeleteDir('modules/apigee_edge/modules/apigee_edge_actions')
486+
->run();
487+
}
488+
}
489+
442490
}

.circleci/config.yml

+71-13
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
# Check https://circleci.com/docs/2.0/language-php/ for more details
1414
#
1515

16+
version: 2.1
17+
1618
defaults: &defaults
1719
docker:
1820
# specify the version you desire here (avoid latest except for testing)
19-
- image: andrewberry/drupal_tests:0.4.0
21+
- image: quay.io/deviantintegral/drupal_tests:0.5.0-drupal87
2022

2123
- image: selenium/standalone-chrome-debug:3.141.59-neon
2224

@@ -34,6 +36,11 @@ defaults: &defaults
3436
# https://discuss.circleci.com/t/bug-circleci-build-command-ignores-checkout-path-config/13004
3537
working_directory: /var/www/html/modules/apigee_edge
3638

39+
parameters:
40+
core-version:
41+
type: integer
42+
default: 8
43+
3744
# YAML does not support merging of lists. That means we can't have a default
3845
# 'steps' configuration, though we can have defaults for individual step
3946
# properties.
@@ -55,7 +62,11 @@ save_cache: &save_cache
5562
# Install composer dependencies into the workspace to share with all jobs.
5663
update_dependencies: &update_dependencies
5764
<<: *defaults
65+
5866
steps:
67+
- print:
68+
message: Using Drupal core version << parameters.core-version >>
69+
5970
- checkout
6071

6172
- restore_cache: *restore_cache
@@ -64,7 +75,7 @@ update_dependencies: &update_dependencies
6475
working_directory: /var/www/html
6576
command: |
6677
cp ./modules/apigee_edge/.circleci/update-dependencies.sh /var/www/html
67-
./update-dependencies.sh apigee_edge
78+
./update-dependencies.sh apigee_edge << parameters.core-version >>
6879
6980
- save_cache: *save_cache
7081

@@ -92,7 +103,7 @@ unit_kernel_tests: &unit_kernel_tests
92103
working_directory: /var/www/html
93104
command: |
94105
cp ./modules/apigee_edge/.circleci/test.sh /var/www/html
95-
./test.sh apigee_edge
106+
./test.sh apigee_edge << parameters.core-version >>
96107
97108
- store_test_results:
98109
path: /tmp/artifacts/phpunit
@@ -115,7 +126,7 @@ functional_tests: &functional_tests
115126
working_directory: /var/www/html
116127
command: |
117128
cp ./modules/apigee_edge/.circleci/test-functional.sh /var/www/html
118-
./test-functional.sh apigee_edge
129+
./test-functional.sh apigee_edge << parameters.core-version >>
119130
120131
- store_test_results:
121132
path: /tmp/artifacts/phpunit
@@ -137,7 +148,7 @@ functional_js_tests: &functional_js_tests
137148
working_directory: /var/www/html
138149
command: |
139150
cp ./modules/apigee_edge/.circleci/test-functional-js.sh /var/www/html
140-
./test-functional-js.sh apigee_edge
151+
./test-functional-js.sh apigee_edge << parameters.core-version >>
141152
142153
- store_test_results:
143154
path: /tmp/artifacts/phpunit
@@ -180,8 +191,34 @@ code_coverage: &code_coverage
180191
- store_artifacts:
181192
path: /var/www/html/artifacts
182193

194+
# Run D9 deprecation checks.
195+
d9_check: &d9_check
196+
<<: *defaults
197+
steps:
198+
- attach_workspace:
199+
at: /var/www/html
200+
201+
- checkout
202+
203+
- run:
204+
working_directory: /var/www/html
205+
command: |
206+
./d9.sh modules/apigee_edge
207+
208+
- store_test_results:
209+
path: /var/www/html/artifacts/d9
210+
- store_artifacts:
211+
path: /var/www/html/artifacts/d9
212+
213+
commands:
214+
print:
215+
parameters:
216+
message:
217+
type: string
218+
steps:
219+
- run: echo << parameters.message >>
220+
183221
# Declare all of the jobs we should run.
184-
version: 2
185222
jobs:
186223
update-dependencies:
187224
<<: *update_dependencies
@@ -195,6 +232,8 @@ jobs:
195232
<<: *code_sniffer
196233
run-code-coverage:
197234
<<: *code_coverage
235+
run-d9-check:
236+
<<: *d9_check
198237

199238
workflows:
200239
version: 2
@@ -203,19 +242,38 @@ workflows:
203242
# Functional JS tests need to run after functional due to a conflict in apigee_edge_apiproduct_rbac tests.
204243
test_and_lint:
205244
jobs:
206-
- update-dependencies
245+
- update-dependencies:
246+
name: update-dependencies-<< matrix.core-version >>
247+
matrix:
248+
parameters:
249+
core-version: [8]
250+
- run-code-sniffer:
251+
requires:
252+
- update-dependencies-8
253+
- run-d9-check:
254+
requires:
255+
- update-dependencies-8
207256
- run-unit-kernel-tests:
257+
name: run-unit-kernel-tests-<< matrix.core-version >>
258+
matrix:
259+
parameters:
260+
core-version: [8]
208261
requires:
209-
- update-dependencies
262+
- update-dependencies-<< matrix.core-version >>
210263
- run-functional-tests:
264+
name: run-functional-tests-<< matrix.core-version >>
265+
matrix:
266+
parameters:
267+
core-version: [8]
211268
requires:
212-
- update-dependencies
269+
- update-dependencies-<< matrix.core-version >>
213270
- run-functional-js-tests:
271+
name: run-functional-js-tests-<< matrix.core-version >>
272+
matrix:
273+
parameters:
274+
core-version: [8]
214275
requires:
215-
- update-dependencies
216-
- run-code-sniffer:
217-
requires:
218-
- update-dependencies
276+
- update-dependencies-<< matrix.core-version >>
219277
# - run-code-coverage:
220278
# requires:
221279
# - update-dependencies

.circleci/d9.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash -ex
2+
3+
if [ ! -f dependencies_updated ]
4+
then
5+
./update-dependencies.sh $1
6+
fi
7+
8+
vendor/bin/drupal-check --no-progress --memory-limit=1000M --format=junit $1 > /var/www/html/artifacts/d9/d9check.xml
9+

.circleci/test-functional-js.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ export MINK_DRIVER_ARGS_WEBDRIVER='["chrome", null, "http://localhost:4444/wd/hu
99

1010
if [ ! -f dependencies_updated ]
1111
then
12-
./update-dependencies.sh $1
12+
./update-dependencies.sh $1 $2
1313
fi
1414

1515
# This is the command used by the base image to serve Drupal.
1616
apache2-foreground&
1717

1818
robo override:phpunit-config $1
19+
robo do:extra $2
1920

2021
sudo -E -u www-data vendor/bin/phpunit -c core --group $1 --testsuite functional-javascript --debug --verbose --log-junit /tmp/artifacts/phpunit/phpunit.xml

.circleci/test-functional.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ export BROWSERTEST_OUTPUT_DIRECTORY="/var/www/html/sites/simpletest"
88

99
if [ ! -f dependencies_updated ]
1010
then
11-
./update-dependencies.sh $1
11+
./update-dependencies.sh $1 $2
1212
fi
1313

1414
# This is the command used by the base image to serve Drupal.
1515
apache2-foreground&
1616

1717
robo override:phpunit-config $1
18+
robo do:extra $2
1819

1920
sudo -E -u www-data vendor/bin/phpunit -c core --group $1 --testsuite functional --debug --verbose --log-junit /tmp/artifacts/phpunit/phpunit.xml

.circleci/test.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ export BROWSERTEST_OUTPUT_DIRECTORY="/var/www/html/sites/simpletest"
88

99
if [ ! -f dependencies_updated ]
1010
then
11-
./update-dependencies.sh $1
11+
./update-dependencies.sh $1 $2
1212
fi
1313

1414
# This is the command used by the base image to serve Drupal.
1515
apache2-foreground&
1616

1717
robo override:phpunit-config $1
18+
robo do:extra $2
19+
composer show
1820

1921
sudo -E -u www-data vendor/bin/phpunit -c core --group $1 --testsuite unit,kernel --debug --verbose --log-junit /tmp/artifacts/phpunit/phpunit.xml

.circleci/update-dependencies.sh

+2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ cp modules/apigee_edge/.circleci/RoboFile.php ./
55

66
robo setup:skeleton
77
robo add:modules $1
8+
robo drupal:version $2
89
robo configure:module-dependencies
910
robo update:dependencies
11+
robo do:extra $2
1012

1113
# Touch a flag so we know dependencies have been set. Otherwise, there is no
1214
# easy way to know this step needs to be done when running circleci locally since

apigee_edge.services.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ services:
116116
apigee_edge.exception_subscriber:
117117
class: Drupal\apigee_edge\EventSubscriber\EdgeExceptionSubscriber
118118
arguments:
119-
- '@http_kernel'
120119
- '@logger.channel.apigee_edge'
121-
- '@redirect.destination'
122-
- '@router.no_access_checks'
123120
- '@config.factory'
124121
- '@messenger'
122+
- '@class_resolver'
123+
- '@current_route_match'
124+
- '%main_content_renderers%'
125125
tags:
126126
- { name: event_subscriber }
127127

0 commit comments

Comments
 (0)