Skip to content

Commit

Permalink
CI: switch to GitHub Actions
Browse files Browse the repository at this point in the history
This commit:
* Adds a GH Actions workflow for the CI checks which were previously run on Travis.
* Removes the, now redundant, `.travis.yml` configuration.
* Updates the `.gitattributes` file.
* Updates the "Build Status" badge in the Readme to use the results from the GH Actions runs.

Notes:
1. Builds will run on pushes to `master` and on pull requests.
    For a small repo like this, running on all _pushes_ seems redundant.
2. The build will automatically be triggered once a month (was previously also done on Travis) to make sure that upstream changes to the polyfills themselves will not go unnoticed if they impact the ruleset.
3. If the XMLLint "stage" fails, the test _stage_ will be skipped.
    Reasoning: if there is a syntax error in the XML, the tests will fail anyhow.
4. The build against PHPCompatibility `dev-develop` should be allowed to fail, which is why is it marked as `experimental` and why `continue-on-error` checks that value.
    When updating the "required statuses", that particular build should **not** get a checkmark.
    That way, all builds will run, but a failure of the build on the `dev-develop` branch will not block merging of PRs.
  • Loading branch information
jrfnl committed Dec 16, 2020
1 parent 674ed5d commit b5528dc
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 61 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Expand Up @@ -4,7 +4,6 @@
#
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/.github/ export-ignore
/Test/ export-ignore

Expand Down
95 changes: 95 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,95 @@
name: CI

on:
# Run on pushes to `master` and on all pull requests.
push:
branches:
- master
pull_request:
# Also run this workflow on day 15 of every month as the repo isn't that active.
schedule:
- cron: '0 0 15 * *'

jobs:
xmllint:
name: 'Check XML'
runs-on: ubuntu-latest

env:
XMLLINT_INDENT: ' '

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

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

# Install dependencies to make sure the PHPCS XSD file is available.
- name: Install dependencies
run: composer install --no-dev --no-interaction --no-progress

- name: Setup xmllint
run: sudo apt-get install --no-install-recommends -y libxml2-utils

# Show violations inline in the file diff.
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
- uses: korelstar/xmllint-problem-matcher@v1

# Validate the xml file.
# @link http://xmlsoft.org/xmllint.html
- name: Validate against schema
run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd PHPCompatibilityWP/ruleset.xml

# Check the code-style consistency of the xml file.
- name: Check code style
run: diff -B ./PHPCompatibilityWP/ruleset.xml <(xmllint --format "./PHPCompatibilityWP/ruleset.xml")

test:
needs: xmllint
runs-on: ubuntu-latest

strategy:
matrix:
php: ['5.4', 'latest']
phpcompat: ['stable']
experimental: [false]

include:
- php: '7.4'
phpcompat: 'dev-develop as 9.99.99'
experimental: true

name: "Test: PHP ${{ matrix.php }} - PHPCompat ${{ matrix.phpcompat }}"
continue-on-error: ${{ matrix.experimental }}

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

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

- name: Conditionally update PHPCompatibility to develop version
if: ${{ matrix.phpcompat != 'stable' }}
run: |
composer config minimum-stability dev
composer require --no-update phpcompatibility/php-compatibility:"${{ matrix.phpcompat }}"
- name: Install dependencies
run: composer install --no-interaction --no-progress

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

# Make sure that known polyfills don't trigger any errors.
- name: Test the ruleset
run: vendor/bin/phpcs -ps ./Test/WPTest.php --standard=PHPCompatibilityWP --runtime-set testVersion 5.2-
59 changes: 0 additions & 59 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
@@ -1,7 +1,7 @@
[![Latest Stable Version](https://poser.pugx.org/phpcompatibility/phpcompatibility-wp/v/stable.png)](https://packagist.org/packages/phpcompatibility/phpcompatibility-wp)
[![Latest Unstable Version](https://poser.pugx.org/phpcompatibility/phpcompatibility-wp/v/unstable.png)](https://packagist.org/packages/phpcompatibility/phpcompatibility-wp)
[![License](https://poser.pugx.org/phpcompatibility/phpcompatibility-wp/license.png)](https://github.com/PHPCompatibility/PHPCompatibilityWP/blob/master/LICENSE)
[![Build Status](https://travis-ci.org/PHPCompatibility/PHPCompatibilityWP.svg?branch=master)](https://travis-ci.org/PHPCompatibility/PHPCompatibilityWP)
[![Build Status](https://github.com/PHPCompatibility/PHPCompatibilityWP/workflows/CI/badge.svg?branch=master)](https://github.com/PHPCompatibility/PHPCompatibilityWP/actions)

# PHPCompatibilityWP

Expand Down

0 comments on commit b5528dc

Please sign in to comment.