Skip to content

Commit 310ec0f

Browse files
authored
Merge pull request #16 from Codeception/cleanup
chore: add github workflows
2 parents 3680bd0 + e648458 commit 310ec0f

File tree

3 files changed

+112
-16
lines changed

3 files changed

+112
-16
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: 16 additions & 16 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
/**
@@ -401,8 +402,7 @@ protected function assertInstanceOf(string $expected, $actual, string $message =
401402
* Asserts that a variable is of type array.
402403
*
403404
* @param mixed $actual
404-
*
405-
* @phpstan-assert array $actual
405+
* @phpstan-assert array<mixed> $actual
406406
*/
407407
protected function assertIsArray($actual, string $message = ''): void
408408
{
@@ -474,7 +474,7 @@ protected function assertIsInt($actual, string $message = ''): void
474474
*
475475
* @param mixed $actual
476476
*
477-
* @phpstan-assert iterable $actual
477+
* @phpstan-assert iterable<mixed> $actual
478478
*/
479479
protected function assertIsIterable($actual, string $message = ''): void
480480
{
@@ -486,7 +486,7 @@ protected function assertIsIterable($actual, string $message = ''): void
486486
*
487487
* @param mixed $actual
488488
*
489-
* @phpstan-assert !array $actual
489+
* @phpstan-assert !array<mixed> $actual
490490
*/
491491
protected function assertIsNotArray($actual, string $message = ''): void
492492
{
@@ -558,7 +558,7 @@ protected function assertIsNotInt($actual, string $message = ''): void
558558
*
559559
* @param mixed $actual
560560
*
561-
* @phpstan-assert !iterable $actual
561+
* @phpstan-assert !iterable<mixed> $actual
562562
*/
563563
protected function assertIsNotIterable($actual, string $message = ''): void
564564
{
@@ -1143,7 +1143,7 @@ protected function assertStringNotEqualsFileIgnoringCase(string $expectedFile, s
11431143
/**
11441144
* Asserts that a string does not match a given format string.
11451145
*/
1146-
protected function assertStringNotMatchesFormat(string $format, string $string, string $message = '')
1146+
protected function assertStringNotMatchesFormat(string $format, string $string, string $message = ''): void
11471147
{
11481148
trigger_error(__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 12', E_USER_DEPRECATED);
11491149
$constraint = new LogicalNot(new StringMatchesFormatDescription($format));
@@ -1153,15 +1153,14 @@ protected function assertStringNotMatchesFormat(string $format, string $string,
11531153
/**
11541154
* Asserts that a string does not match a given format string.
11551155
*/
1156-
protected function assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = '')
1156+
protected function assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = ''): void
11571157
{
11581158
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-
);
1159+
$content = file_get_contents($formatFile);
1160+
if ($content === false) {
1161+
Assert::fail(sprintf('Failed to read format file "%s"', $formatFile));
1162+
}
1163+
$constraint = new LogicalNot(new StringMatchesFormatDescription($content));
11651164
Assert::assertThat($string, $constraint, $message);
11661165
}
11671166

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

13211320
/**
13221321
* @see https://github.com/sebastianbergmann/phpunit/blob/9.6/src/Framework/Constraint/Object/ClassHasStaticAttribute.php
1322+
* @param class-string $className
13231323
*/
1324-
private static function hasStaticAttribute(string $attributeName, string $className)
1324+
private static function hasStaticAttribute(string $attributeName, string $className): bool
13251325
{
13261326
try {
13271327
$class = new \ReflectionClass($className);

0 commit comments

Comments
 (0)