ci: improve linting, GitHub Actions workflows (#149)

* release: release 2.7.2

* fix: urgent 2.7.3 release to fix fatal error

* chore: remove un-needed setup script

* ci: remove steps from pre-push command

* chore: remove un-needed PHP-Commitizen config

* chore: put image files in correct folders

* chore: move GitHub image into `.github/` dir

* fix: classic editor button

* fix: call correct jQuery Tools file in dev env

* docs: replace license with Markdown version

* ci: clean up PHP linting commands

If anyone has noticed me playing musical filepaths with these commands
for a while, it's because I kept getting inconsistent results from the
use of double-globs (i.e., `**`). However, I've finally figured out
that this is because Composer is running these scripts in its own shell,
so the double-glob that works when I run the command manually in my
Terminal doesn't work when Composer runs it in its.

* chore: lint PHP files

* build: update JS linting standards

* chore: lint JS file

* build: add node-sass

* build: add additional stylelint rules

* chore: lint stylesheets with new rulesets

* refactor: move ESLint settings to `package.json`

* chore: move Prettier config to `package.json`

It is not yet possible to move `.prettierignore` to `package.json` too,
but this appears to be on the horizon; see [this Issue][prettier-issue].

[prettier-issue]: https://github.com/prettier/prettier/issues/3460

* fix: move WPML config into Plugin folder

* chore: move Stylelint config into `package.json`

* chore: remove unused `.distignore`

It can always be re-added at a later date if it becomes useful.

* chore: format file

* build: add HTML linting

* fix: add image alt tag

* ci: clean up GitHub Actions workflows

* fix: fix workflow

* fix: fix indentation

* ci: add YAML validation

* chore: make valid

* ci: add YAML validation

* chore: lint code

* ci: change dep install back to original

* chore: lint license
This commit is contained in:
Ben Goldsworthy 2021-04-26 17:17:44 +01:00 committed by GitHub
parent ac819034e5
commit 4af8849eec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 15881 additions and 1771 deletions

49
.github/workflows/lint-code.yml vendored Normal file
View file

@ -0,0 +1,49 @@
name: Code Linting
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
lint:
name: Lint all code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --ignore-platform-reqs
- name: Validate workflow files (YAML)
run: npm run validate:yaml
- name: Lint Plugin code (PHP)
run: composer run lint:php
- name: Lint Plugin scripts (JS)
run: composer run format:js:fix && composer run lint:js
#- name: Lint stylesheets (CSS)
# run: composer run lint:css
#- name: Lint templates (HTML)
# run: composer run lint:html
- name: Lint documentation (Markdown)
run: composer run lint:md

View file

@ -16,6 +16,7 @@ jobs:
OSSAR-Scan:
# OSSAR runs on windows-latest.
# ubuntu-latest and macos-latest support coming soon
name: Scan code with OSSAR
runs-on: windows-latest
steps:

View file

@ -1,46 +0,0 @@
name: PHP Composer
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --ignore-platform-reqs
- name: Lint PHP code
run: composer run lint:php
- name: Lint JS code
run: composer run format:js:fix && composer run lint:js
#- name: Lint stylesheets
# run: composer run lint:css
- name: Lint Markdown files
run: composer run lint:md
# TODO: Add tests
# - name: Run test suite
# run: composer run-script test

View file

@ -1,13 +1,13 @@
name: Release Handler
name: Pre-release Handler
# Action runs when a new release is published.
on:
release:
types: [published]
jobs:
release-new:
name: Issue new release
build:
name: Build the Plugin for pre-release
if: "github.event.release.prerelease"
runs-on: ubuntu-latest
steps:
@ -16,7 +16,7 @@ jobs:
- name: Install dependencies
run: |
composer install --no-dev --optimize-autoloader
composer install --no-dev --optimize-autoloader --no-progress
- name: Build Plugin
run: |

View file

@ -1,13 +1,19 @@
name: Snyk
on: push
jobs:
security:
name: Scan for vulnerabilities
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/php@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --all-projects
- name: Checkout code
uses: actions/checkout@master
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/php@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --all-projects