Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #638: Fix all our tests #639

Merged
merged 39 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1545b6d
Issue #638: Replace sserbin/twig-linter with vincentlanglet/twig-cs-f…
justafish Aug 8, 2024
e9b2275
remove debugging
justafish Aug 8, 2024
b7c44b2
Merge branch 'main' into justafish/638-replace-twig-linter
justafish Aug 8, 2024
ec6e32d
Fix PHP/Drupal versions
justafish Aug 8, 2024
9659e7a
Set node version to 22
justafish Aug 8, 2024
4dbf184
Set yarn classic version
justafish Aug 8, 2024
d301672
Enable corepack
justafish Aug 8, 2024
d482c08
Upgrade Tugboat to PHP 8.3
justafish Aug 8, 2024
c6f9f56
debugging
justafish Aug 8, 2024
0d11149
Disable corepack for classic tests
justafish Aug 8, 2024
5d925f5
Remove tmate
justafish Aug 8, 2024
c43d488
add exec
justafish Aug 8, 2024
1124fee
Add symlink to yarn
justafish Aug 8, 2024
cf633ce
Upgrade Pantheon PHP version and PHPUnit schema
justafish Aug 9, 2024
bb9a4f9
Migrate PHPUnit configuration and disable corepack for Yarn Classic t…
justafish Aug 9, 2024
d4e7e26
Time Service Added and REQUEST_TIME deprecated
justafish Aug 9, 2024
3d4a539
Fix more tests
justafish Aug 9, 2024
fb4e35f
Fix more tests
justafish Aug 9, 2024
c969ed2
Fix Pantheon versions and excluding unit tests from phpunit functiona…
justafish Aug 9, 2024
914940c
Fix Pantheon, static PHPUnit tests, and PHPUnit output folder
justafish Aug 9, 2024
accdda3
Fix test suites
justafish Aug 9, 2024
0903199
fix namespaces
justafish Aug 9, 2024
af7c29c
Fix test numbers and add debuggin
justafish Aug 9, 2024
2feb762
Make sure yarn is run in ddev
justafish Aug 9, 2024
2fd2fc1
Adjust Pantheon settings file
justafish Aug 9, 2024
964c0cb
fix url
justafish Aug 9, 2024
066857c
remove additional lines from test traits config
justafish Aug 9, 2024
a6b0a75
Update tests for Drupal 10 an Drupal 11
justafish Aug 12, 2024
f0c921a
Fix PHPUnit tests
justafish Aug 12, 2024
732052b
Fix artifact name
justafish Aug 12, 2024
56c1350
Fix PHPUnit command
justafish Aug 12, 2024
cc72b52
Fix file names
justafish Aug 12, 2024
699f275
remove drupal version from artifact
justafish Aug 12, 2024
b967155
remove char
justafish Aug 12, 2024
f7d9419
Fix matrix
justafish Aug 12, 2024
35c2a9e
Fix matrix
justafish Aug 12, 2024
89ed57b
Fix upload artifact name
justafish Aug 12, 2024
d9e3d86
Fix testtraits path
justafish Aug 12, 2024
24ee1c6
Merge branch 'main' into justafish/638-replace-twig-linter
justafish Aug 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/TestFunctional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jobs:
- name: Setup Project
run: |
ddev config --auto
ddev config --nodejs-version "18"
ddev config --nodejs-version "22"
ddev config --corepack-enable
ddev start
ddev composer config extra.drupal-scaffold.gitignore true
ddev composer config --json extra.drupal-scaffold.allowed-packages '["lullabot/drainpipe-dev", "lullabot/drainpipe"]'
Expand Down Expand Up @@ -143,7 +144,9 @@ jobs:

- name: Setup Nightwatch
run: |
ddev yarn set version classic
ddev exec corepack disable
ddev exec npm i -g yarn@1.22.1
ddev exec 'ln -s $(npm root -g)/yarn/bin/yarn /usr/local/bin/yarn'
ddev yarn init -y
ddev yarn add nightwatch nightwatch-accessibility @lullabot/nightwatch-drupal-commands lodash --dev

Expand Down Expand Up @@ -195,7 +198,7 @@ jobs:
ddev yarn set version berry
ddev yarn set version 3
ddev yarn init -y
yarn config set nodeLinker node-modules
ddev yarn config set nodeLinker node-modules
ddev yarn add nightwatch nightwatch-accessibility @lullabot/nightwatch-drupal-commands lodash --dev

- name: Install Drupal
Expand Down Expand Up @@ -243,12 +246,11 @@ jobs:

