-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #691 from westonruter/fix/linting
Fix CI
- Loading branch information
Showing
14 changed files
with
902 additions
and
44 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
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 |
---|---|---|
@@ -1,53 +1,100 @@ | ||
name: Continuous Integration | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- actions-playground # TODO: Remove this after it works | ||
- develop | ||
- "*.*" | ||
pull_request_target: ~ | ||
|
||
# Cancel previous workflow run groups that have not completed. | ||
concurrency: | ||
# Group workflow runs by workflow name, along with the head branch ref of the pull request | ||
# or otherwise the branch or tag ref. | ||
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
lint: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: | ||
- ubuntu-18.04 | ||
|
||
lint-css: | ||
name: 'Lint and Analyze' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/[email protected] | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: npm | ||
|
||
- name: Install dependencies (Ubuntu) | ||
if: runner.os == 'Linux' | ||
run: |- | ||
sudo apt-get update | ||
sudo apt-get install -y libxml2-utils | ||
- name: Install Node dependencies | ||
run: npm ci | ||
env: | ||
CI: true | ||
|
||
- name: Cache multiple paths | ||
uses: actions/[email protected] | ||
- name: Validate package.json | ||
run: npm run lint:pkg-json | ||
|
||
- name: Detect coding standard violations (stylelint) | ||
run: npm run lint:css | ||
|
||
- name: Detect ESLint coding standard violations | ||
if: > | ||
github.event.pull_request.head.repo.fork == true || | ||
github.event.pull_request.user.login == 'dependabot[bot]' | ||
run: npm run lint:js | ||
|
||
- name: Generate ESLint coding standard violations report | ||
# Prevent generating the ESLint report if PR is from a fork or authored by Dependabot. | ||
if: > | ||
! ( github.event.pull_request.head.repo.fork == true || | ||
github.event.pull_request.user.login == 'dependabot[bot]' ) | ||
run: npm run lint:js:report | ||
continue-on-error: true | ||
|
||
- name: Annotate code linting results | ||
# The action cannot annotate the PR when run from a PR fork or was authored by Dependabot. | ||
if: > | ||
! ( github.event.pull_request.head.repo.fork == true || | ||
github.event.pull_request.user.login == 'dependabot[bot]' ) | ||
uses: ataylorme/[email protected] | ||
with: | ||
path: |- | ||
$HOME/.composer/cache | ||
$HOME/.npm | ||
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock', '**/package-lock.json') }} | ||
repo-token: '${{ secrets.GITHUB_TOKEN }}' | ||
report-json: 'lint-js-report.json' | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 7.4 | ||
php-version: '8.0' | ||
extensions: dom, iconv, json, libxml, zip | ||
coverage: none | ||
tools: phpstan, cs2pr | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
||
- name: Configure Composer cache | ||
uses: actions/[email protected] | ||
with: | ||
node-version: 14 | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: Install Composer dependencies | ||
run: composer install --prefer-dist --optimize-autoloader --no-progress --no-interaction | ||
|
||
- name: Install Dependencies | ||
run: | | ||
npm install | ||
composer install | ||
- name: Validate composer.json | ||
run: composer --no-interaction validate --no-check-all | ||
|
||
- name: Build Plug-in | ||
run: npm run build | ||
- name: Detect coding standard violations (PHPCS) | ||
run: vendor/bin/phpcs -q --report=checkstyle --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 | cs2pr --graceful-warnings | ||
|
||
- name: Lint | ||
run: npm run lint | ||
- name: Normalize composer.json | ||
run: composer --no-interaction normalize --dry-run | ||
|
||
- name: Static Analysis (PHPStan) | ||
run: | | ||
phpstan --version | ||
phpstan analyse |
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx lint-staged |
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,16 @@ | ||
module.exports = { | ||
"composer.*": [ | ||
() => "composer --no-interaction validate --no-check-all", | ||
() => "npm run lint:composer" | ||
], | ||
"package.json": [ | ||
"npm run lint:pkg-json" | ||
], | ||
"**/*.js": [ | ||
"npm run lint:js" | ||
], | ||
"**/*.php": [ | ||
"npm run lint:php", | ||
() => 'npm run lint:phpstan' | ||
] | ||
}; |
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,13 @@ | ||
#!/bin/bash | ||
# Wrap phpcbf to turn 1 success exit code into 0 code. | ||
# See https://github.com/squizlabs/PHP_CodeSniffer/issues/1818#issuecomment-354420927 | ||
|
||
composer exec phpcbf $@ | ||
exit=$? | ||
|
||
# Exit code 1 is used to indicate that all fixable errors were fixed correctly. | ||
if [[ $exit == 1 ]]; then | ||
exit=0 | ||
fi | ||
|
||
exit $exit |
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
Oops, something went wrong.