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

Improve CI #2

Merged
merged 1 commit into from
Nov 7, 2024
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
46 changes: 17 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
on:
- pull_request
- push

name: build

on:
pull_request:
push:
branches:
- master

jobs:
tests:
name: PHP ${{ matrix.php }}-${{ matrix.os }}
Expand All @@ -17,15 +19,14 @@ jobs:
- windows-latest

php:
- 8.0
- 8.1
- 8.2
- 8.3

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install PHP with extensions.
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
env:
update: true
Expand All @@ -35,27 +36,14 @@ jobs:
coverage: xdebug
tools: composer:v2

- name: Determine composer cache directory on Linux.
if: matrix.os == 'ubuntu-latest'
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
- name: Install Composer dependencies
uses: ramsey/composer-install@v3

- name: Determine composer cache directory on Windows.
if: matrix.os == 'windows-latest'
run: echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Run tests with PHPUnit
run: vendor/bin/phpunit --colors=always --coverage-clover=coverage.xml

- name: Cache dependencies installed with composer.
uses: actions/cache@v3
- name: Upload coverage to Coveralls
if: matrix.os == 'ubuntu-latest'
uses: coverallsapp/github-action@v2
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-

- name: Update composer.
run: composer self-update

- name: Install dependencies with composer.
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run tests with phpunit.
run: vendor/bin/phpunit --colors=always
file: ./coverage.xml
38 changes: 38 additions & 0 deletions .github/workflows/composer-require-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Composer require checker

on:
pull_request:
push:
branches:
- master

jobs:
composer-require-checker:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest
php:
- 8.2
- 8.3

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none

- name: Install Composer dependencies
uses: ramsey/composer-install@v3

- name: Check dependencies
run: vendor/bin/composer-require-checker
37 changes: 37 additions & 0 deletions .github/workflows/cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: cs fixer

on:
pull_request_target:

jobs:
php-cs-fixer:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.VJIK_GITHUB_TOKEN }}
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: composer:v2
coverage: none

- name: Install Composer dependencies
uses: ramsey/composer-install@v3

- name: Run PHP CS Fixer
run: composer cs-fix

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Apply PHP CS Fixer changes (CI)"
file_pattern: '*.php'
disable_globbing: true
31 changes: 8 additions & 23 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: mutation test

on:
pull_request:
push:
branches:
- "master"

name: mutation test
- master

jobs:
mutation:
Expand All @@ -16,13 +16,12 @@ jobs:
matrix:
os:
- ubuntu-latest

php:
- 8.0
- 8.3

steps:
- name: Checkout.
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install PHP with extensions.
uses: shivammathur/setup-php@v2
Expand All @@ -32,25 +31,11 @@ jobs:
coverage: xdebug
tools: composer:v2

- name: Determine composer cache directory on Linux.
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer.
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer

- name: Update composer.
run: composer self-update

- name: Install dependencies with composer.
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Install Composer dependencies
uses: ramsey/composer-install@v3

- name: Run roave infection.
run: |
vendor/bin/roave-infection-static-analysis-plugin -j2 --ignore-msi-with-no-mutations --only-covered
vendor/bin/roave-infection-static-analysis-plugin --threads=2 --ignore-msi-with-no-mutations --only-covered
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
40 changes: 13 additions & 27 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
on:
- pull_request
- push

name: static analysis

on:
pull_request:
push:
branches:
- master

jobs:
mutation:
name: PHP ${{ matrix.php }}-${{ matrix.os }}
Expand All @@ -14,39 +16,23 @@ jobs:
matrix:
os:
- ubuntu-latest

php:
- 8.0
- 8.1
- 8.2
- 8.3

steps:
- name: Checkout.
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4

- name: Install PHP with extensions.
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php }}
tools: composer:v2, cs2pr

- name: Determine composer cache directory on Linux.
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer.
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-

- name: Update composer.
run: composer self-update

- name: Install dependencies with composer.
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Install Composer dependencies
uses: ramsey/composer-install@v3

- name: Static analysis.
- name: Static analysis
run: vendor/bin/psalm --shepherd --stats --output-format=checkstyle --php-version=${{ matrix.php }} | cs2pr --graceful-warnings --colorize
17 changes: 17 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;

$finder = (new Finder())->in([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

return (new Config())
->setParallelConfig(ParallelConfigFactory::detect())
->setRules(['@PER-CS2.0' => true])
->setFinder($finder);
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Latest Stable Version](https://poser.pugx.org/vjik/_____/v/stable.png)](https://packagist.org/packages/vjik/_____)
[![Total Downloads](https://poser.pugx.org/vjik/_____/downloads.png)](https://packagist.org/packages/vjik/_____)
[![Build status](https://github.com/vjik/_____/workflows/build/badge.svg)](https://github.com/vjik/_____/actions?query=workflow%3Abuild)
[![Coverage Status](https://coveralls.io/repos/github/vjik/_____/badge.svg)](https://coveralls.io/github/vjik/_____)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fvjik%2F_____%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/vjik/_____/master)
[![type-coverage](https://shepherd.dev/github/vjik/_____/coverage.svg)](https://shepherd.dev/github/vjik/_____)
[![static analysis](https://github.com/vjik/_____/workflows/static%20analysis/badge.svg)](https://github.com/vjik/_____/actions?query=workflow%3A%22static+analysis%22)
Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"php": "^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.64",
"phpunit/phpunit": "^9.5",
"roave/infection-static-analysis-plugin": "^1.25",
"vimeo/psalm": "^4.30|^5.1"
Expand All @@ -30,6 +31,7 @@
}
},
"scripts": {
"cs-fix": "php-cs-fixer fix"
},
"config": {
"sort-packages": true,
Expand Down
Loading