- name: Setup Nightwatch
run: |
ddev config --nodejs-version=21
ddev restart
ddev yarn set version berry
ddev yarn set version 4
ddev yarn init -y
yarn config set nodeLinker node-modules
ddev yarn config set nodeLinker node-modules
ddev yarn add nightwatch nightwatch-accessibility @lullabot/nightwatch-drupal-commands lodash --dev

- name: Install Drupal
Expand Down Expand Up @@ -350,7 +352,6 @@ jobs:

- name: Setup Nightwatch
run: |
ddev config --nodejs-version=21
ddev restart
ddev yarn set version berry
ddev yarn init -y
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/TestGitHubActions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Create a Drupal project
run: composer create-project drupal/recommended-project . --ignore-platform-req=ext-gd
run: composer create-project drupal/recommended-project . --ignore-platform-reqs

- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -58,10 +58,9 @@ jobs:
run: |
echo "api_version: 1" >> pantheon.yml
echo "web_docroot: true" >> pantheon.yml
echo "php_version: 8.1" >> pantheon.yml
echo "drush_version: 10" >> pantheon.yml
echo "php_version: 8.3" >> pantheon.yml
echo "database:" >> pantheon.yml
echo " version: 10.4" >> pantheon.yml
echo " version: 10.6" >> pantheon.yml
echo "enforce_https: full+subdomains" >> pantheon.yml
echo "build_step: false" >> pantheon.yml

Expand All @@ -78,7 +77,7 @@ jobs:
echo "\$settings['container_yamls'][] = __DIR__ . '/services.yml';" >> web/sites/default/settings.php
echo "include __DIR__ . \"/settings.pantheon.php\";" >> web/sites/default/settings.php
echo "\$settings['config_sync_directory'] = '../config';" >> web/sites/default/settings.php
curl -o web/sites/default/settings.pantheon.php https://raw.githubusercontent.com/pantheon-systems/drops-8/default/sites/default/settings.pantheon.php
curl -o web/sites/default/settings.pantheon.php https://raw.githubusercontent.com/pantheon-systems/drupal-integrations/11.x/assets/settings.pantheon.php

- name: Snapshot Project
env:
Expand Down
25 changes: 14 additions & 11 deletions .github/workflows/TestMetapackages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Create a Drupal project
run: composer create-project drupal/recommended-project . --ignore-platform-req=ext-gd
run: composer create-project drupal/recommended-project . --ignore-platform-reqs

- uses: actions/checkout@v4
with:
Expand All @@ -35,7 +35,8 @@ jobs:
- name: Setup Project
run: |
ddev config --auto
ddev config --nodejs-version "18"
ddev config --nodejs-version "22"
ddev config --corepack-enable
ddev start
ddev composer config extra.drupal-scaffold.gitignore true
ddev composer config --json extra.drupal-scaffold.allowed-packages '["lullabot/drainpipe-dev", "lullabot/drainpipe"]'
Expand Down Expand Up @@ -126,9 +127,11 @@ jobs:

- name: Setup Sass
run: |
ddev yarn set version classic
ddev yarn init -y
ddev yarn add file:./drainpipe/metapackages/sass --dev
ddev exec corepack disable
ddev exec npm i -g yarn@1.22.1
ddev exec 'ln -s $(npm root -g)/yarn/bin/yarn /usr/local/bin/yarn'
ddev exec yarn init -y
ddev exec yarn add file:./drainpipe/metapackages/sass --dev

- name: Compile Sass
run: ddev task sass
Expand Down Expand Up @@ -197,7 +200,6 @@ jobs:

- name: Setup Sass
run: |
ddev config --nodejs-version=21
ddev restart
ddev yarn set version berry
ddev yarn set version 4
Expand Down Expand Up @@ -271,10 +273,12 @@ jobs:

- name: Setup Sass
run: |
ddev yarn set version classic
ddev yarn init -y
ddev yarn add focus-trap@^6.7.3
ddev yarn add file:./drainpipe/metapackages/javascript --dev
ddev exec corepack disable
ddev exec npm i -g yarn@1.22.1
ddev exec 'ln -s $(npm root -g)/yarn/bin/yarn /usr/local/bin/yarn'
ddev exec yarn init -y
ddev exec yarn add focus-trap@^6.7.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this package for? Is it just an easy way to do a test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's testing whether the package import works correctly when bundling

ddev exec yarn add file:./drainpipe/metapackages/javascript --dev

- name: Compile JavaScript
run: ddev task javascript
Expand Down Expand Up @@ -344,7 +348,6 @@ jobs:

