Skip to content

Commit 8e99911

Browse files
committed
ci: add php cs fixer config
1 parent d5ac074 commit 8e99911

File tree

1 file changed

+196
-0
lines changed

1 file changed

+196
-0
lines changed
+196
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
---
2+
3+
on: # yamllint disable-line rule:truthy
4+
pull_request:
5+
branches:
6+
- master
7+
push:
8+
branches:
9+
- master
10+
11+
name: 🧹 Fix PHP coding standards
12+
13+
jobs:
14+
commit-linting:
15+
timeout-minutes: 4
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
pull-requests: read
20+
steps:
21+
- name: 📦 Check out the codebase
22+
uses: actions/[email protected]
23+
24+
- name: 🧐 Lint commits using "commitlint"
25+
uses: wagoid/[email protected]
26+
with:
27+
configFile: ${{ github.workspace }}/.github/.commitlint.config.mjs
28+
failOnWarnings: false
29+
failOnErrors: false
30+
helpURL: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint'
31+
32+
yaml-linting:
33+
timeout-minutes: 4
34+
runs-on: ubuntu-latest
35+
permissions:
36+
contents: read
37+
pull-requests: read
38+
steps:
39+
- name: 📦 Check out the codebase
40+
uses: actions/[email protected]
41+
42+
- name: 🧐 Lint YAML files
43+
uses: ibiqlik/[email protected]
44+
with:
45+
config_file: .github/.yamllint.yaml
46+
file_or_dir: '.'
47+
strict: true
48+
49+
markdown-linting:
50+
timeout-minutes: 4
51+
runs-on: ubuntu-latest
52+
concurrency:
53+
cancel-in-progress: true
54+
group: markdown-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
55+
steps:
56+
- name: 📦 Check out the codebase
57+
uses: actions/[email protected]
58+
59+
- name: 🧐 Lint Markdown files
60+
uses: DavidAnson/[email protected]
61+
with:
62+
globs: |
63+
**/*.md
64+
!CHANGELOG.md
65+
66+
composer-linting:
67+
timeout-minutes: 4
68+
runs-on: ${{ matrix.os }}
69+
concurrency:
70+
cancel-in-progress: true
71+
group: composer-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
72+
strategy:
73+
matrix:
74+
os:
75+
- ubuntu-latest
76+
php-version:
77+
- '8.2'
78+
dependencies:
79+
- locked
80+
permissions:
81+
contents: write
82+
steps:
83+
- name: 🛠️ Setup PHP
84+
uses: shivammathur/[email protected]
85+
with:
86+
php-version: ${{ matrix.php-version }}
87+
extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, phar, sockets
88+
ini-values: error_reporting=E_ALL
89+
coverage: none
90+
tools: phive
91+
92+
- name: 📦 Check out the codebase
93+
uses: actions/[email protected]
94+
95+
- name: 🛠️ Setup problem matchers
96+
run: |
97+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
98+
99+
- name: 🤖 Validate composer.json and composer.lock
100+
run: composer validate --ansi --strict
101+
102+
- name: 🔍 Get composer cache directory
103+
uses: wayofdev/gh-actions/actions/composer/[email protected]
104+
105+
- name: ♻️ Restore cached dependencies installed with composer
106+
uses: actions/[email protected]
107+
with:
108+
path: ${{ env.COMPOSER_CACHE_DIR }}
109+
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
110+
restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
111+
112+
- name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer
113+
uses: wayofdev/gh-actions/actions/composer/[email protected]
114+
with:
115+
dependencies: ${{ matrix.dependencies }}
116+
117+
- name: 📥 Install dependencies with phive
118+
uses: wayofdev/gh-actions/actions/phive/[email protected]
119+
with:
120+
phive-home: '.phive'
121+
trust-gpg-keys: '0xC00543248C87FB13,0x033E5F8D801A2F8D'
122+
123+
- name: 🔍 Run ergebnis/composer-normalize
124+
run: .phive/composer-normalize --ansi --dry-run
125+
126+
coding-standards:
127+
timeout-minutes: 4
128+
runs-on: ${{ matrix.os }}
129+
concurrency:
130+
cancel-in-progress: true
131+
group: coding-standards-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
132+
strategy:
133+
matrix:
134+
os:
135+
- ubuntu-latest
136+
php-version:
137+
- '8.2'
138+
dependencies:
139+
- locked
140+
permissions:
141+
contents: write
142+
steps:
143+
- name: ⚙️ Set git to use LF line endings
144+
run: |
145+
git config --global core.autocrlf false
146+
git config --global core.eol lf
147+
148+
- name: 🛠️ Setup PHP
149+
uses: shivammathur/[email protected]
150+
with:
151+
php-version: ${{ matrix.php-version }}
152+
extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, sockets
153+
ini-values: error_reporting=E_ALL
154+
coverage: none
155+
156+
- name: 📦 Check out the codebase
157+
uses: actions/[email protected]
158+
159+
- name: 🛠️ Setup problem matchers
160+
run: |
161+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
162+
163+
- name: 🤖 Validate composer.json and composer.lock
164+
run: composer validate --ansi --strict
165+
166+
- name: 🔍 Get composer cache directory
167+
uses: wayofdev/gh-actions/actions/composer/[email protected]
168+
169+
- name: ♻️ Restore cached dependencies installed with composer
170+
uses: actions/[email protected]
171+
with:
172+
path: ${{ env.COMPOSER_CACHE_DIR }}
173+
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
174+
restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
175+
176+
- name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer
177+
uses: wayofdev/gh-actions/actions/composer/[email protected]
178+
with:
179+
dependencies: ${{ matrix.dependencies }}
180+
181+
- name: 🛠️ Prepare environment
182+
run: make prepare
183+
184+
- name: 🚨 Run coding standards task
185+
run: composer cs:fix
186+
env:
187+
PHP_CS_FIXER_IGNORE_ENV: true
188+
189+
- name: 📤 Commit and push changed files back to GitHub
190+
uses: stefanzweifel/[email protected]
191+
with:
192+
commit_message: 'style(php-cs-fixer): lint php files and fix coding standards'
193+
branch: ${{ github.head_ref }}
194+
commit_author: 'github-actions <[email protected]>'
195+
env:
196+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)