Skip to content

Commit 455bede

Browse files
Merge pull request #267 from TheDragonCode/6.x
Added code-style.yml
2 parents 635566a + 48309c2 commit 455bede

3 files changed

Lines changed: 98 additions & 9 deletions

File tree

.github/workflows/code-style.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Code Style
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions: write-all
8+
9+
jobs:
10+
Check:
11+
runs-on: ubuntu-latest
12+
13+
if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/main' }}
14+
15+
steps:
16+
- uses: actions/checkout@v5
17+
- uses: shivammathur/setup-php@v2
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 'latest'
22+
23+
- name: Install Composer dependencies
24+
run: composer global require dragon-code/codestyler
25+
26+
- name: Install Node dependencies
27+
run: npm i -D @biomejs/biome
28+
29+
- name: Publish config files
30+
run: |
31+
codestyle pint 8.2
32+
codestyle npm
33+
34+
- name: PHP code-style
35+
run: pint --parallel --test
36+
37+
- name: Node code-style
38+
run: |
39+
npx @biomejs/biome lint
40+
npx @biomejs/biome format
41+
42+
Fix:
43+
runs-on: ubuntu-latest
44+
45+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
46+
47+
steps:
48+
- uses: actions/checkout@v5
49+
- uses: shivammathur/setup-php@v2
50+
51+
- uses: actions/setup-node@v4
52+
with:
53+
node-version: 'latest'
54+
55+
- name: Setup Composer
56+
run: |
57+
composer global config --no-plugins allow-plugins.dragon-code/codestyler true
58+
composer global config --no-plugins allow-plugins.ergebnis/composer-normalize true
59+
60+
composer config --no-plugins allow-plugins.dragon-code/codestyler true
61+
composer config --no-plugins allow-plugins.ergebnis/composer-normalize true
62+
63+
- name: Install Composer dependencies
64+
run: composer global require dragon-code/codestyler
65+
66+
- name: Install Node dependencies
67+
run: npm i -D @biomejs/biome
68+
69+
- name: Publish config files
70+
run: |
71+
codestyle pint 8.2
72+
codestyle npm
73+
74+
- name: Normalize composer.json
75+
run: composer normalize
76+
77+
- name: PHP code-style
78+
run: pint --parallel
79+
80+
- name: Node code-style
81+
run: |
82+
npx @biomejs/biome lint --write
83+
npx @biomejs/biome format --write
84+
85+
- name: Create a Pull Request
86+
uses: peter-evans/create-pull-request@v7
87+
with:
88+
branch: code-style
89+
branch-suffix: random
90+
delete-branch: true
91+
title: "🦋 The code style has been fixed"
92+
commit-message: 🦋 The code style has been fixed
93+
body: The code style has been fixed
94+
labels: code-style

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ After that, write the commands in the `package.json` file:
9494

9595
[`Laravel Pint`](https://laravel.com/docs/pint) is used as the linter for PHP.
9696

97-
The linter is invoked by a console commands:
97+
The linter is invoked by a console command:
9898

9999
```bash
100100
composer style

tests/style.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
{
22
"preset": "laravel",
33
"rules": {
4-
"@PHP83Migration": true,
4+
"@PHP83Migration": true,
55
"concat_space": {
6-
"spacing": "one"
7-
},
6+
"spacing": "one" },
87
"blank_line_before_statement": {
9-
"statements": [
10-
"declare",
11-
"phpdoc",
12-
"continue",
13-
"return"
8+
"statements": [ "declare", "phpdoc", "continue", "return"
149
]
1510
}
1611
},

0 commit comments

Comments
 (0)