Skip to content

Commit

Permalink
Merge pull request #948 from Automattic/improve/workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryJones authored Jul 23, 2023
2 parents 0e83081 + 0d0e8eb commit f066f70
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
/package-lock.json
/composer.json
/tests
/phpunit.xml
/phpunit.xml.dist
/Makefile
/phpcs.xml
/.phpcs.xml.dist
83 changes: 83 additions & 0 deletions .github/workflows/cs-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: CS & Lint

on:
# Run on all pushes and on all pull requests.
# Prevent the "push" build from running when there are only irrelevant changes.
push:
paths-ignore:
- "**.md"
pull_request:

# Allow manually triggering the workflow.
workflow_dispatch:

jobs:
checkcs:
name: "Basic CS and QA checks"
runs-on: ubuntu-latest

env:
XMLLINT_INDENT: " "

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
coverage: none
tools: cs2pr

# Show PHP lint violations inline in the file diff.
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
- name: Register PHP lint violations to appear as file diff comments
uses: korelstar/phplint-problem-matcher@v1

# Show XML violations inline in the file diff.
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
- name: Register XML violations to appear as file diff comments
uses: korelstar/xmllint-problem-matcher@v1

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

# 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

# Lint PHP.
- name: Lint PHP against parse errors
run: composer lint-ci | cs2pr

# Needed as runs-on: system doesn't have xml-lint by default.
# @link https://github.com/marketplace/actions/xml-lint
- name: Lint phpunit.xml.dist
uses: ChristophWurst/xmllint-action@v1
with:
xml-file: ./phpunit.xml.dist
xml-schema-file: ./vendor/phpunit/phpunit/phpunit.xsd

# Needed as runs-on: system doesn't have xml-lint by default.
# @link https://github.com/marketplace/actions/xml-lint
- name: Lint .phpcs.xml.dist
uses: ChristophWurst/xmllint-action@v1
with:
xml-file: ./.phpcs.xml.dist
xml-schema-file: ./vendor/squizlabs/php_codesniffer/phpcs.xsd

# This script discards Warnings, and only checks one standard, so shouldn't be considered a full PHPCS run.
- name: Run PHPCS
run: composer cs

# Check the code-style consistency of the PHP files.
# - name: Check PHP code style
# continue-on-error: true
# run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml

# - name: Show PHPCS results in PR
# run: cs2pr ./phpcs-report.xml
14 changes: 7 additions & 7 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run PHPUnit and PHPCS
name: Integration Tests

on: [push]

Expand Down Expand Up @@ -27,7 +27,7 @@ jobs:

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

- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
Expand All @@ -38,11 +38,14 @@ jobs:
coverage: ${{ matrix.coverage }}

- name: Install Composer dependencies
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v2
with:
composer-options: "${{ matrix.composer-options }}"

- name: Setup Problem Matchers for PHPUnit
- name: Set up problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: Set up problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Show PHP and PHPUnit version info
Expand All @@ -65,6 +68,3 @@ jobs:

- name: Run integration tests (multisite)
run: composer integration-ms

- name: Run PHPCS
run: composer cs
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DS_Store
.svn
.idea/
wpcom-helper.php
/node_modules/
/vendor/
/.phpcs.xml
/composer.lock
/vendor
node_modules
/phpcs.xml
/phpunit.xml
/wpcom-helper.php
File renamed without changes.
File renamed without changes.

0 comments on commit f066f70

Please sign in to comment.