Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
tannguyen04 authored and AlexSkrypnyk committed Jul 4, 2024
1 parent 0516c7f commit 97c77a4
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 22 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/test-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ on:
branches:
- main
- 'feature/**'
workflow_dispatch:
inputs:
enable_upterm:
description: 'Set "true" to enable upterm session.'
required: true

jobs:
test-php:
runs-on: ubuntu-latest

strategy:
matrix:
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.2', '8.3']

steps:
- name: Checkout code
Expand All @@ -31,26 +36,39 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: pcov
ini-values: pcov.directory=.

- name: Install dependencies
run: composer install

- name: Check coding standards
run: composer lint
continue-on-error: ${{ vars.CI_LINT_IGNORE_FAILURE == '1' }}

- name: Run tests
run: XDEBUG_MODE=coverage composer test
run: composer test-coverage
continue-on-error: ${{ vars.CI_TEST_IGNORE_FAILURE == '1' }}

- name: Upload coverage report as artifact
uses: actions/upload-artifact@v4
with:
name: ${{github.job}}-code-coverage-report-${{ matrix.php-versions }}
path: ./.coverage-html
if-no-files-found: error

- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
if: ${{ env.CODECOV_TOKEN != '' }}
with:
files: ./cobertura.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Setup upterm session
if: ${{ !cancelled() && github.event.inputs.enable_upterm == 'true' }}
uses: lhotari/action-upterm@v1
with:
wait-timeout-minutes: 5
12 changes: 7 additions & 5 deletions CsvTable.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace AlexSkrypnyk\CsvTable;

Expand Down Expand Up @@ -43,10 +43,12 @@ class CsvTable {
* The character used to escape special characters in the CSV data.
* Defaults to '\\'.
*/
public function __construct(protected ?string $csvString = NULL,
protected string $csvSeparator = ',',
protected string $csvEnclosure = '"',
protected string $csvEscape = '\\') {
public function __construct(
protected ?string $csvString = NULL,
protected string $csvSeparator = ',',
protected string $csvEnclosure = '"',
protected string $csvEscape = '\\',
) {
$this->parse();
}

Expand Down
2 changes: 1 addition & 1 deletion Markdown.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace AlexSkrypnyk\CsvTable;

Expand Down
3 changes: 3 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Security Policy

Report security issues at alex@drevops.com
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"source": "https://github.com/AlexSkrypnyk/CsvTable"
},
"require": {
"php": ">=8.1"
"php": ">=8.2"
},
"require-dev": {
"drupal/coder": "^8.3",
Expand All @@ -43,6 +43,7 @@
"rector --dry-run"
],
"lint:fix": "phpcbf",
"test": "if [ \"${XDEBUG_MODE}\" = 'coverage' ]; then phpunit; else phpunit --no-coverage; fi"
"test": "phpunit --no-coverage",
"test-coverage": "phpunit"
}
}
4 changes: 3 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
<ruleset name="custom">
<description>Custom PHPCS standard.</description>

<!-- Coding standard. -->
<!-- Using Drupal coding standard as a base-fix. -->
<rule ref="Drupal"/>
<!-- Checks that the strict_types has been declared. -->
<rule ref="Generic.PHP.RequireStrictTypes" />

<!-- Show sniff codes in all reports -->
<arg value="s"/>
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<file>CsvTable.php</file>
<file>Markdown.php</file>
</include>
<exclude>
<directory>tests</directory>
</exclude>
</source>

<coverage includeUncoveredFiles="true"
Expand Down
6 changes: 4 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,24 @@
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
use Rector\Set\ValueObject\SetList;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/**',
]);

$rectorConfig->sets([
SetList::PHP_80,
SetList::PHP_81,
SetList::PHP_82,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::DEAD_CODE,
SetList::INSTANCEOF,
SetList::TYPE_DECLARATION,
]);

$rectorConfig->rule(DeclareStrictTypesRector::class);

$rectorConfig->skip([
// Rules added by Rector's rule sets.
ArraySpreadInsteadOfArrayMergeRector::class,
Expand Down
7 changes: 2 additions & 5 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"automerge": true,
"dependencyDashboard": true,
"extends": [
"config:base"
]
"dependencyDashboard": true
}
2 changes: 1 addition & 1 deletion tests/CsvTableUnitTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

use AlexSkrypnyk\CsvTable\CsvTable;
use PHPUnit\Framework\TestCase;
Expand Down
2 changes: 1 addition & 1 deletion tests/MarkdownUnitTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

use AlexSkrypnyk\CsvTable\CsvTable;
use AlexSkrypnyk\CsvTable\Markdown;
Expand Down

0 comments on commit 97c77a4

Please sign in to comment.