Skip to content

Commit e0b12c0

Browse files
authored
Merge pull request #269 from wayofdev/docs/updates
docs: update readme
2 parents 637ed79 + 4adda75 commit e0b12c0

File tree

1 file changed

+119
-1
lines changed

1 file changed

+119
-1
lines changed

README.md

Lines changed: 119 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,127 @@ composer req --dev wayofdev/cs-fixer-config
101101
/vendor/
102102
```
103103

104+
### → Makefile
105+
106+
- If you are using [`Makefile`](https://www.gnu.org/software/make/manual/make.html#Introduction), create a `Makefile` with a `lint-php` and `lint-diff` targets:
107+
108+
```diff
109+
+APP_RUNNER ?= php
110+
+APP_COMPOSER ?= $(APP_RUNNER) composer
111+
+
112+
+prepare:
113+
+ mkdir -p .build/php-cs-fixer
114+
+.PHONY: prepare
115+
116+
+lint-php: prepare ## Fixes code to follow coding standards using php-cs-fixer
117+
+ $(APP_COMPOSER) cs:fix
118+
+.PHONY: lint-php
119+
120+
+lint-diff: prepare ## Runs php-cs-fixer in dry-run mode and shows diff which will by applied
121+
+ $(APP_COMPOSER) cs:diff
122+
+.PHONY: lint-diff
123+
```
124+
125+
​ Or, you can check for one of our pre-configured `Makefile` from any of these repositories:
126+
127+
<https://github.com/wayofdev/php-cs-fixer-config/blob/master/Makefile>
128+
129+
<https://github.com/wayofdev/laravel-package-tpl/blob/master/Makefile>
130+
104131
### → GitHub Actions
105132

106-
To use in GitHub Actions, do...
133+
- To use this package in [GitHub Actions](https://github.com/features/actions), add a `coding-standards.yml` workflow to your repository:
134+
135+
```yaml
136+
---
137+
138+
on: # yamllint disable-line rule:truthy
139+
pull_request:
140+
branches:
141+
- master
142+
push:
143+
branches:
144+
- master
145+
146+
name: 🧹 Fix PHP coding standards
147+
148+
jobs:
149+
coding-standards:
150+
timeout-minutes: 4
151+
runs-on: ${{ matrix.os }}
152+
concurrency:
153+
cancel-in-progress: true
154+
group: coding-standards-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
155+
strategy:
156+
matrix:
157+
os:
158+
- ubuntu-latest
159+
php-version:
160+
- '8.1'
161+
dependencies:
162+
- locked
163+
permissions:
164+
contents: write
165+
steps:
166+
- name: ⚙️ Set git to use LF line endings
167+
run: |
168+
git config --global core.autocrlf false
169+
git config --global core.eol lf
170+
171+
- name: 🛠️ Setup PHP
172+
uses: shivammathur/[email protected]
173+
with:
174+
php-version: ${{ matrix.php-version }}
175+
extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter
176+
ini-values: error_reporting=E_ALL
177+
coverage: none
178+
179+
- name: 📦 Check out the codebase
180+
uses: actions/[email protected]
181+
182+
- name: 🛠️ Setup problem matchers
183+
run: |
184+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
185+
186+
- name: 🤖 Validate composer.json and composer.lock
187+
run: composer validate --ansi --strict
188+
189+
- name: 🔍 Get composer cache directory
190+
uses: wayofdev/gh-actions/actions/composer/[email protected]
191+
192+
- name: ♻️ Restore cached dependencies installed with composer
193+
uses: actions/[email protected]
194+
with:
195+
path: ${{ env.COMPOSER_CACHE_DIR }}
196+
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
197+
restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
198+
199+
- name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer
200+
uses: wayofdev/gh-actions/actions/composer/[email protected]
201+
with:
202+
dependencies: ${{ matrix.dependencies }}
203+
204+
- name: 🛠️ Prepare environment
205+
run: make prepare
206+
207+
- name: 🚨 Run coding standards task
208+
run: composer cs:fix
209+
env:
210+
PHP_CS_FIXER_IGNORE_ENV: true
211+
212+
- name: 📤 Commit and push changed files back to GitHub
213+
uses: stefanzweifel/[email protected]
214+
with:
215+
commit_message: 'style(php-cs-fixer): lint php files and fix coding standards'
216+
branch: ${{ github.head_ref }}
217+
commit_author: 'github-actions <[email protected]>'
218+
env:
219+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
220+
```
221+
222+
​ Or, you can check for one of our pre-configured workflows from any of these repositories:
223+
224+
​ <https://github.com/wayofdev/php-cs-fixer-config/blob/master/.github/workflows/coding-standards.yml>
107225
108226
<br>
109227

0 commit comments

Comments
 (0)