-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Added a good example of a travis file #8701
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
Changes from all commits
465d702
c990fea
aa3283a
6b805cf
5803fd0
5848ff6
f1a0439
83daf5d
33aa6a7
3671cbd
8613f1d
e11b677
5bacbd5
14f96a9
165bcf7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,6 +166,80 @@ the ``Tests/`` directory. Tests should follow the following principles: | |
A test suite must not contain ``AllTests.php`` scripts, but must rely on the | ||
existence of a ``phpunit.xml.dist`` file. | ||
|
||
Continuous Integration | ||
---------------------- | ||
|
||
Testing bundle code continuously, including all its commits and pull requests, | ||
is a good practice called Continuous Integration. There are several services | ||
providing this feature for free for open source projects. The most popular | ||
service for Symfony bundles is called `Travis CI`_. | ||
|
||
Here is the recommended configuration file (``.travis.yml``) for Symfony bundles, | ||
which test the two latest :doc:`LTS versions </contributing/community/releases>` | ||
of Symfony and the latest beta release: | ||
|
||
.. code-block:: yaml | ||
|
||
language: php | ||
sudo: false | ||
cache: | ||
directories: | ||
- $HOME/.composer/cache/files | ||
- $HOME/symfony-bridge/.phpunit | ||
|
||
env: | ||
global: | ||
- PHPUNIT_FLAGS="-v" | ||
- SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit" | ||
|
||
matrix: | ||
fast_finish: true | ||
include: | ||
# Minimum supported dependencies with the latest and oldest PHP version | ||
- php: 7.2 | ||
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak" | ||
- php: 7.0 | ||
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak" | ||
|
||
# Test the latest stable release | ||
- php: 7.0 | ||
- php: 7.1 | ||
- php: 7.2 | ||
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text" | ||
|
||
# Test LTS versions. This makes sure we do not use Symfony packages with version greater | ||
# than 2 or 3 respectively. Read more at https://github.com/symfony/lts | ||
- php: 7.2 | ||
env: DEPENDENCIES="symfony/lts:^2" | ||
- php: 7.2 | ||
env: DEPENDENCIES="symfony/lts:^3" | ||
|
||
# Latest commit to master | ||
- php: 7.2 | ||
env: STABILITY="dev" | ||
|
||
allow_failures: | ||
# Dev-master is allowed to fail. | ||
- env: STABILITY="dev" | ||
|
||
before_install: | ||
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi | ||
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi; | ||
- if ! [ -v "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi; | ||
|
||
install: | ||
# To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355 | ||
- if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi | ||
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction | ||
- ./vendor/bin/simple-phpunit install | ||
|
||
script: | ||
- composer validate --strict --no-check-lock | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whats the point of this? wouldn't composer update fail if the composer.json is invalid which is run before anyway? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. afaik the |
||
- ./vendor/bin/simple-phpunit $PHPUNIT_FLAGS | ||
|
||
Consider using `Travis cron`_ too to make sure your project is built even if | ||
there are no new pull requests or commits. | ||
|
||
Installation | ||
------------ | ||
|
||
|
@@ -476,3 +550,5 @@ Learn more | |
.. _`Packagist`: https://packagist.org/ | ||
.. _`choose any license`: http://choosealicense.com/ | ||
.. _`valid license identifier`: https://spdx.org/licenses/ | ||
.. _`Travis CI`: https://travis-ci.org/ | ||
.. _`Travis Cron`: https://docs.travis-ci.com/user/cron-jobs/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC
sudo
is no longer requiredThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some searching just now. I cannot find any references to this.. Can you provide a link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before sudo was enabled by default and there was a deprecation for a while stating if you want sudo you need to explicitly require it. You can see here that if you do need sudo, you should put
sudo: required
. Might be worth to double check what the actual default is thoughThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, Same page says:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends on the build distribution, see here. Newer builds, or builds explicitly using
dist: trusty
will ignore thesudo:
setting.