Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 83e5c0c

Browse files
Slavaslavcodev
andauthored
Migrate to PHP 7.3, php-cs-fixer v3 and GHA (#40)
* Rename config * Upgrade php-csfixer upto v3 * Add scripts * Fix cs * Remove Makefile * Migrate from travis to GHA * Require PHP v7.3 * Update CHANGELOG * Fix cs * Fix strict types issues * Remove php 7.2 from CI * Allow 8.0 in composer * Fix ocular script in GHA * Fix badge Co-authored-by: Veaceslav Medvedev <slavcopost@gmail.com>
1 parent 90f8bc3 commit 83e5c0c

27 files changed

Lines changed: 258 additions & 237 deletions

.github/CODEOWNERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Code Owners settings
2+
# See: https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
3+
4+
# As soon as a PR is added or a project is published, these teams will be invited for review.
5+
* @Rebilly/php

.github/workflows/workflow.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Tests
2+
on: [pull_request]
3+
4+
jobs:
5+
unit-tests:
6+
runs-on: ubuntu-latest
7+
8+
strategy:
9+
matrix:
10+
php-version: ['7.3', '7.4', '8.0']
11+
12+
env:
13+
EXECUTE_COVERAGE: ${{ matrix.php-version == '7.3' }}
14+
CLOVER_PATH: "clover.xml"
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Setup PHP
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: ${{ matrix.php-version }}
23+
extensions: mbstring, intl, curl, json
24+
25+
- name: Get Composer Cache Directory
26+
id: composer-cache
27+
run: |
28+
echo "::set-output name=dir::$(composer config cache-files-dir)"
29+
- uses: actions/cache@v2
30+
with:
31+
path: ${{ steps.composer-cache.outputs.dir }}
32+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-composer-
35+
- name: Install dependencies
36+
run: composer install -n --no-suggest
37+
38+
- name: Run PhpUnit with coverage
39+
if: env.EXECUTE_COVERAGE == 'true'
40+
run: composer test-unit -- --testdox --colors=always --coverage-clover ${{ env.CLOVER_PATH }}
41+
42+
- name: Run PhpUnit
43+
if: env.EXECUTE_COVERAGE != 'true'
44+
run: composer test-unit -- --testdox --colors=always
45+
46+
- name: Coverage monitor
47+
if: env.EXECUTE_COVERAGE == 'true'
48+
uses: slavcodev/coverage-monitor-action@v1
49+
with:
50+
github_token: ${{ secrets.GITHUB_TOKEN }}
51+
clover_file: ${{ env.CLOVER_PATH }}
52+
threshold_alert: 0
53+
threshold_warning: 50
54+
55+
- name: Upload coverage
56+
if: env.EXECUTE_COVERAGE == 'true'
57+
run: composer upload-coverage -- --format=php-clover ${{ env.CLOVER_PATH }} --repository=g/$GITHUB_REPOSITORY --parent=$GITHUB_BASE_REF
58+
59+
lint:
60+
runs-on: ubuntu-latest
61+
62+
strategy:
63+
max-parallel: 1
64+
matrix:
65+
php-version: ['7.3']
66+
67+
steps:
68+
- uses: actions/checkout@v2
69+
70+
- name: Setup PHP
71+
uses: shivammathur/setup-php@v2
72+
with:
73+
php-version: ${{ matrix.php-version }}
74+
extensions: mbstring, intl, curl, json
75+
76+
- name: Get Composer Cache Directory
77+
id: composer-cache
78+
run: |
79+
echo "::set-output name=dir::$(composer config cache-files-dir)"
80+
- uses: actions/cache@v2
81+
with:
82+
path: ${{ steps.composer-cache.outputs.dir }}
83+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
84+
restore-keys: |
85+
${{ runner.os }}-composer-
86+
- name: Install dependencies
87+
run: composer install -n --no-suggest
88+
89+
- name: Lint code
90+
run: composer test-cs -- -vv

.php-cs-fixer.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
// https://cs.symfony.com/doc/rules/
6+
// https://cs.symfony.com/doc/ruleSets/
7+
$rules = [
8+
'@PhpCsFixer' => true,
9+
'@PhpCsFixer:risky' => true,
10+
'@PHP74Migration' => true,
11+
'@PHP74Migration:risky' => true,
12+
'@PHPUnit84Migration:risky' => true,
13+
'concat_space' => [
14+
'spacing' => 'one',
15+
],
16+
'increment_style' => ['style' => 'pre'],
17+
'multiline_whitespace_before_semicolons' => [
18+
'strategy' => 'no_multi_line',
19+
],
20+
'single_line_comment_style' => true,
21+
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
22+
'yoda_style' => [
23+
'equal' => false,
24+
'identical' => false,
25+
'less_and_greater' => null,
26+
],
27+
// Environment not ready to use short functions.
28+
'use_arrow_functions' => false,
29+
'phpdoc_align' => false,
30+
// Make function invocation consistent, require all to be with leading `\`.
31+
'native_function_invocation' => ['include' => ['@all'], 'scope' => 'namespaced', 'strict' => true],
32+
'global_namespace_import' => ['import_classes' => true, 'import_functions' => true, 'import_constants' => true],
33+
// Force PSR-12 standard.
34+
'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['class', 'function', 'const']],
35+
'php_unit_test_class_requires_covers' => false,
36+
'php_unit_internal_class' => false,
37+
'blank_line_before_statement' => ['statements' => ['declare', 'include', 'include_once', 'require', 'require_once', 'return']],
38+
'php_unit_test_annotation' => ['style' => 'annotation'],
39+
];
40+
41+
return (new PhpCsFixer\Config())
42+
->setFinder(
43+
PhpCsFixer\Finder::create()
44+
->exclude('vendor')
45+
->in(__DIR__),
46+
)
47+
->setRules($rules)
48+
->setRiskyAllowed(true)
49+
->setUsingCache(true);

.php_cs

Lines changed: 0 additions & 163 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file
33
using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6+
## [0.9.0] 2021-08-12
7+
8+
### Changed
9+
10+
- Updated minimum requirements for `php` to version `7.3`
11+
612
## [0.8.0] 2019-06-16
713

814
### Changed

Makefile

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)