Skip to content

Commit 8c0e5ce

Browse files
committed
ci: add coding-standards workflow
1 parent 8695baf commit 8c0e5ce

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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/checkout@v4.1.4
23+
24+
- name: 🧐 Lint commits using "commitlint"
25+
uses: wagoid/commitlint-github-action@v6.0.1
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+
markdown-linting:
33+
timeout-minutes: 4
34+
runs-on: ubuntu-latest
35+
concurrency:
36+
cancel-in-progress: true
37+
group: markdown-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
38+
steps:
39+
- name: 📦 Check out the codebase
40+
uses: actions/checkout@v4.1.4
41+
42+
- name: 🧐 Lint Markdown files
43+
uses: DavidAnson/markdownlint-cli2-action@v16.0.0
44+
with:
45+
globs: |
46+
**/*.md
47+
!CHANGELOG.md
48+
49+
coding-standards:
50+
timeout-minutes: 4
51+
runs-on: ${{ matrix.os }}
52+
concurrency:
53+
cancel-in-progress: true
54+
group: coding-standards-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
55+
strategy:
56+
matrix:
57+
os:
58+
- ubuntu-latest
59+
php-version:
60+
- '8.2'
61+
dependencies:
62+
- locked
63+
permissions:
64+
contents: write
65+
steps:
66+
- name: ⚙️ Set git to use LF line endings
67+
run: |
68+
git config --global core.autocrlf false
69+
git config --global core.eol lf
70+
71+
- name: 🛠️ Setup PHP
72+
uses: shivammathur/setup-php@2.30.4
73+
with:
74+
php-version: ${{ matrix.php-version }}
75+
extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, sockets
76+
ini-values: error_reporting=E_ALL
77+
coverage: none
78+
79+
- name: 📦 Check out the codebase
80+
uses: actions/checkout@v4.1.5
81+
82+
- name: 🛠️ Setup problem matchers
83+
run: |
84+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
85+
86+
- name: 🤖 Validate composer.json and composer.lock
87+
run: composer validate --ansi --strict
88+
89+
- name: 🔍 Get composer cache directory
90+
uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.0
91+
92+
- name: ♻️ Restore cached dependencies installed with composer
93+
uses: actions/cache@v4.0.2
94+
with:
95+
path: ${{ env.COMPOSER_CACHE_DIR }}
96+
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
97+
restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
98+
99+
- name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer
100+
uses: wayofdev/gh-actions/actions/composer/install@v3.1.0
101+
with:
102+
dependencies: ${{ matrix.dependencies }}
103+
104+
- name: 🛠️ Prepare environment
105+
run: make prepare
106+
107+
- name: 🚨 Run coding standards task
108+
run: composer cs:fix
109+
env:
110+
PHP_CS_FIXER_IGNORE_ENV: true
111+
112+
- name: 📤 Commit and push changed files back to GitHub
113+
uses: stefanzweifel/git-auto-commit-action@v5.0.1
114+
with:
115+
commit_message: 'style(php-cs-fixer): lint php files and fix coding standards'
116+
branch: ${{ github.head_ref }}
117+
commit_author: 'github-actions <github-actions@users.noreply.github.com>'
118+
env:
119+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)