- name: Setup Sass
run: |
ddev config --nodejs-version=21
ddev restart
ddev yarn set version berry
ddev yarn set version 4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/TestPHPUnit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
uses: GuillaumeFalourd/assert-command-line-output@v2.3
with:
command_line: xmllint --xpath 'string(//testsuites/testsuite/@tests)' test_result/phpunit-functional.xml
contains: 18
contains: 6
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were previously also running the unit tests apparently

expected_result: PASSED

Test-PHPUnit-Functional-DTT:
Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:
uses: GuillaumeFalourd/assert-command-line-output@v2
with:
command_line: xmllint --xpath 'string(//testsuites/testsuite/@tests)' test_result/phpunit-functional.xml
contains: 21
contains: 9
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were previously also running the unit tests apparently

expected_result: PASSED

Test-PHPUnit-Static:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/TestTugboat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Create a Drupal project
run: composer create-project drupal/recommended-project . --ignore-platform-req=ext-gd
run: composer create-project drupal/recommended-project . --ignore-platform-reqs

- uses: actions/checkout@v4
with:
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Setup Project
run: |
ddev config --auto
ddev config --php-version "8.1"
ddev config --php-version "8.3"
ddev config --nodejs-version "18"
ddev get ddev/ddev-redis --version v1.2.0
ddev get ddev/ddev-elasticsearch --version v0.3.2
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
- name: Setup Project
run: |
ddev config --auto
ddev config --php-version "8.1"
ddev config --php-version "8.3"
ddev config --nodejs-version "16"
ddev restart
ddev composer config extra.drupal-scaffold.gitignore true
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/test-production-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ jobs:
strategy:
matrix:
php-version: [8.1, 8.2, 8.3]

include:
- php-version: 8.1
drupal-version: ":^10"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice.

- php-version: 8.2
drupal-version: ":^10"
steps:
- uses: actions/checkout@v4

Expand All @@ -37,7 +41,7 @@ jobs:
- name: Install Drupal
run: |
cd ../
composer create-project drupal/recommended-project drupal --ignore-platform-req=ext-gd
composer create-project drupal/recommended-project${{ matrix.drupal-version }} drupal --ignore-platform-reqs
cd drupal
cp ${GITHUB_WORKSPACE}/tests/fixtures.drainpipe-test-build/Taskfile.yml .
composer config extra.drupal-scaffold.gitignore true
Expand Down
2 changes: 1 addition & 1 deletion .tugboat/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
services:
php:
http: false
image: tugboatqa/php-nginx:8.1-fpm
image: tugboatqa/php-nginx:8.3-fpm
default: true

depends:
Expand Down
21 changes: 11 additions & 10 deletions drainpipe-dev/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
"php": "^8.1",
"ext-json": "*",
"composer-plugin-api": "^2.0",
"phpunit/phpunit": "^9.6.20",
"sserbin/twig-linter": "^3.1.0",
"mikey179/vfsstream": "^1.6.11",
"mockery/mockery": "^1.6.12",
"behat/mink": "^1.11.0",
"symfony/phpunit-bridge": "^6|^7",
"behat/mink-browserkit-driver": "^2.2.0",
"drupal/coder": "^8.3.24",
"lullabot/drainpipe": "*",
"mglaman/phpstan-drupal": "^1.2.11",
"mikey179/vfsstream": "^1.6.11",
"mockery/mockery": "^1.6.12",
"phpspec/prophecy-phpunit": "^2",
"phpstan/phpstan-deprecation-rules": "^1.2.0",
"phpunit/phpunit": "^9|^10",
"symfony/phpunit-bridge": "^6|^7",
"symfony/yaml": "^6|^7",
"drupal/coder": "^8.3.24",
"behat/mink-browserkit-driver": "^2.2.0",
"tijsverkoyen/convert-to-junit-xml": "^1.11.0",
"phpstan/phpstan-deprecation-rules": "^1.2.0",
"phpspec/prophecy-phpunit": "^2"
"vincentlanglet/twig-cs-fixer": "^3.0.0"
},
"require-dev": {
"composer/composer": "^2.7.7"
Expand All @@ -49,7 +49,8 @@
"[project-root]/.ddev/docker-compose.selenium.yaml": "scaffold/nightwatch/docker-compose.selenium.yaml",
"[project-root]/test/nightwatch/example.nightwatch.js": "scaffold/nightwatch/example.nightwatch.js",
"[project-root]/phpcs.xml.dist": "scaffold/phpcs.xml.dist",
"[project-root]/phpstan.neon.dist": "scaffold/phpstan.neon.dist"
"[project-root]/phpstan.neon.dist": "scaffold/phpstan.neon.dist",
"[project-root]/.twig-cs-fixer.dist.php": "scaffold/.twig-cs-fixer.dist.php"
}
}
},
Expand Down
33 changes: 13 additions & 20 deletions drainpipe-dev/bin/drainpipe-twig-linter → ...pipe-dev/scaffold/.twig-cs-fixer.dist.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);

