This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add code linting and github action (#73)
* Add config files for PHP and CSS linting + coding standards. * Update readme with test info. * Fix standards error and add newline at end of file. * Test github action. * Fix php version. * Ignore warnings on exit and remove stan from autocheck. * Apply clarifications and naming suggestions Co-authored-by: Stephen Edgar <stephen@netweb.com.au> * Formatting improvements. * Pin actions to specific commit/version, use node v14 * Remove extra linebreaks. * Fix yaml syntax errors. * Remove reference to this branch. Co-authored-by: Stephen Edgar <stephen@netweb.com.au>
- Loading branch information
Showing
13 changed files
with
3,313 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This file is for unifying the coding style for different editors and IDEs | ||
# editorconfig.org | ||
|
||
# WordPress Coding Standards | ||
# https://make.wordpress.org/core/handbook/coding-standards/ | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
indent_style = tab | ||
|
||
[*.yml] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Code Quality - PHP | ||
|
||
on: | ||
pull_request: | ||
branches: [trunk] | ||
push: | ||
branches: [trunk] | ||
|
||
jobs: | ||
lint: | ||
name: Parallel lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checkout repository | ||
- name: Checkout | ||
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 | ||
# Setup PHP versions, run checks | ||
- name: PHP setup | ||
uses: shivammathur/setup-php@a7f90656b3be3996d1ec5501e8e25d5d35aa9bb2 # v2.15.0 | ||
with: | ||
php-version: 7.4 | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: | | ||
echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- name: Cache composer dependencies | ||
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: Install composer packages | ||
run: composer install --no-progress | ||
- name: Check for PHP errors | ||
run: composer lint | ||
|
||
phpcs_check: | ||
name: PHPCS check | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checkout repository | ||
- name: Checkout | ||
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 | ||
# Setup PHP versions, run checks | ||
- name: PHP setup | ||
uses: shivammathur/setup-php@a7f90656b3be3996d1ec5501e8e25d5d35aa9bb2 # v2.15.0 | ||
with: | ||
php-version: 7.4 | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: | | ||
echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- name: Cache composer dependencies | ||
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: Install composer packages | ||
run: composer install --no-progress | ||
- name: Check coding standards using PHPCS | ||
run: composer standards:check -- --runtime-set ignore_warnings_on_exit true --runtime-set testVersion 5.8- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Code Quality - CSS | ||
|
||
on: | ||
pull_request: | ||
branches: [trunk] | ||
push: | ||
branches: [trunk] | ||
|
||
jobs: | ||
stylelint: | ||
name: stylelint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 | ||
- name: install node v14 | ||
uses: actions/setup-node@270253e841af726300e85d718a5f606959b2903c # v2.4.1 | ||
with: | ||
node-version: 14 | ||
- name: npm install | ||
run: npm install | ||
- name: stylelint | ||
uses: actions-hub/stylelint@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
PATTERN: "**/*.css" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "@wordpress/stylelint-config" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "wordpress/twentytwentytwo", | ||
"type": "package", | ||
"description": "WordPress default theme for 2022.", | ||
"keywords": [ | ||
"WordPress", | ||
"Themes" | ||
], | ||
"homepage": "https://github.com/WordPress/twentytwentytwo", | ||
"license": "GPL-2.0-or-later", | ||
"authors": [ | ||
{ | ||
"name": "Contributors", | ||
"homepage": "https://github.com/WordPress/twentytwentytwo/contributors.md" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.6" | ||
}, | ||
"require-dev": { | ||
"szepeviktor/phpstan-wordpress": "^0.7.7", | ||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", | ||
"wptrt/wpthemereview": "^0.2.1", | ||
"php-parallel-lint/php-parallel-lint": "^1.3" | ||
}, | ||
"scripts": { | ||
"analyze": "@php ./vendor/bin/phpstan analyze", | ||
"lint": "@php ./vendor/bin/parallel-lint --exclude .git --exclude vendor .", | ||
"standards:check": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs", | ||
"standards:fix": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf" | ||
} | ||
} |
Oops, something went wrong.