Skip to content

Commit a874a2c

Browse files
authored
test(ci): Update PHP versions and fix workflow tests (#54)
- Update PHP versions in CI workflows from 8.1-8.3 to 8.2-8.4. - Remove the unnecessary scheduled CI job. - Adjust `TraitGithubActions` to validate the updated workflow configuration. - Fix badge line formatting in `TraitReadme` test.
1 parent 50ffb11 commit a874a2c

File tree

3 files changed

+11
-31
lines changed

3 files changed

+11
-31
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ on:
1919
push:
2020
branches:
2121
- 'master'
22-
schedule:
23-
- cron: '7 */8 * * *'
2422

2523
env:
2624
COLUMNS: 120
@@ -34,7 +32,7 @@ jobs:
3432
JBZOO_COMPOSER_UPDATE_FLAGS: ${{ matrix.composer_flags }}
3533
strategy:
3634
matrix:
37-
php-version: [ 8.1, 8.2, 8.3 ]
35+
php-version: [ 8.2, 8.3, 8.4 ]
3836
coverage: [ xdebug, none ]
3937
composer_flags: [ "--prefer-lowest", "" ]
4038
steps:
@@ -65,7 +63,7 @@ jobs:
6563
run: make report-coveralls --no-print-directory || true
6664

6765
- name: Upload Artifacts
68-
uses: actions/upload-artifact@v3
66+
uses: actions/upload-artifact@v4
6967
continue-on-error: true
7068
with:
7169
name: PHPUnit - ${{ matrix.php-version }} - ${{ matrix.coverage }}
@@ -77,7 +75,7 @@ jobs:
7775
runs-on: ubuntu-latest
7876
strategy:
7977
matrix:
80-
php-version: [ 8.1, 8.2, 8.3 ]
78+
php-version: [ 8.2, 8.3, 8.4 ]
8179
steps:
8280
- name: Checkout code
8381
uses: actions/checkout@v3
@@ -99,7 +97,7 @@ jobs:
9997
run: make codestyle --no-print-directory
10098

10199
- name: Upload Artifacts
102-
uses: actions/upload-artifact@v3
100+
uses: actions/upload-artifact@v4
103101
continue-on-error: true
104102
with:
105103
name: Linters - ${{ matrix.php-version }}
@@ -111,7 +109,7 @@ jobs:
111109
runs-on: ubuntu-latest
112110
strategy:
113111
matrix:
114-
php-version: [ 8.1, 8.2, 8.3 ]
112+
php-version: [ 8.2, 8.3, 8.4 ]
115113
steps:
116114
- name: Checkout code
117115
uses: actions/checkout@v3
@@ -133,7 +131,7 @@ jobs:
133131
run: make report-all --no-print-directory
134132

135133
- name: Upload Artifacts
136-
uses: actions/upload-artifact@v3
134+
uses: actions/upload-artifact@v4
137135
continue-on-error: true
138136
with:
139137
name: Reports - ${{ matrix.php-version }}

src/PHPUnit/TraitGithubActions.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@
1919
use function JBZoo\Data\yml;
2020
use function JBZoo\PHPUnit\isSame;
2121

22-
/**
23-
* @phan-file-suppress PhanUndeclaredProperty
24-
*/
2522
trait TraitGithubActions
2623
{
27-
public function testGithubActionsWorkflow(): void
24+
public static function testGithubActionsWorkflow(): void
2825
{
2926
$mailYmlPath = PROJECT_ROOT . '/.github/workflows/main.yml';
3027
$actual = yml($mailYmlPath)->getArrayCopy();
@@ -42,7 +39,6 @@ public function testGithubActionsWorkflow(): void
4239
'on' => [
4340
'pull_request' => ['branches' => ['*']],
4441
'push' => ['branches' => ['master']],
45-
'schedule' => [['cron' => $this->getScheduleMinute()]],
4642
],
4743

4844
'jobs' => [
@@ -128,11 +124,6 @@ public function testGithubActionsWorkflow(): void
128124
}
129125
}
130126

131-
protected function getScheduleMinute(): string
132-
{
133-
return self::stringToNumber($this->packageName, 59) . ' */8 * * *';
134-
}
135-
136127
protected static function stepBeforeTests(): ?array
137128
{
138129
return null;
@@ -159,7 +150,7 @@ protected static function checkoutStep(string $jobName): array
159150

160151
protected static function phpVersions(): array
161152
{
162-
return [8.1, 8.2, 8.3];
153+
return [8.2, 8.3, 8.4];
163154
}
164155

165156
/**
@@ -200,7 +191,7 @@ protected static function uploadArtifactsStep(string $stepName): array
200191
{
201192
return [
202193
'name' => 'Upload Artifacts',
203-
'uses' => 'actions/upload-artifact@v3',
194+
'uses' => 'actions/upload-artifact@v4',
204195
'continue-on-error' => true,
205196
'with' => ['name' => $stepName, 'path' => 'build/'],
206197
];
@@ -225,13 +216,4 @@ private static function toYaml(array $data): string
225216
{
226217
return (string)yml(self::normalizeData($data));
227218
}
228-
229-
private static function stringToNumber(string $string, int $maxNumber): int
230-
{
231-
$hash = \md5($string);
232-
$substr = \substr($hash, 0, 8);
233-
$number = \hexdec($substr);
234-
235-
return $number % ($maxNumber + 1);
236-
}
237219
}

src/PHPUnit/TraitReadme.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ public function testReadmeHeader(): void
120120
}
121121
}
122122

123-
$expectedBadgeLine = \implode("\n", [
123+
$expectedBadgeLine = \str_replace(" \n", "\n", \implode("\n", [
124124
$this->getTitle(),
125125
'',
126126
\trim(\implode('', \array_filter($expectedBadges))),
127127
'',
128128
'',
129-
]);
129+
]));
130130

131131
isFileContains($expectedBadgeLine, PROJECT_ROOT . '/README.md');
132132
}

0 commit comments

Comments
 (0)