Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI tests #2

Merged
merged 8 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup PHP 8.2
uses: shivammathur/setup-php@e6f75134d35752277f093989e72e140eaa222f35
with:
php-version: '8.2'

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
Expand All @@ -32,5 +37,8 @@ jobs:
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Check code style
run: composer test:lint

- name: Run test suite
run: ./vendor/bin/pest
run: composer test:unit
22 changes: 19 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,31 @@
}
},
"require": {
"php": "^8.2.0",
"php": "^8.2",
"minicli/minicli": "^4.2",
"minicli/stencil": "^0.2.1"
},
"require-dev": {
"pestphp/pest": "^2.16",
"mockery/mockery": "^1.6"
"mockery/mockery": "^1.6",
"laravel/pint": "^1.13"
},
"config": {
"scripts": {
"lint": [
"pint"
],
"test:lint": [
"pint --test"
],
"test:unit": [
"pest"
],
"test": [
"@test:lint",
"@test:unit"
]
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
}
Expand Down
100 changes: 83 additions & 17 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 16 additions & 13 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<testsuites>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<coverage/>
<source>
<include>
<directory suffix=".php">./app</directory>
<directory suffix=".php">./src</directory>
</include>
</source>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
<directory suffix=".php">./src</directory>
</include>
</coverage>
</phpunit>
39 changes: 39 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"preset": "psr12",
"rules": {
"align_multiline_comment": true,
"array_indentation": true,
"array_syntax": true,
"blank_line_after_namespace": true,
"blank_line_after_opening_tag": true,
"combine_consecutive_issets": true,
"combine_consecutive_unsets": true,
"concat_space": true,
"declare_parentheses": true,
"declare_strict_types": true,
"explicit_string_variable": true,
"fully_qualified_strict_types": true,
"global_namespace_import": {
"import_classes": true,
"import_constants": true,
"import_functions": true
},
"is_null": true,
"lambda_not_used_import": true,
"logical_operators": true,
"mb_str_functions": true,
"method_chaining_indentation": true,
"modernize_strpos": true,
"new_with_braces": true,
"no_empty_comment": true,
"not_operator_with_space": true,
"ordered_traits": true,
"simplified_if_return": true,
"strict_comparison": true,
"ternary_to_null_coalescing": true,
"trim_array_spaces": true,
"use_arrow_functions": true,
"void_return": true,
"yoda_style": true
}
}
17 changes: 10 additions & 7 deletions src/Changelog.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Autodocs;

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

public function makeDiff(?string $monitoredPath = null): void
{
if (!$monitoredPath) {
if ( ! $monitoredPath) {
$monitoredPath = $this->monitoredPath;
}
$previous = $this->monitoredFiles;
$this->registerFiles($monitoredPath);

foreach ($this->monitoredFiles as $index => $file) {
if (!array_key_exists($index, $previous)) {
if ( ! array_key_exists($index, $previous)) {
$this->newFiles[] = $file;
continue;
}

if ($previous[$index]['md5'] != $file['md5']) {
if ($previous[$index]['md5'] !== $file['md5']) {
$this->changedFiles[] = $file;
}
}
Expand All @@ -56,9 +58,10 @@ public function hasChanges(): bool
public function getChangesSummary(): string
{
if ($this->hasChanges()) {
return sprintf("%s files added and %s files changed.",
count($this->newFiles),
count($this->changedFiles)
return sprintf(
"%s files added and %s files changed.",
count($this->newFiles),
count($this->changedFiles)
);
}

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

public function registerFiles(string $monitoredPath): void
{
foreach (glob($monitoredPath . '/*') as $filename) {
foreach (glob($monitoredPath.'/*') as $filename) {
if (is_dir($filename)) {
$this->registerFiles($filename);
}
Expand Down
4 changes: 3 additions & 1 deletion src/DataFeed/DataFeedInterface.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);

namespace Autodocs\DataFeed;

interface DataFeedInterface
{
public function load(string $data): void;
public function save(string $path): void;
}
}
Loading
Loading