Skip to content

Commit 507444c

Browse files
committed
[ci] windows tests on GitHub actions
1 parent fc8038d commit 507444c

File tree

7 files changed

+174
-20
lines changed

7 files changed

+174
-20
lines changed

.github/workflows/ci.yaml renamed to .github/workflows/ci-linux.yaml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "CI"
1+
name: "CI Linux"
22

33
on:
44
pull_request:
@@ -26,34 +26,34 @@ jobs:
2626

2727
steps:
2828
-
29-
name: "Checkout code"
29+
name: Checkout code
3030
uses: "actions/checkout@v3"
3131

3232
-
33-
name: "Install PHP"
33+
name: Install PHP
3434
uses: "shivammathur/setup-php@v2"
3535
with:
3636
coverage: "none"
3737
php-version: "${{ matrix.php-version }}"
3838

3939
-
40-
name: "Validate composer.json"
40+
name: Validate composer.json
4141
run: "composer validate --strict --no-check-lock"
4242

4343
-
44-
name: "Composer install"
44+
name: Composer install
4545
uses: "ramsey/composer-install@v2"
4646
with:
4747
composer-options: "--no-scripts"
4848

4949
-
50-
name: "Composer install php-cs-fixer"
50+
name: Composer install php-cs-fixer
5151
uses: "ramsey/composer-install@v2"
5252
with:
5353
composer-options: "--no-scripts --working-dir=tools/php-cs-fixer"
5454

5555
-
56-
name: "Run friendsofphp/php-cs-fixer"
56+
name: Run PHP-CS-Fixer
5757
run: "tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run --diff"
5858

5959
test:
@@ -99,42 +99,42 @@ jobs:
9999
dependency-versions: 'highest'
100100

101101
steps:
102-
- name: "Checkout code"
102+
- name: Checkout code
103103
uses: actions/checkout@v3
104104

105-
- name: "Install PHP with extensions"
105+
- name: Install PHP with extensions
106106
uses: shivammathur/setup-php@v2
107107
with:
108108
coverage: "none"
109109
php-version: ${{ matrix.php-version }}
110110

111-
- name: "Add PHPUnit matcher"
111+
- name: Add PHPUnit matcher
112112
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
113113

114-
- name: "Composer install"
114+
- name: Composer install
115115
uses: "ramsey/composer-install@v2"
116116
with:
117117
dependency-versions: "${{ matrix.dependency-versions }}"
118118

119-
- name: "Composer install php-cs-fixer"
119+
- name: Composer install php-cs-fixer
120120
uses: "ramsey/composer-install@v2"
121121
with:
122122
composer-options: "--no-scripts --working-dir=tools/php-cs-fixer"
123123

124-
- name: "Composer install twigcs"
124+
- name: Composer install twigcs
125125
uses: "ramsey/composer-install@v2"
126126
with:
127127
composer-options: "--no-scripts --working-dir=tools/twigcs"
128128

129-
- name: "Install PHPUnit"
129+
- name: Install PHPUnit
130130
run: |
131131
if [[ ${{ matrix.dependency_versions == 'lowest' }} ]]; then
132132
echo "SYMFONY_PHPUNIT_REQUIRE=nikic/php-parser:^4.18" >> $GITHUB_ENV
133133
fi
134134
vendor/bin/simple-phpunit install
135135
136-
- name: "PHPUnit version"
136+
- name: PHPUnit version
137137
run: vendor/bin/simple-phpunit --version
138138

139-
- name: "Run tests"
139+
- name: Run tests
140140
run: vendor/bin/simple-phpunit ${{ env.PHPUNIT_FLAGS }}

