Skip to content

Commit f0275e6

Browse files
committed
chore: add github workflows
1 parent 6ec0f7f commit f0275e6

File tree

3 files changed

+108
-11
lines changed

3 files changed

+108
-11
lines changed

.github/workflows/main.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
jobs:
5+
tests:
6+
runs-on: ubuntu-latest
7+
8+
strategy:
9+
matrix:
10+
php: [8.2, 8.3, 8.4]
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Setup PHP
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: ${{ matrix.php }}
20+
tools: phpstan
21+
22+
- name: Validate composer.json and composer.lock
23+
run: composer validate
24+
25+
- name: Install dependencies
26+
run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
27+
- name: Run PHPStan
28+
run: phpstan

.github/workflows/release.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Automated release
2+
on:
3+
push:
4+
branches:
5+
- master
6+
jobs:
7+
tests:
8+
runs-on: ubuntu-latest
9+
10+
strategy:
11+
matrix:
12+
php: [ 8.2, 8.3, 8.4 ]
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: ${{ matrix.php }}
22+
coverage: none
23+
24+
- name: Validate composer.json and composer.lock
25+
run: composer validate
26+
27+
- name: Install dependencies
28+
run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
29+
30+
- name: Execute Code Sniffer
31+
run: vendor/bin/phpcs
32+
33+
- name: Execute PHP Stan
34+
run: vendor/bin/phpstan
35+
36+
- name: Run test suite
37+
run: |
38+
php -S 127.0.0.1:8000 -t tests/data/app >/dev/null 2>&1 &
39+
php -S 127.0.0.1:8010 -t tests/data/rest >/dev/null 2>&1 &
40+
php vendor/bin/codecept run
41+
42+
43+
release:
44+
name: Automated release
45+
needs:
46+
- tests
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
with:
51+
fetch-depth: 0
52+
persist-credentials: false
53+
- uses: actions/setup-node@v4
54+
with:
55+
node-version: 22
56+
- run: >
57+
npx
58+
-p "@semantic-release/commit-analyzer"
59+
-p "@semantic-release/release-notes-generator"
60+
-p conventional-changelog-conventionalcommits
61+
-p semantic-release
62+
-- semantic-release
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
permissions:
66+
packages: write
67+
contents: write
68+
pull-requests: write

src/Codeception/Util/Shared/InheritedAsserts.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PHPUnit\Framework\Constraint\LogicalNot;
1111
use PHPUnit\Framework\Constraint\StringMatchesFormatDescription;
1212
use ReflectionClass;
13+
use ReflectionException;
1314

1415
trait InheritedAsserts
1516
{
@@ -49,7 +50,7 @@ protected function assertClassHasStaticAttribute(string $attributeName, string $
4950
{
5051
trigger_error(__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 10', E_USER_DEPRECATED);
5152

52-
Assert::assertTrue($this->hasStaticAttribute($attributeName, $className), $message);
53+
Assert::assertTrue(self::hasStaticAttribute($attributeName, $className), $message);
5354
}
5455

5556
/**
@@ -69,7 +70,7 @@ protected function assertClassNotHasAttribute(string $attributeName, string $cla
6970
protected function assertClassNotHasStaticAttribute(string $attributeName, string $className, string $message = ''): void
7071
{
7172
trigger_error(__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 10', E_USER_DEPRECATED);
72-
Assert::assertFalse($this->hasStaticAttribute($attributeName, $className), $message);
73+
Assert::assertFalse(self::hasStaticAttribute($attributeName, $className), $message);
7374
}
7475

7576
/**
@@ -1143,7 +1144,7 @@ protected function assertStringNotEqualsFileIgnoringCase(string $expectedFile, s
11431144
/**
11441145
* Asserts that a string does not match a given format string.
11451146
*/
1146-
protected function assertStringNotMatchesFormat(string $format, string $string, string $message = '')
1147+
protected function assertStringNotMatchesFormat(string $format, string $string, string $message = ''): void
11471148
{
11481149
trigger_error(__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 12', E_USER_DEPRECATED);
11491150
$constraint = new LogicalNot(new StringMatchesFormatDescription($format));
@@ -1153,15 +1154,14 @@ protected function assertStringNotMatchesFormat(string $format, string $string,
11531154
/**
11541155
* Asserts that a string does not match a given format string.
11551156
*/
1156-
protected function assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = '')
1157+
protected function assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = ''): void
11571158
{
11581159
trigger_error(__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 12', E_USER_DEPRECATED);
1159-
Assert::assertFileExists($formatFile);
1160-
$constraint = new LogicalNot(
1161-
new StringMatchesFormatDescription(
1162-
file_get_contents($formatFile)
1163-
)
1164-
);
1160+
$content = file_get_contents($formatFile);
1161+
if ($content === false) {
1162+
Assert::fail(sprintf('Failed to read format file "%s"', $formatFile));
1163+
}
1164+
$constraint = new LogicalNot(new StringMatchesFormatDescription($content));
11651165
Assert::assertThat($string, $constraint, $message);
11661166
}
11671167

@@ -1320,8 +1320,9 @@ protected function markTestSkipped(string $message = ''): never
13201320

13211321
/**
13221322
* @see https://github.com/sebastianbergmann/phpunit/blob/9.6/src/Framework/Constraint/Object/ClassHasStaticAttribute.php
1323+
* @param class-string $className
13231324
*/
1324-
private static function hasStaticAttribute(string $attributeName, string $className)
1325+
private static function hasStaticAttribute(string $attributeName, string $className): bool
13251326
{
13261327
try {
13271328
$class = new \ReflectionClass($className);

0 commit comments

Comments
 (0)