Skip to content

Commit 9621dc8

Browse files
committed
ITKDev: Added github actions to check code style
1 parent c49c3ea commit 9621dc8

File tree

4 files changed

+153
-0
lines changed

4 files changed

+153
-0
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#### Link to ticket
2+
3+
Please add a link to the ticket being addressed by this change.
4+
5+
#### Description
6+
7+
Please include a short description of the suggested change and the reasoning behind the approach you have chosen.
8+
9+
#### Screenshot of the result
10+
11+
If your change affects the user interface you should include a screenshot of the result with the pull request.
12+
13+
#### Checklist
14+
15+
- [ ] My code passes our static analysis suite.
16+
- [ ] My code passes our continuous integration process.
17+
18+
If your code does not pass all the requirements on the checklist you have to add a comment explaining why this change
19+
should be exempt from the list.
20+
21+
#### Additional comments or questions
22+
23+
If you have any further comments or questions for the reviewer please add them here.

.github/workflows/pr.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,92 @@ jobs:
1717

1818
- name: Check that changelog has been updated.
1919
run: git diff --exit-code origin/${{ github.base_ref }} -- CHANGELOG.md && exit 1 || exit 0
20+
21+
test-composer-files:
22+
name: Validate composer
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
php-versions: [ '8.1' ]
27+
dependency-version: [ prefer-lowest, prefer-stable ]
28+
steps:
29+
- uses: actions/checkout@master
30+
- name: Setup PHP, with composer and extensions
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: ${{ matrix.php-versions }}
34+
extensions: json
35+
coverage: none
36+
tools: composer:v2
37+
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
38+
- name: Get composer cache directory
39+
id: composer-cache
40+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
41+
- name: Cache dependencies
42+
uses: actions/cache@v2
43+
with:
44+
path: ${{ steps.composer-cache.outputs.dir }}
45+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
46+
restore-keys: ${{ runner.os }}-composer-
47+
- name: Validate composer files
48+
run: |
49+
composer validate --strict composer.json
50+
# Check that dependencies resolve.
51+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
52+
53+
php-coding-standards:
54+
name: PHP coding standards
55+
runs-on: ubuntu-latest
56+
strategy:
57+
matrix:
58+
php-versions: [ '8.1' ]
59+
steps:
60+
- uses: actions/checkout@master
61+
- name: Setup PHP, with composer and extensions
62+
uses: shivammathur/setup-php@v2
63+
with:
64+
php-version: ${{ matrix.php-versions }}
65+
extensions: json
66+
coverage: none
67+
tools: composer:v2
68+
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
69+
- name: Get composer cache directory
70+
id: composer-cache
71+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
72+
- name: Cache dependencies
73+
uses: actions/cache@v2
74+
with:
75+
path: ${{ steps.composer-cache.outputs.dir }}
76+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
77+
restore-keys: ${{ runner.os }}-composer-
78+
- name: Install Dependencies
79+
run: |
80+
composer install --no-interaction --no-progress
81+
- name: PHPCS
82+
run: |
83+
composer coding-standards-check/phpcs
84+
85+
markdownlint:
86+
runs-on: ubuntu-latest
87+
name: markdownlint
88+
steps:
89+
- name: Checkout
90+
uses: actions/checkout@v2
91+
- name: Get yarn cache directory path
92+
id: yarn-cache-dir-path
93+
run: echo "::set-output name=dir::$(yarn cache dir)"
94+
- name: Cache yarn packages
95+
uses: actions/cache@v2
96+
id: yarn-cache
97+
with:
98+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
99+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
100+
restore-keys: |
101+
${{ runner.os }}-yarn-
102+
- name: Yarn install
103+
uses: actions/setup-node@v2
104+
with:
105+
node-version: '20'
106+
- run: yarn install
107+
- name: markdownlint
108+
run: yarn coding-standards-check/markdownlint

composer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,33 @@
1717
"type": "composer",
1818
"url": "https://asset-packagist.org"
1919
}
20+
},
21+
"require-dev": {
22+
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
23+
"drupal/coder": "^8.3",
24+
"mglaman/phpstan-drupal": "^1.1",
25+
"phpstan/extension-installer": "^1.3",
26+
"phpstan/phpstan-deprecation-rules": "^1.1",
27+
"phpunit/phpunit": "^9.5"
28+
},
29+
"scripts": {
30+
"code-analysis/phpstan": [
31+
"phpstan analyse"
32+
],
33+
"code-analysis": [
34+
"@code-analysis/phpstan"
35+
],
36+
"coding-standards-check/phpcs": [
37+
"phpcs --standard=phpcs.xml.dist"
38+
],
39+
"coding-standards-check": [
40+
"@coding-standards-check/phpcs"
41+
],
42+
"coding-standards-apply/phpcs": [
43+
"phpcbf --standard=phpcs.xml.dist"
44+
],
45+
"coding-standards-apply": [
46+
"@coding-standards-apply/phpcs"
47+
]
2048
}
2149
}

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"license": "UNLICENSED",
3+
"private": true,
4+
"devDependencies": {
5+
"markdownlint-cli": "^0.32.2"
6+
},
7+
"scripts": {
8+
"coding-standards-check/markdownlint": "yarn markdownlint --ignore LICENSE.md --ignore vendor --ignore node_modules '*.md' 'modules/os2forms_digital_post/**/*.md'",
9+
"coding-standards-check": "yarn coding-standards-check/markdownlint",
10+
"coding-standards-apply/markdownlint": "yarn markdownlint --ignore LICENSE.md --ignore vendor --ignore node_modules '*.md' 'modules/os2forms_digital_post/**/*.md' --fix",
11+
"coding-standards-apply": "yarn coding-standards-apply/markdownlint"
12+
}
13+
}

0 commit comments

Comments
 (0)