Skip to content
This repository was archived by the owner on Jun 27, 2024. It is now read-only.

Commit cb1b2fc

Browse files
committed
Coding standards
1 parent 8b3de92 commit cb1b2fc

File tree

2 files changed

+84
-1
lines changed

2 files changed

+84
-1
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: "Coding Standards"
2+
on: [push]
3+
jobs:
4+
coding-standards:
5+
runs-on: ubuntu-latest
6+
7+
strategy:
8+
matrix:
9+
php-version:
10+
- "8.0"
11+
node-version:
12+
- 16
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
with:
18+
ref: ${{ github.head_ref }}
19+
20+
- name: "Install Node"
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: "${{ matrix.node-version }}"
24+
25+
- name: "Install PHP with extensions"
26+
uses: "shivammathur/setup-php@v2"
27+
with:
28+
coverage: "none"
29+
php-version: "${{ matrix.php-version }}"
30+
31+
- name: Cache node modules
32+
id: cache-npm
33+
uses: actions/cache@v3
34+
env:
35+
cache-name: cache-node-modules
36+
with:
37+
# npm cache files are stored in `~/.npm` on Linux/macOS
38+
path: ~/.npm
39+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
40+
restore-keys: |
41+
${{ runner.os }}-build-${{ env.cache-name }}-
42+
${{ runner.os }}-build-
43+
${{ runner.os }}-
44+
45+
- if: ${{ steps.cache-npm.outputs.cache-hit == 'false' }}
46+
name: List the state of node modules
47+
continue-on-error: true
48+
run: npm list
49+
50+
- name: "Install locked dependencies with npm"
51+
run: "npm ci --ignore-scripts"
52+
53+
- name: "Cache dependencies installed with composer"
54+
uses: "actions/cache@v2"
55+
with:
56+
path: "~/.composer/cache"
57+
key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}"
58+
restore-keys: "php-${{ matrix.php-version }}-composer-"
59+
60+
- name: "Install locked dependencies with composer"
61+
run: "composer install --no-interaction --no-progress --no-suggest"
62+
63+
- name: "Create cache directory for friendsofphp/php-cs-fixer"
64+
run: mkdir -p .build/php-cs-fixer
65+
66+
- name: "Cache cache directory for friendsofphp/php-cs-fixer"
67+
uses: "actions/cache@v2"
68+
with:
69+
path: "~/.build/php-cs-fixer"
70+
key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ github.sha }}"
71+
restore-keys: "php-${{ matrix.php-version }}-php-cs-fixer-"
72+
73+
- name: "Run eslint"
74+
run: "npm run eslint"
75+
76+
- name: "Run friendsofphp/php-cs-fixer"
77+
run: "composer php-cs-fixer"
78+
79+
- name: Commit changes
80+
uses: stefanzweifel/git-auto-commit-action@v4
81+
with:
82+
commit_message: Fix styling

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
},
3232
"scripts": {
3333
"test": "vendor/bin/phpunit",
34-
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
34+
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
35+
"php-cs-fixer": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --verbose"
3536
},
3637
"config": {
3738
"sort-packages": true

0 commit comments

Comments
 (0)