.github/workflows/ci-windows.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: "CI Windows"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- 'main'
8+
schedule:
9+
- cron: '0 0 * * *'
10+
11+
env:
12+
PHPUNIT_FLAGS: "-v"
13+
SYMFONY_PHPUNIT_DIR: "$HOME/symfony-bridge/.phpunit"
14+
MAKER_SKIP_MERCURE_TEST: 1
15+
MAKER_SKIP_PANTHER_TEST: 1
16+
MAKER_DISABLE_FILE_LINKS: 1
17+
MAKER_ALLOW_DEV_DEPS_IN_APP: 0
18+
SYMFONY_VERSION: '7.0.x-dev'
19+
20+
jobs:
21+
tests:
22+
name: Testing on Windows
23+
runs-on: [windows-latest]
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
php-versions: [8.2]
28+
dependency-versions: ['highest']
29+
steps:
30+
# This is needed in Windows, otherwise assertions comparing fixtures and generated code will fail.
31+
- name: Use INPUT for autocrlf in Git Config
32+
run: git config --global core.autocrlf input
33+
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: Setup SQLite For Entity Regen Tests
38+
run: |
39+
choco install sqlite --params "/NoTools"
40+
41+
- name: Setup PHP
42+
uses: shivammathur/setup-php@v2
43+
with:
44+
php-version: ${{ matrix.php-versions }}
45+
extensions: pdo, pdo_sqlite
46+
47+
- name: Composer Install
48+
uses: "ramsey/composer-install@v2"
49+
with:
50+
dependency-versions: "${{ matrix.dependency-versions }}"
51+
52+
- name: Composer install php-cs-fixer
53+
uses: "ramsey/composer-install@v2"
54+
with:
55+
composer-options: "--no-scripts --working-dir=tools/php-cs-fixer"
56+
57+
- name: Composer install twigcs
58+
uses: "ramsey/composer-install@v2"
59+
with:
60+
composer-options: "--no-scripts --working-dir=tools/twigcs"
61+
62+
- name: Install PHPUnit
63+
run: |
64+
vendor/bin/simple-phpunit install
65+
66+
- name: PHPUnit Version
67+
run: vendor/bin/simple-phpunit --version
68+
69+
- name: Run Tests
70+
run: vendor/bin/simple-phpunit ${{ env.PHPUNIT_FLAGS }}

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
1919
<env name="SYMFONY_PHPUNIT_VERSION" value="9.6" />
2020
<env name="MAKER_SKIP_MERCURE_TEST" value="false"/>
21+
<env name="MAKER_SKIP_PANTHER_TEST" value="false" />
2122
</php>
2223

2324
<testsuites>

src/Test/MakerTestEnvironment.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*/
2323
final class MakerTestEnvironment
2424
{
25+
public const GENERATED_FILES_REGEX = '#(?:created|updated):\s(?:.*\\\\)*(.*\.[a-z]{3,4}).*(?:\\\\n)?#ui';
26+
2527
private Filesystem $fs;
2628
private bool|string $rootPath;
2729
private string $cachePath;
@@ -213,9 +215,9 @@ public function getGeneratedFilesFromOutputText(): array
213215

214216
$matches = [];
215217

216-
preg_match_all('#(created|updated): (]8;;[^]*\\\)?(.*?)(]8;;\\\)?\n#iu', $output, $matches, \PREG_PATTERN_ORDER);
218+
preg_match_all(self::GENERATED_FILES_REGEX, $output, $matches, \PREG_PATTERN_ORDER);
217219

218-
return array_map('trim', $matches[3]);
220+
return array_map('trim', $matches[1]);
219221
}
220222

221223
public function fileExists(string $file): bool

tests/Maker/MakeFunctionalTestTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Bundle\MakerBundle\Maker\MakeFunctionalTest;
1515
use Symfony\Bundle\MakerBundle\Test\MakerTestCase;
16+
use Symfony\Bundle\MakerBundle\Test\MakerTestDetails;
1617
use Symfony\Bundle\MakerBundle\Test\MakerTestRunner;
1718

