Skip to content

Commit a9ef13c

Browse files
jrfnlgrogy
authored andcommitted
CI: switch to GitHub Actions
This commit: * Adds a GH Actions `cs` workflow for the code style and vardump checks which were previously run on Travis. These checks only need to run against one PHP version as the results will be the same independently of the PHP version these checks are run on. * Adds a GH Actions `test` workflow for the linting and unit test checks which were previously run on Travis. * Uses the [`cs2pr`](https://github.com/staabm/annotate-pull-request-from-checkstyle) tool to display the results of the PHP linting and the results of the PHP code style check in-line in the file diff in the PR. * 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.
1 parent 8343a8b commit a9ef13c

File tree

5 files changed

+94
-42
lines changed

5 files changed

+94
-42
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
/tests export-ignore
33
.gitattributes export-ignore
44
.gitignore export-ignore
5-
.travis.yml export-ignore
5+
/.github export-ignore
66
phpunit.xml.dist export-ignore
77
phpcs.xml.dist export-ignore

.github/workflows/cs.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CS
2+
3+
on:
4+
push:
5+
pull_request:
6+
# Allow manually triggering the workflow.
7+
workflow_dispatch:
8+
9+
jobs:
10+
checkcs:
11+
name: 'Check code style'
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
18+
- name: Install PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: '7.4'
22+
coverage: none
23+
tools: cs2pr
24+
25+
# Install dependencies and handle caching in one go.
26+
# @link https://github.com/marketplace/actions/install-composer-dependencies
27+
- name: Install Composer dependencies
28+
uses: "ramsey/composer-install@v1"
29+
30+
- name: Check PHP code style
31+
continue-on-error: true
32+
run: vendor/bin/phpcs --report-full --report-checkstyle=./checkstyle.xml
33+
34+
- name: Show PHPCS results in PR
35+
run: cs2pr ./checkstyle.xml --graceful-warnings
36+
37+
- name: Make sure no vardumps remain
38+
run: composer vardumpcheck

.github/workflows/test.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
push:
6+
# Allow manually triggering the workflow.
7+
workflow_dispatch:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
16+
experimental: [false]
17+
18+
include:
19+
- php: '8.1'
20+
experimental: true
21+
22+
name: "Test on PHP ${{ matrix.php }}"
23+
continue-on-error: ${{ matrix.experimental }}
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v2
28+
29+
- name: Setup PHP
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: ${{ matrix.php }}
33+
coverage: none
34+
tools: cs2pr
35+
36+
# Install dependencies and handle caching in one go.
37+
# @link https://github.com/marketplace/actions/install-composer-dependencies
38+
- name: Install Composer dependencies - normal
39+
if: ${{ matrix.experimental == false }}
40+
uses: "ramsey/composer-install@v1"
41+
42+
# For the PHP "nightly", we need to install with ignore platform reqs as not all dependencies allow it.
43+
- name: Install Composer dependencies - with ignore platform
44+
if: ${{ matrix.experimental == true }}
45+
uses: "ramsey/composer-install@v1"
46+
with:
47+
composer-options: --ignore-platform-reqs
48+
49+
- name: Lint
50+
run: composer phplint -- --checkstyle | cs2pr
51+
52+
- name: Run unit tests
53+
run: composer phpunit

.travis.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ echo $highlighter->getWholeFile($fileContent);
3232
------
3333

3434
[![Downloads this Month](https://img.shields.io/packagist/dm/php-parallel-lint/php-console-highlighter.svg)](https://packagist.org/packages/php-parallel-lint/php-console-highlighter)
35-
[![Build Status](https://travis-ci.org/php-parallel-lint/PHP-Console-Highlighter.svg?branch=master)](https://travis-ci.org/php-parallel-lint/PHP-Console-Highlighter)
35+
[![CS](https://github.com/php-parallel-lint/PHP-Console-Highlighter/actions/workflows/cs.yml/badge.svg)](https://github.com/php-parallel-lint/PHP-Console-Highlighter/actions/workflows/cs.yml)
36+
[![Test](https://github.com/php-parallel-lint/PHP-Console-Highlighter/actions/workflows/test.yml/badge.svg)](https://github.com/php-parallel-lint/PHP-Console-Highlighter/actions/workflows/test.yml)
3637
[![License](https://poser.pugx.org/php-parallel-lint/php-console-highlighter/license.svg)](https://packagist.org/packages/php-parallel-lint/php-console-highlighter)

0 commit comments

Comments
 (0)