Skip to content

Commit a90d006

Browse files
committed
CI: switch to GitHub Actions
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 all pushes and on pull requests. Builds can also be manually triggered. Note: manual triggering of builds has to be [explicitly allowed](https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/). This is not a feature which is enabled by default. 2. If a previous GH actions run for the same branch hadn't finished yet when the same branch is pushed again, the previous run will be cancelled. In Travis, this was an option on the "Settings" page - "Auto cancellation" -, which was turned on for most, if not all, repos. The `concurrency` configuration in the GHA script emulates the same behaviour. 3. The default ini settings used by the `setup-php` action are based on the `php.ini-production` configuration. This means that `error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT`, `display_errors` is set to `Off` and `zend.assertions` is set to `-1` (= do not compile). For the purposes of CI, especially for linting and testing code, I'd recommend running with `zend.assertions=-1, `error_reporting=-1` and `display_errors=On` to ensure **all** PHP notices are shown. Note: the defaults will be changed in the next major of `setup-php` to be based on the `php.ini-develop` configuration, but that may still be a while off. Refs: * shivammathur/setup-php#450 * shivammathur/setup-php#469 4. Composer dependency downloads will be cached for faster builds using a [predefined GH action](https://github.com/marketplace/actions/install-composer-dependencies) specifically created for this purpose. The alternative would be to handle the caching manually, which would add three extra steps to the script. Note: Caching works differently between Travis and GH Actions. On GH Actions, once a cache has been created, it can't be updated. It can only be replaced by a new cache with a different key. As the PHP version, the `composer.json` and a potential `composer.lock` hash are all part of the key used by the above mentioned action, this difference should not have a significant impact. Ref: https://docs.github.com/en/actions/advanced-guides/caching-dependencies-to-speed-up-workflows Includes adding new builds against PHP 8.0 and 8.1.
1 parent d574926 commit a90d006

File tree

4 files changed

+63
-21
lines changed

4 files changed

+63
-21
lines changed

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/.gitattributes export-ignore
22
/.gitignore export-ignore
3-
/.travis.yml export-ignore
3+
/.github/ export-ignore
44
/CONTRIBUTING.md export-ignore
55
/fixtures/ export-ignore
66
/phpunit.xml.dist export-ignore

.github/workflows/ci.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
# Allow manually triggering the workflow.
7+
workflow_dispatch:
8+
9+
# Cancels all previous workflow runs for the same branch that have not yet completed.
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
check_composer:
16+
name: Check composer.json
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v2
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: '8.0'
26+
coverage: none
27+
28+
- name: Validate composer.json
29+
run: composer validate --strict --no-check-lock
30+
31+
test:
32+
runs-on: ubuntu-latest
33+
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
php: ['7.3', '7.4', '8.0', '8.1']
38+
39+
name: PHP ${{ matrix.php }}
40+
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v2
44+
45+
- name: Setup PHP
46+
uses: shivammathur/setup-php@v2
47+
with:
48+
php-version: ${{ matrix.php }}
49+
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
50+
coverage: xdebug
51+
52+
- name: Validate Composer installation
53+
run: composer validate --no-check-all --strict
54+
55+
# Install dependencies and handle caching in one go.
56+
# @link https://github.com/marketplace/actions/install-composer-dependencies
57+
- name: Install Composer dependencies
58+
uses: "ramsey/composer-install@v1"
59+
60+
- name: Execute Unit Tests
61+
run: vendor/bin/phpunit --coverage-text

.travis.yml

-19
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Prophecy
22

3-
[![Build Status](https://travis-ci.org/phpspec/prophecy-phpunit.png?branch=master)](https://travis-ci.org/phpspec/prophecy-phpunit)
3+
[![Build Status](https://github.com/phpspec/prophecy-phpunit/actions/workflows/test.yml/badge.svg)](https://github.com/phpspec/prophecy-phpunit/actions/workflows/test.yml)
44

55
Prophecy PhpUnit integrates the [Prophecy](https://github.com/phpspec/prophecy) mocking
66
library with [PHPUnit](https://phpunit.de) to provide an easier mocking in your testsuite.

0 commit comments

Comments
 (0)