Skip to content

CI: switch to GitHub Actions #35

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

Merged
merged 1 commit into from
Nov 4, 2021

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Nov 4, 2021

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. 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:
  4. Composer dependency downloads will be cached for faster builds using a predefined GH action 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, while transforming nightly to 8.2.

Fixes actions/toolkit#34

@jrfnl jrfnl force-pushed the feature/migrate-to-ghactions branch 2 times, most recently from 6b02821 to abf8320 Compare November 4, 2021 12:17
@jrfnl jrfnl force-pushed the feature/migrate-to-ghactions branch 2 times, most recently from a90d006 to bfb9d5f Compare November 4, 2021 13:10
@jrfnl
Copy link
Contributor Author

jrfnl commented Nov 4, 2021

Current action run results: https://github.com/jrfnl/prophecy-phpunit/actions/runs/1421377047

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.
@jrfnl jrfnl force-pushed the feature/migrate-to-ghactions branch from bfb9d5f to 0ab48a8 Compare November 4, 2021 14:24
@stof stof merged commit a65425c into phpspec:master Nov 4, 2021
@jrfnl jrfnl deleted the feature/migrate-to-ghactions branch November 4, 2021 14:27
@jrfnl jrfnl mentioned this pull request Nov 4, 2021
@jrfnl
Copy link
Contributor Author

jrfnl commented Nov 5, 2021

Thanks @stof for working with me on this. I've pulled actions/toolkit#36 and actions/toolkit#37 as next steps - haven't pulled the "widen versions" PR yet as it modifies files also modified in actions/toolkit#36 and actions/toolkit#37, so would lead to conflicts. Will pull that after.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants