Skip to content

Commit 8ab2a42

Browse files
authored
Merge pull request #2 from erikaheidi/fix-ci
Fix CI tests
2 parents 3193afb + eec521a commit 8ab2a42

23 files changed

+264
-104
lines changed

.github/workflows/php.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v3
1919

20+
- name: Setup PHP 8.2
21+
uses: shivammathur/setup-php@e6f75134d35752277f093989e72e140eaa222f35
22+
with:
23+
php-version: '8.2'
24+
2025
- name: Validate composer.json and composer.lock
2126
run: composer validate --strict
2227

2328
- name: Cache Composer packages
2429
id: composer-cache
25-
uses: actions/cache@v3
30+
uses: actions/cache@v2
2631
with:
2732
path: vendor
2833
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
@@ -32,5 +37,8 @@ jobs:
3237
- name: Install dependencies
3338
run: composer install --prefer-dist --no-progress
3439

40+
- name: Check code style
41+
run: composer test:lint
42+
3543
- name: Run test suite
36-
run: ./vendor/bin/pest
44+
run: composer test:unit

composer.json

+19-3
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,31 @@
1010
}
1111
},
1212
"require": {
13-
"php": "^8.2.0",
13+
"php": "^8.2",
1414
"minicli/minicli": "^4.2",
1515
"minicli/stencil": "^0.2.1"
1616
},
1717
"require-dev": {
1818
"pestphp/pest": "^2.16",
19-
"mockery/mockery": "^1.6"
19+
"mockery/mockery": "^1.6",
20+
"laravel/pint": "^1.13"
2021
},
21-
"config": {
22+
"scripts": {
23+
"lint": [
24+
"pint"
25+
],
26+
"test:lint": [
27+
"pint --test"
28+
],
29+
"test:unit": [
30+
"pest"
31+
],
32+
"test": [
33+
"@test:lint",
34+
"@test:unit"
35+
]
36+
},
37+
"config": {
2238
"allow-plugins": {
2339
"pestphp/pest-plugin": true
2440
}

composer.lock

+83-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true">
3-
<testsuites>
4-
<testsuite name="Test Suite">
5-
<directory suffix="Test.php">./tests</directory>
6-
</testsuite>
7-
</testsuites>
8-
<coverage/>
9-
<source>
10-
<include>
11-
<directory suffix=".php">./app</directory>
12-
<directory suffix=".php">./src</directory>
13-
</include>
14-
</source>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
>
7+
<testsuites>
8+
<testsuite name="Test Suite">
9+
<directory suffix="Test.php">./tests</directory>
10+
</testsuite>
11+
</testsuites>
12+
<coverage processUncoveredFiles="true">
13+
<include>
14+
<directory suffix=".php">./app</directory>
15+
<directory suffix=".php">./src</directory>
16+
</include>
17+
</coverage>
1518
</phpunit>

pint.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"preset": "psr12",
3+
"rules": {
4+
"align_multiline_comment": true,
5+
"array_indentation": true,
6+
"array_syntax": true,
7+
"blank_line_after_namespace": true,
8+
"blank_line_after_opening_tag": true,
9+
"combine_consecutive_issets": true,
10+
"combine_consecutive_unsets": true,
11+
"concat_space": true,
12+
"declare_parentheses": true,
13+
"declare_strict_types": true,
14+
"explicit_string_variable": true,
15+
"fully_qualified_strict_types": true,
16+
"global_namespace_import": {
17+
"import_classes": true,
18+
"import_constants": true,
19+
"import_functions": true
20+
},
21+
"is_null": true,
22+
"lambda_not_used_import": true,
23+
"logical_operators": true,
24+
"mb_str_functions": true,
25+
"method_chaining_indentation": true,
26+
"modernize_strpos": true,
27+
"new_with_braces": true,
28+
"no_empty_comment": true,
29+
"not_operator_with_space": true,
30+
"ordered_traits": true,
31+
"simplified_if_return": true,
32+
"strict_comparison": true,
33+
"ternary_to_null_coalescing": true,
34+
"trim_array_spaces": true,
35+
"use_arrow_functions": true,
36+
"void_return": true,
37+
"yoda_style": true
38+
}
39+
}

src/Changelog.php

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autodocs;
46

57
class Changelog
@@ -20,19 +22,19 @@ public function capture(): void
2022

2123
public function makeDiff(?string $monitoredPath = null): void
2224
{
23-
if (!$monitoredPath) {
25+
if ( ! $monitoredPath) {
2426
$monitoredPath = $this->monitoredPath;
2527
}
2628
$previous = $this->monitoredFiles;
2729
$this->registerFiles($monitoredPath);
2830

2931
foreach ($this->monitoredFiles as $index => $file) {
30-
if (!array_key_exists($index, $previous)) {
32+
if ( ! array_key_exists($index, $previous)) {
3133
$this->newFiles[] = $file;
3234
continue;
3335
}
3436

35-
if ($previous[$index]['md5'] != $file['md5']) {
37+
if ($previous[$index]['md5'] !== $file['md5']) {
3638
$this->changedFiles[] = $file;
3739
}
3840
}
@@ -56,9 +58,10 @@ public function hasChanges(): bool
5658
public function getChangesSummary(): string
5759
{
5860
if ($this->hasChanges()) {
59-
return sprintf("%s files added and %s files changed.",
60-
count($this->newFiles),
61-
count($this->changedFiles)
61+
return sprintf(
62+
"%s files added and %s files changed.",
63+
count($this->newFiles),
64+
count($this->changedFiles)
6265
);
6366
}
6467

@@ -67,7 +70,7 @@ public function getChangesSummary(): string
6770

6871
public function registerFiles(string $monitoredPath): void
6972
{
70-
foreach (glob($monitoredPath . '/*') as $filename) {
73+
foreach (glob($monitoredPath.'/*') as $filename) {
7174
if (is_dir($filename)) {
7275
$this->registerFiles($filename);
7376
}

src/DataFeed/DataFeedInterface.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autodocs\DataFeed;
46

57
interface DataFeedInterface
68
{
79
public function load(string $data): void;
810
public function save(string $path): void;
9-
}
11+
}

0 commit comments

Comments
 (0)