Skip to content

Commit 14f7db9

Browse files
committed
minor #8701 Added a good example of a travis file (Nyholm, javiereguiluz)
This PR was submitted for the master branch but it was merged into the 4.0 branch instead (closes #8701). Discussion ---------- Added a good example of a travis file After a lot of discussions with people at Symfony con I came up with a "perfect" travis file. See php-http/client-common#90 (comment) for info. Btw, should I make a table explaining what we really test? (Like on the client-common PR) Commits ------- 93bdb86 Rewords 4bd8e65 Minor updates bc9a43f use ./ before vendor ae322b7 typo 1017897 Using better cache syntax 36ca90b Using PHPUNIT_FLAGS 18e4a18 Added back php-versions 05bf09d Moved coverage to PHP 7.2 with latest deps bfdd064 Fixed minor things 3e2b876 Fixed typos and created more variables a62bcb7 Added comment and install simple-phpunit deps 65f91df Use tilde or composer validate will never pass 179abb0 Updated according to feedback a281604 Typo 2418834 Added a good example travis file
2 parents 89e2427 + 93bdb86 commit 14f7db9

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

bundles/best_practices.rst

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,80 @@ the ``Tests/`` directory. Tests should follow the following principles:
166166
A test suite must not contain ``AllTests.php`` scripts, but must rely on the
167167
existence of a ``phpunit.xml.dist`` file.
168168

169+
Continuous Integration
170+
----------------------
171+
172+
Testing bundle code continuously, including all its commits and pull requests,
173+
is a good practice called Continuous Integration. There are several services
174+
providing this feature for free for open source projects. The most popular
175+
service for Symfony bundles is called `Travis CI`_.
176+
177+
Here is the recommended configuration file (``.travis.yml``) for Symfony bundles,
178+
which test the two latest :doc:`LTS versions </contributing/community/releases>`
179+
of Symfony and the latest beta release:
180+
181+
.. code-block:: yaml
182+
183+
language: php
184+
sudo: false
185+
cache:
186+
directories:
187+
- $HOME/.composer/cache/files
188+
- $HOME/symfony-bridge/.phpunit
189+
190+
env:
191+
global:
192+
- PHPUNIT_FLAGS="-v"
193+
- SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit"
194+
195+
matrix:
196+
fast_finish: true
197+
include:
198+
# Minimum supported dependencies with the latest and oldest PHP version
199+
- php: 7.2
200+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak"
201+
- php: 7.0
202+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak"
203+
204+
# Test the latest stable release
205+
- php: 7.0
206+
- php: 7.1
207+
- php: 7.2
208+
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text"
209+
210+
# Test LTS versions. This makes sure we do not use Symfony packages with version greater
211+
# than 2 or 3 respectively. Read more at https://github.com/symfony/lts
212+
- php: 7.2
213+
env: DEPENDENCIES="symfony/lts:^2"
214+
- php: 7.2
215+
env: DEPENDENCIES="symfony/lts:^3"
216+
217+
# Latest commit to master
218+
- php: 7.2
219+
env: STABILITY="dev"
220+
221+
allow_failures:
222+
# Dev-master is allowed to fail.
223+
- env: STABILITY="dev"
224+
225+
before_install:
226+
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
227+
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
228+
- if ! [ -v "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;
229+
230+
install:
231+
# To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355
232+
- if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi
233+
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
234+
- ./vendor/bin/simple-phpunit install
235+
236+
script:
237+
- composer validate --strict --no-check-lock
238+
- ./vendor/bin/simple-phpunit $PHPUNIT_FLAGS
239+
240+
Consider using `Travis cron`_ too to make sure your project is built even if
241+
there are no new pull requests or commits.
242+
169243
Installation
170244
------------
171245

@@ -476,3 +550,5 @@ Learn more
476550
.. _`Packagist`: https://packagist.org/
477551
.. _`choose any license`: http://choosealicense.com/
478552
.. _`valid license identifier`: https://spdx.org/licenses/
553+
.. _`Travis CI`: https://travis-ci.org/
554+
.. _`Travis Cron`: https://docs.travis-ci.com/user/cron-jobs/

0 commit comments

Comments
 (0)