Skip to content

Commit

Permalink
Merge branch 'feature/plugin-check-updates' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveJonesDev committed Nov 29, 2023
2 parents d871923 + e291d50 commit 8c70a95
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 6 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CS

on:
# Run on all pushes (except to main) and on all pull requests.
push:
branches-ignore:
- 'master'
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
checkcs:
name: 'Check code style'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run custom composer script
run: ./run-composer.sh

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
tools: cs2pr

# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
- name: Validate Composer installation
run: composer validate --no-check-all

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
with:
# Bust the cache at least once a month - output format: YYYY-MM-DD.
custom-cache-suffix: $(date -u -d "-0 month -$(($(date +%d)-1)) days" "+%F")

# Check the codestyle of the files.
# The results of the CS check will be shown inline in the PR via the CS2PR tool.
# @link https://github.com/staabm/annotate-pull-request-from-checkstyle/
- name: Check PHP code style
id: phpcs
run: composer check-cs -- --report-full --report-checkstyle=./phpcs-report.xml --ignore=vendor

- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: cs2pr ./phpcs-report.xml
59 changes: 59 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Lint

on:
# Run on pushes to select branches and on all pull requests.
push:
branches:
- master
- develop
- trunk
- 'feature/**'
- 'release/**'
- 'hotfix/[0-9]+.[0-9]+*'
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest

strategy:
matrix:
# Lint against the highest/lowest supported versions of each PHP major.
# And also do a run against "nightly" (the current dev version of PHP).
php_version: ['7.4', '8.0', '8.1', '8.2']

name: "Lint: PHP ${{ matrix.php_version }}"

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run custom composer script
run: ./run-composer.sh

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_version }}
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
coverage: none
tools: cs2pr

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
with:
# Bust the cache at least once a month - output format: YYYY-MM-DD.
custom-cache-suffix: $(date -u -d "-0 month -$(($(date +%d)-1)) days" "+%F")

- name: Lint against parse errors
run: composer lint -- --checkstyle | cs2pr
40 changes: 35 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{
"name": "equalizedigital/accesibility-checker",
"description": "Audit and check your website for accessibility before you hit publish. In-post accessibility scanner and guidance.",
"keywords": [
"accessibility",
"accessible",
"wcag"
],
"homepage": "https://equalizedigital.com/accessibility-checker/",
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "Steve Jones",
"email": "dev@equalizedigital.com"
"name": "Equalize Digital",
"homepage": "https://equalizedigital.com"
}
],
"config": {
Expand All @@ -24,11 +32,33 @@
"require-dev": {
"automattic/vipwpcs": "^3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
"equalizedigital/accessibility-checker-wp-env": "dev-main#2d6218b193e089baeb1848f8b9935c22343cbaa0",
"phpcompatibility/php-compatibility": "*"
"phpcompatibility/php-compatibility": "*",
"yoast/wp-test-utils": "^1.1.1",
"php-parallel-lint/php-parallel-lint": "^1.3",
"equalizedigital/accessibility-checker-wp-env": "1.0.0"
},
"require": {
"cbschuld/browser.php": "^1.9",
"davechild/textstatistics": "1.0.2"
"davechild/textstatistics": "1.0.2",
"php": ">=7.4",
"composer/installers": "^1.12.0"
},
"scripts": {
"lint": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --show-deprecated --exclude vendor --exclude node_modules --exclude .git"
],
"config-yoastcs": [
"Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run",
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --config-set default_standard Yoast"
],
"check-cs": [
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --runtime-set testVersion 7.4-"
],
"fix-cs": [
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf"
],
"test": [
"@php ./vendor/phpunit/phpunit/phpunit"
]
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"hard-reset": "./hard-reset.sh",
"wp:clean": "npx wp-env clean all",
"wp:sql": "npx wp-env run cli wp db cli",
"start": "npx wp-env start",
"start": "./run-composer.sh && npx wp-env start",
"stop": "npx wp-env stop",
"build": "npx webpack",
"dev": "npx webpack --watch --mode development",
Expand Down
3 changes: 3 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<exclude-pattern>./dist/</exclude-pattern>
<exclude-pattern>./vendor/</exclude-pattern>
<exclude-pattern>./node_modules/</exclude-pattern>
<exclude-pattern>./.wp-env/</exclude-pattern>
<exclude-pattern>./simple_html_dom.php</exclude-pattern>
<exclude-pattern>./update-composer-config.php</exclude-pattern>

<!-- Scan only PHP files -->
<arg name="extensions" value="php"/>
Expand Down
4 changes: 4 additions & 0 deletions run-composer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
php update-composer-config.php

composer update
24 changes: 24 additions & 0 deletions update-composer-config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Accessibility Checker pluign file.
*
* @package Accessibility_Checker
*/

// Check if running in GitHub Actions environment.
$env = getenv( 'GITHUB_ACTIONS' );

$composer_json_path = 'composer.json';
$composer_config = json_decode( file_get_contents( $composer_json_path ), true );

if ( 'true' === $env ) {
// Running in GitHub Actions environment.
// Remove local specific packages for GitHub Actions environment.
unset( $composer_config['require-dev']['equalizedigital/accessibility-checker-wp-env'] );
} else {
// Not running in GitHub Actions, assuming local environment.
// Add your local specific packages.
$composer_config['require-dev']['equalizedigital/accessibility-checker-wp-env'] = '1.0.0';
}

file_put_contents( $composer_json_path, json_encode( $composer_config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) );

0 comments on commit 8c70a95

Please sign in to comment.