1819
/**
@@ -27,7 +28,7 @@ protected function getMakerClass(): string
2728

2829
public function getTestDetails(): \Generator
2930
{
30-
yield 'it_generates_test_with_panther' => [$this->createMakerTest()
31+
yield 'it_generates_test_with_panther' => [$this->getPantherTest()
3132
->addExtraDependencies('panther')
3233
->run(function (MakerTestRunner $runner) {
3334
$runner->copy(
@@ -48,4 +49,13 @@ public function getTestDetails(): \Generator
4849
}),
4950
];
5051
}
52+
53+
protected function getPantherTest(): MakerTestDetails
54+
{
55+
return $this->createMakerTest()
56+
->skipTest(
57+
message: 'Panther test skipped - MAKER_SKIP_PANTHER_TEST set to TRUE.',
58+
skipped: getenv('MAKER_SKIP_PANTHER_TEST')
59+
);
60+
}
5161
}

tests/Maker/MakeTestTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Bundle\MakerBundle\Maker\MakeTest;
1515
use Symfony\Bundle\MakerBundle\Test\MakerTestCase;
16+
use Symfony\Bundle\MakerBundle\Test\MakerTestDetails;
1617
use Symfony\Bundle\MakerBundle\Test\MakerTestRunner;
1718

1819
class MakeTestTest extends MakerTestCase
@@ -79,7 +80,7 @@ public function getTestDetails(): \Generator
7980
}),
8081
];
8182

82-
yield 'it_makes_PantherTestCase_type' => [$this->createMakerTest()
83+
yield 'it_makes_PantherTestCase_type' => [$this->getPantherTest()
8384
->addExtraDependencies('panther')
8485
->run(function (MakerTestRunner $runner) {
8586
$runner->copy(
@@ -103,4 +104,13 @@ public function getTestDetails(): \Generator
103104
}),
104105
];
105106
}
107+
108+
protected function getPantherTest(): MakerTestDetails
109+
{
110+
return $this->createMakerTest()
111+
->skipTest(
112+
message: 'Panther test skipped - MAKER_SKIP_PANTHER_TEST set to TRUE.',
113+
skipped: getenv('MAKER_SKIP_PANTHER_TEST')
114+
);
115+
}
106116
}

tests/RegexTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony MakerBundle package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\MakerBundle\Tests;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bundle\MakerBundle\Test\MakerTestEnvironment;
16+
17+
class RegexTest extends TestCase
18+
{
19+
/** @dataProvider regexDataProvider */
20+
public function testRegex(string $data, array $expectedResult): void
21+
{
22+
$result = [];
23+
24+
preg_match_all(MakerTestEnvironment::GENERATED_FILES_REGEX, $data, $result, \PREG_PATTERN_ORDER);
25+
26+
self::assertSame($expectedResult, $result[1]);
27+
}
28+
29+
public function regexDataProvider(): \Generator
30+
{
31+
yield 'Created Prefix' => ['created: test/something.php', ['test/something.php']];
32+
yield 'Updated Prefix' => ['updated: test/something.php', ['test/something.php']];
33+
yield 'Twig file' => ['created: test/something.html.twig', ['test/something.html.twig']];
34+
yield 'Config file (no dir)' => ['updated: service.yaml', ['service.yaml']];
35+
yield 'Line Char + 2 dir' => ['\n success\ncreated: test/somewhere/else.php\n', ['test/somewhere/else.php']];
36+
yield 'Multiline' => [<<< 'EOT'
37+
Congrats!\n
38+
Created: some/file.php\n
39+
Updated: another/config.yaml\n
40+
\n
41+
EOT,
42+
['some/file.php', 'another/config.yaml'],
43+
];
44+
yield 'Linux CI Results' => [<<< 'EOT'
45+
Bundled PHP-CS-Fixer & Bundled PHP-CS-Fixer Configuration\n
46+
\n
47+
created: \e]8;;file:///home/runner/work/maker-bundle/maker-bundle/tests/tmp/cache/maker_app_40cd750bba9870f18aada2478b24840a_6.4.x-dev/tests/FooBarTest.php#L1\e\tests/FooBarTest.php\e]8;;\e\\n
48+
\n
49+
EOT,
50+
['tests/FooBarTest.php'],
51+
];
52+
yield 'Windows CI Results' => [<<< 'EOT'
53+
Bundled PHP-CS-Fixer & Bundled PHP-CS-Fixer Configuration\r\n
54+
\r\n
55+
created: tests/FooBarTest.php\r\n
56+
\r\n
57+
EOT,
58+
['tests/FooBarTest.php'],
59+
];
60+
}
61+
}

0 commit comments

Comments
 (0)