Skip to content

Commit 47acb8a

Browse files
authored
Support shim install; improve workflow (#9)
* Support shim install * Improve workflow * Fix workflow * Fix workflow harder :) * Upgrade gh actions
1 parent 4107b9b commit 47acb8a

5 files changed

Lines changed: 60 additions & 12 deletions

File tree

.github/workflows/ci.yml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
release:
1010
types:
1111
- created
12+
schedule:
13+
- cron: '0 0 * * *'
1214

1315
jobs:
1416
check_actions:
@@ -33,7 +35,7 @@ jobs:
3335
- run: composer validate --strict --no-check-lock
3436

3537
check_code:
36-
name: Analyse code
38+
name: Check code
3739
runs-on: ubuntu-latest
3840
steps:
3941
- uses: actions/checkout@v6
@@ -57,15 +59,15 @@ jobs:
5759
- run: diff -u README.md .generated-readme.md
5860

5961
tests:
60-
name: Build & Test (${{ matrix.osName }}, PHP ${{ matrix.php }})
62+
name: Build & Test (PHP ${{ matrix.php }} ${{ matrix.desc }})
6163
runs-on: ${{ matrix.os }}
6264
strategy:
6365
fail-fast: false
6466
matrix:
67+
desc:
68+
- 'on Ubuntu'
6569
os:
6670
- 'ubuntu-latest'
67-
osName:
68-
- 'Ubuntu'
6971
php:
7072
- '7.4'
7173
- '8.0'
@@ -75,28 +77,50 @@ jobs:
7577
- '8.4'
7678
- '8.5'
7779
include:
78-
- os: 'macos-15-intel'
79-
osName: 'macOS'
80+
- desc: 'on macOS'
81+
os: 'macos-15-intel'
8082
php: '8.4'
81-
- os: 'windows-latest'
82-
osName: 'Windows'
83+
- desc: 'on Windows'
84+
os: 'windows-latest'
8385
php: '8.4'
86+
- desc: '+ bootstrap, on Ubuntu'
87+
os: 'ubuntu-latest'
88+
php: '8.4'
89+
bootstrap: true
8490
steps:
8591
- uses: actions/checkout@v6
8692
- uses: shivammathur/setup-php@v2
8793
with:
8894
php-version: "${{ matrix.php }}"
8995
ini-file: "development"
9096
coverage: "xdebug"
97+
- id: composer-cache
98+
shell: bash
99+
run: echo "dir=$(composer config cache-dir)" >> "$GITHUB_OUTPUT"
100+
- uses: actions/cache@v4
101+
with:
102+
path: ${{ steps.composer-cache.outputs.dir }}
103+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
91104
- if: matrix.os == 'macos-15-intel'
92105
uses: douglascamata/setup-docker-macos-action@v1.1.0
106+
- if: ${{ matrix.bootstrap }}
107+
# language=bash
108+
run: |
109+
jq -r --indent 4 'del(.autoload."psr-4")' composer.json > composer.tmp
110+
jq -r --indent 4 '.autoload += {"files": ["bootstrap.php"]}' composer.tmp > composer.json
93111
- run: composer update --ansi --no-progress
94112
- run: composer test -- --coverage-clover=coverage.xml --log-junit junit.xml --testdox
95-
- uses: codecov/codecov-action@v6
113+
- if: ${{ !cancelled() }}
114+
uses: codecov/codecov-action@v6
96115
with:
97116
token: ${{ secrets.CODECOV_TOKEN }}
98-
files: coverage.xml
99-
flags: php${{ matrix.php }}
100-
- uses: codecov/test-results-action@v1
117+
report_type: coverage
118+
name: "Coverage: PHP ${{ matrix.php }} ${{ matrix.desc }}"
119+
flags: ${{ runner.os }}-php-${{ matrix.php }}
120+
- if: ${{ !cancelled() }}
121+
uses: codecov/codecov-action@v6
101122
with:
102123
token: ${{ secrets.CODECOV_TOKEN }}
124+
report_type: test_results
125+
name: "Tests: PHP ${{ matrix.php }} ${{ matrix.desc }}"
126+
flags: ${{ runner.os }}-php-${{ matrix.php }}

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ return (new PhpCsFixer\Config())
4242
->setFinder(...);
4343
```
4444

45+
> [!WARNING]
46+
> If PHP CS Fixer is installed via [`php-cs-fixer/shim`](https://github.com/PHP-CS-Fixer/shim) package, you may have to
47+
> require the bootstrap file:
48+
> ```php
49+
> require __DIR__ . '/vendor/uuf6429/php-cs-fixer-blockstring/bootstrap.php';
50+
> ```
51+
4552
## 💡 Before You Start
4653
4754
<details>

bootstrap.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php declare(strict_types=1);
2+
3+
spl_autoload_register(static function (string $class): void {
4+
if (strncmp($class, 'uuf6429\\PhpCsFixerBlockstring\\', 30) !== 0) {
5+
return;
6+
}
7+
8+
require __DIR__ . '/src/' . str_replace('\\', '/', substr($class, 30)) . '.php';
9+
});

phpstan.dist.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ parameters:
77
paths:
88
- ./src
99
- ./tests
10+
- ./bootstrap.php
1011
excludePaths:
1112
- ./tests/fixtures/*
1213
ignoreErrors:

tools/readmerator/README.tpl.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ return (new PhpCsFixer\Config())
4242
->setFinder(...);
4343
```
4444

45+
> [!WARNING]
46+
> If PHP CS Fixer is installed via [`php-cs-fixer/shim`](https://github.com/PHP-CS-Fixer/shim) package, you may have to
47+
> require the bootstrap file:
48+
> ```php
49+
> require __DIR__ . '/vendor/uuf6429/php-cs-fixer-blockstring/bootstrap.php';
50+
> ```
51+
4552
## 💡 Before You Start
4653
4754
<details>

0 commit comments

Comments
 (0)