Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Improve CI and testing #941

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### Summary
<!-- Please describe the changes you made. -->

### Will affect the visual aspect of the product
<!-- It includes visual changes? -->
YES/NO

### Screenshots <!-- if applicable -->

### Test instructions
<!-- Describe how this pull request can be tested. -->

-
-

## Check before Pull Request is ready:

* [ ] I have [written a test](CONTRIBUTING.md#writing-an-acceptance-test) and included it in this PR
* [ ] I have [run all tests](CONTRIBUTING.md#run-tests) and they pass
* [ ] The code passes when [running the PHP CodeSniffer](CONTRIBUTING.md#run-php-codesniffer)
* [ ] Code meets [WordPress Coding Standards](CONTRIBUTING.md#coding-standards) for PHP, HTML, CSS and JS
* [ ] [Security and Sanitization](CONTRIBUTING.md#security-and-sanitization) requirements have been followed
* [ ] I have assigned a reviewer or two to review this PR (if you're not sure who to assign, we can do this step for you)

<!-- Issues that this pull request closes. -->
Closes #.
<!-- Should look like this: `Closes #1, #2, #3.` . -->
26 changes: 26 additions & 0 deletions .github/workflows/pr-checklist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Add labels to pull request based on checklist

on:
pull_request:
types: [ opened, edited, synchronize, labeled, unlabeled ]
branches-ignore:
- 'master'
- 'update_dependencies'

permissions: write-all

jobs:
add-labels:
runs-on: ubuntu-latest
name: Label PR based on checklist
if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name && github.actor != 'dependabot[bot]'
steps:
- name: Check if checklist items are completed
uses: Codeinwp/gha-pr-check-helper@master
with:
token: ${{ secrets.BOT_TOKEN }}
requireChecklist: true
onlyCheckBody: true
completedLabel: "pr-checklist-complete"
incompleteLabel: "pr-checklist-incomplete"
skipLabel: "pr-checklist-skip"
50 changes: 35 additions & 15 deletions .github/workflows/test-php.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,52 @@
name: Test PHP

concurrency:
group: ${{ github.head_ref }}
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true

on:
pull_request:
branches:
- master
- development
push:
branches-ignore:
- 'master'

jobs:
code-sniff:
name: PHP Lint
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
with:
php-version: '7.4'
tools: phpcs, phpcbf
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Setup Composer cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Run Composer Install
run: composer install --prefer-dist --no-progress --quiet
- name: Run PHPCBF
run: composer run format
# PHPCBF returns exit code 1 when it fixes errors, so we continue letting PHPCS find unfixed issues
continue-on-error: true
- name: Run PHPCS
run: composer run lint
continue-on-error: false


php-unit:
needs: code-sniff
php-unit:
name: PHPUnit
needs: code-sniff
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306/tcp
Expand All @@ -52,7 +61,18 @@ jobs:
tools: phpunit-polyfills
- name: Install WordPress Test Suite
run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1:${{ job.services.mysql.ports['3306'] }}
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Setup Composer cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install composer
run: composer install --prefer-dist --no-progress
- name: Run PHP Unit
run: composer run test
run: composer run test
Loading
Loading