Skip to content

Commit 3c1be89

Browse files
committed
ci: add rector workflow
1 parent 6f37090 commit 3c1be89

File tree

4 files changed

+215
-37
lines changed

4 files changed

+215
-37
lines changed

.github/workflows/refactoring.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
3+
on: # yamllint disable-line rule:truthy
4+
pull_request:
5+
branches:
6+
- develop
7+
paths:
8+
- 'app/config/**'
9+
- 'app/src/**'
10+
- 'app/tests/**'
11+
- 'app/.php-cs-fixer.dist.php'
12+
- 'app/rector.php'
13+
14+
name: ⚙️ Refactoring
15+
16+
env:
17+
# Disable docker support in Makefile
18+
APP_RUNNER: 'cd app &&'
19+
20+
jobs:
21+
refactoring:
22+
timeout-minutes: 4
23+
runs-on: ${{ matrix.os }}
24+
concurrency:
25+
cancel-in-progress: true
26+
group: refactoring-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
27+
strategy:
28+
fail-fast: true
29+
matrix:
30+
os:
31+
- ubuntu-latest
32+
php-version:
33+
- '8.3'
34+
dependencies:
35+
- locked
36+
steps:
37+
- name: 📦 Check out the codebase
38+
uses: actions/checkout@v4.1.6
39+
40+
- name: 🛠️ Setup PHP
41+
uses: shivammathur/setup-php@2.30.5
42+
with:
43+
php-version: ${{ matrix.php-version }}
44+
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql
45+
ini-values: error_reporting=E_ALL
46+
coverage: none
47+
48+
- name: 🛠️ Setup problem matchers
49+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
50+
51+
- name: 🤖 Validate composer.json and composer.lock
52+
run: make validate-composer
53+
54+
- name: 🔍 Get composer cache directory
55+
uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1
56+
with:
57+
working-directory: app
58+
59+
- name: ♻️ Restore cached dependencies installed with composer
60+
uses: actions/cache@v4.0.2
61+
with:
62+
path: ${{ env.COMPOSER_CACHE_DIR }}
63+
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
64+
restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
65+
66+
- name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer
67+
uses: wayofdev/gh-actions/actions/composer/install@v3.1.1
68+
with:
69+
working-directory: app
70+
dependencies: ${{ matrix.dependencies }}
71+
72+
- name: ⚙️ Run automated refactoring with rector/rector
73+
run: make refactor-ci

app/composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@
125125
],
126126
"cs:diff": "php-cs-fixer fix --dry-run -v --diff",
127127
"cs:fix": "php-cs-fixer fix -v",
128-
"deptrac": "deptrac analyse --config-file=deptrac.yaml -v --cache-file=.build/.deptrac.cache",
129-
"deptrac:ci": "deptrac analyse --config-file=deptrac.yaml -v --cache-file=.build/.deptrac.cache --formatter github-actions",
130-
"deptrac:gv": "deptrac analyse --config-file=deptrac.yaml -v --cache-file=.build/.deptrac.cache --formatter graphviz-image --output ../.github/assets/deptrac.svg",
131128
"infect": [
132129
"Composer\\Config::disableProcessTimeout",
133130
"@putenv XDEBUG_MODE=coverage",
@@ -141,6 +138,8 @@
141138
"psalm": "psalm --show-info=true",
142139
"psalm:baseline": "psalm --set-baseline=psalm-baseline.xml",
143140
"psalm:ci": "psalm --output-format=github --shepherd --show-info=false --stats --threads=4",
141+
"refactor": "rector process --config=rector.php",
142+
"refactor:ci": "rector process --config=rector.php --dry-run --ansi",
144143
"stan": "phpstan analyse --memory-limit=2G",
145144
"stan:baseline": "phpstan analyse --generate-baseline --memory-limit=2G --allow-empty-baseline",
146145
"stan:ci": "phpstan analyse --memory-limit=2G --error-format=github",

app/composer.lock

Lines changed: 108 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)