0
0
mirror of https://github.com/PHPMailer/PHPMailer.git synced 2024-09-19 17:42:14 +02:00

GH Actions: run tests on PRs and show CS violations (#2373)

* GH Actions: run on PRs and allow for manually triggering

Currently the workflow only ran on `push` events, which - as forks have to enable the workflows - means that PRs could be submitted without CI having been run and you'd only see the CI results on merge.

By adding the `pull_request` event, it is ensured that CI is always run within the main repo for pull requests. This also allows for branch protection to be enabled with "required statuses".

Additionally, triggering a workflow for a branch manually is not supported by default in GH Actions, but has to be explicitly allowed.

This is useful if, for instance, an external action script or composer dependency has broken.
Once a fix is available, failing builds for `master` or open PRs can be retriggered manually instead of having to be re-pushed to retrigger the workflow.

Ref: https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/

* GH Actions: report CS violations in the PR

Currently the PR template asks for people to run the CS tooling.

As the PHPCS tool is also run in the test workflow and this workflow - per the previous commit - will now also be run on pull requests, we can make life easier on contributors.

The cs2pr tool allows to display the results from an action run in checkstyle format in-line in the PR code view.
This commit enables this for PHPCS, which means that the code view will now show CS violations in the PR.

Ref: https://github.com/staabm/annotate-pull-request-from-checkstyle

Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
This commit is contained in:
Juliette 2021-06-23 11:03:18 +02:00 committed by GitHub
parent c33a304650
commit 711de8bf70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,10 @@
name: "Tests"
on: [push]
on:
push:
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:
jobs:
@ -20,12 +24,18 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: cs2pr
- name: Install dependencies
run: composer install --no-interaction
- name: Check coding standards
run: ./vendor/bin/phpcs -s
continue-on-error: true
run: ./vendor/bin/phpcs -s --report-full --report-checkstyle=./phpcs-report.xml
- name: Show PHPCS results in PR
run: cs2pr ./phpcs-report.xml
test:
needs: ['coding-standard']