if (PHP_SAPI !== 'cli') {
return;
}

if (is_file(__DIR__ . '/../../../autoload.php')) {
require_once __DIR__ . '/../../../autoload.php';
if (is_file(__DIR__ . '/vendor/autoload.php')) {
require_once __DIR__ . '/vendor/autoload.php';
}
else {
echo "Composer autoload file not found.\n";
Expand All @@ -20,37 +19,31 @@
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Routing\UrlGeneratorInterface;
use Drupal\Core\Theme\ThemeManagerInterface;
use Symfony\Component\Console\Application;
use Twig\Loader\ArrayLoader;
use PackageVersions\Versions;

use Sserbin\TwigLinter\StubEnvironment;
use Drupal\Core\Template\TwigExtension;
use Sserbin\TwigLinter\Command\LintCommand;

$twig = new StubEnvironment(new ArrayLoader, []);

$renderer = Mockery::mock(RendererInterface::class);
$urlGenerator = Mockery::mock(UrlGeneratorInterface::class);
$themeManager = Mockery::mock(ThemeManagerInterface::class);
$dateFormatter = Mockery::mock(DateFormatterInterface::class);
$fileUrlGenerator = Mockery::mock(FileUrlGenerator::class);

$ruleset = new TwigCsFixer\Ruleset\Ruleset();

// default standard.
$ruleset->addStandard(new TwigCsFixer\Standard\TwigCsFixer());

$config = new TwigCsFixer\Config\Config();
$config->setRuleset($ruleset);
$config->addTwigExtension(new TwigExtension($renderer, $urlGenerator, $themeManager, $dateFormatter, $fileUrlGenerator));

if (class_exists('\TwigStorybook\Twig\TwigExtension')) {
$composer_json = json_decode(file_get_contents(__DIR__ . '/../../../../composer.json'), true);
if (json_last_error()) {
throw new \RuntimeException('Could not parse composer.json');
}

$web_root = $composer_json['extra']['drupal-scaffold']['locations']['web-root'];
$twig->addExtension(new \TwigStorybook\Twig\TwigExtension(new \TwigStorybook\Service\StoryCollector(), '/../../../../' . $web_root));
$config->addExtension(new \TwigStorybook\Twig\TwigExtension(new \TwigStorybook\Service\StoryCollector(), '/../../../../' . $web_root));
}

$twig->addExtension(new TwigExtension($renderer, $urlGenerator, $themeManager, $dateFormatter, $fileUrlGenerator));

$lintCommand = new LintCommand($twig);

$app = new Application('twig-linter', (string) Versions::getVersion('sserbin/twig-linter'));
$app->add($lintCommand);
$app->setDefaultCommand('lint');
$app->run();
return $config;
35 changes: 30 additions & 5 deletions scaffold/phpunit-testtraits.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="../../../weitzman/drupal-test-traits/src/bootstrap.php"
verbose="true"
>
colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
failOnWarning="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
cacheResult="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheDirectory=".phpunit.cache">
<php>
<!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/>
Expand All @@ -31,6 +37,25 @@
<env name="DTT_BASE_URL" value="http://web"/>
<env name="DTT_MINK_DRIVER_ARGS" value='["chrome", {"browserName":"chrome","goog:chromeOptions":{"w3c": true, "args":["---no-sandbox","--ignore-certificate-errors", "--allow-insecure-localhost"]}}, "http://chrome:4444/wd/hub"]'/>
</php>
<extensions>
<!-- Functional tests HTML output logging. -->
<bootstrap class="Drupal\TestTools\Extension\HtmlLogging\HtmlOutputLogger">
<!-- The directory where the browser output will be stored. If a relative
path is specified, it will be relative to the current working directory
of the process running the PHPUnit CLI. In CI environments, this can be
overridden by the value set for the "BROWSERTEST_OUTPUT_DIRECTORY"
environment variable.
-->
<parameter name="outputDirectory" value="test_result/phpunit"/>
<!-- By default browser tests print the individual links in the test run
report. To avoid overcrowding the output in CI environments, you can
set the "verbose" parameter or the "BROWSERTEST_OUTPUT_VERBOSE"
environment variable to "false". In GitLabCI, the output is saved
anyway as an artifact that can be browsed or downloaded from Gitlab.
-->
<parameter name="verbose" value="true"/>
</bootstrap>
</extensions>
<testsuites>
<testsuite name="unit">
<directory>../../../../web/modules/custom/*/tests/src/Unit</directory>
Expand Down
Loading
Loading