PHPackages                             silverstripe/travis-support - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. silverstripe/travis-support

ActiveLibrary[Testing &amp; Quality](/categories/testing)

silverstripe/travis-support
===========================

Provides travis support for silverstripe testing

0.1.0(9y ago)1323415[5 issues](https://github.com/silverstripe/silverstripe-travis-support/issues)2BSD-3-ClausePHPCI failing

Since Aug 12Pushed 8y ago17 watchersCompare

[ Source](https://github.com/silverstripe/silverstripe-travis-support)[ Packagist](https://packagist.org/packages/silverstripe/travis-support)[ RSS](/packages/silverstripe-travis-support/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (1)Versions (4)Used By (2)

Travis Integration for SilverStripe Modules
===========================================

[](#travis-integration-for-silverstripe-modules)

[![Build Status](https://camo.githubusercontent.com/42f5e45fd10f4ec842724fc9008e1441b2f3133c39da107141c0662f2f7a9272/68747470733a2f2f7472617669732d63692e6f72672f73696c7665727374726970652d6c6162732f73696c7665727374726970652d7472617669732d737570706f72742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/silverstripe-labs/silverstripe-travis-support)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/dc94379ac044dbb4486b88b3f1073afccb641bb97d4ae435184d417b58e81e3e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73696c7665727374726970652d6c6162732f73696c7665727374726970652d7472617669732d737570706f72742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/silverstripe-labs/silverstripe-travis-support/?branch=master)[![Build Status](https://camo.githubusercontent.com/9cf83bf707154bf1b745477811f138350bc6e4f076b44ff0a47a48f0f6e794c1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73696c7665727374726970652d6c6162732f73696c7665727374726970652d7472617669732d737570706f72742f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/silverstripe-labs/silverstripe-travis-support/build-status/master)[![codecov.io](https://camo.githubusercontent.com/aa79bb3608695d5351a371085f0186643dcfe4e491f626583f9bab4c3dfe8967/68747470733a2f2f636f6465636f762e696f2f6769746875622f73696c7665727374726970652d6c6162732f73696c7665727374726970652d7472617669732d737570706f72742f636f7665726167652e7376673f6272616e63683d6d6173746572)](https://codecov.io/github/silverstripe-labs/silverstripe-travis-support?branch=master)

[![codecov.io](https://camo.githubusercontent.com/e2be7c4d118885933cf04b87fbfaeef20890816750d04021058d481c28f4946d/68747470733a2f2f636f6465636f762e696f2f6769746875622f73696c7665727374726970652d6c6162732f73696c7665727374726970652d7472617669732d737570706f72742f6272616e63682e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/e2be7c4d118885933cf04b87fbfaeef20890816750d04021058d481c28f4946d/68747470733a2f2f636f6465636f762e696f2f6769746875622f73696c7665727374726970652d6c6162732f73696c7665727374726970652d7472617669732d737570706f72742f6272616e63682e7376673f6272616e63683d6d6173746572)

Introduction
------------

[](#introduction)

[Travis](http://travis-ci.org) is an open source platform for [continuous integration](http://en.wikipedia.org/wiki/Continuous_integration), which mostly means running your unit tests every time you commit to a codebase. The platform is free for open source projects, and integrates nicely with Github. Since each SilverStripe module needs to be tested within a SilverStripe project, there's a bit of setup work required on top of the standard [Composer](http://getcomposer.org) dependency management.

The scripts allow you to test across multiple branches, and rewrite the `composer.json` to match dependencies. The scripts will test your module against multiple core releases, as well as multiple databases (if supported).

Why bother? Because it shows your users that you care about the quality of your codebase, and gives them a clear picture of the current status of it. And it helps you manage the complexity of coding against multiple databases, SilverStripe core releases and other dependencies.

Haven't written unit tests yet? Then it's high time you get started with the [SilverStripe Testing Guide](http://doc.silverstripe.org/framework/en/topics/testing/).

Composer Setup
--------------

[](#composer-setup)

Since this script works based on [Composer](http://getcomposer.org), you need to add some metadata to your module. Copy the `composer.json` into the root directory of your module and adjust it to suit your needs. If you have mulitple branches in your module which support different core releases, then commit the file to each of those branches. Ensure you set the right [dependency versions](http://getcomposer.org/doc/01-basic-usage.md#package-versions).

Don't have branches? You really should, so your users can trust in the stability of releases, and have clear guidance on dependencies. Read on [semver.org](http://semver.org/) for details on version numbering.

Abbreviated `composer.json` for a branch supporting SS 2.4 only:

```
{
  "name":"some-vendor-prefix/my-awesome-module",
  ...
  'require': {"silverstripe/framework": "2.4.*", "silverstripe/cms": "2.4.*"}
}
```

Abbreviated `composer.json` for a branch supporting SS 3.0 and newer:

```
{
  "name":"some-vendor-prefix/my-awesome-module",
  ...
  'require': {"silverstripe/framework": "~3.0", "silverstripe/cms": "~3.0"}
}
```

Now commit those files to the various module branches, and register them on [Packagist](http://packagist.org)so they're discoverable by Composer.

Travis Setup
------------

[](#travis-setup)

The free [Travis](http://travis-ci.com/) CI service is configured by placing a hidden `.travis.yml` file into the root of your module (read me about the [Travis YML format](http://about.travis-ci.org/docs/user/build-configuration)).

Here's an example `.travis.yml`:

```
language: php
php:
- 5.3

env:
matrix:
 - DB=MYSQL CORE_RELEASE=3.0
 - DB=MYSQL CORE_RELEASE=3.1
 - DB=MYSQL CORE_RELEASE=master
 - DB=PGSQL CORE_RELEASE=master

matrix:
include:
  - php: 5.4
    env: DB=MYSQL CORE_RELEASE=master

before_script:
- phpenv rehash
- composer self-update
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
- cd ~/builds/ss

script:
- vendor/bin/phpunit /tests/
```

When getting set up, to avoid repeatedly pushing to trigger the service hook, you should [save time by linting your configuration with Travis WebLint](https://lint.travis-ci.org/).

Now adjust the `` path in `.travis.yml`, in the example above it would be `my-awesome-module`. Adjust the supported PHP versions, SS core versions and databases in `.travis.yml` (read more about the [Travis PHP config](http://about.travis-ci.org/docs/user/languages/php/)). Consider [blacklisting or whitelisting](http://about.travis-ci.org/docs/user/build-configuration/#The-Build-Matrix) builds to keep the number of individual builds to a reasonable level.

The sample file above will run the following builds:

- DB=MYSQL CORE\_RELEASE=3.0, php: 5.3
- DB=MYSQL CORE\_RELEASE=3.1, php: 5.3
- DB=MYSQL CORE\_RELEASE=master, php: 5.3
- DB=PGSQL CORE\_RELEASE=master, php: 5.3
- DB=MYSQL CORE\_RELEASE=master, php: 5.4

After you committed the files, as a final step you'll want to enable your module on travis-ci.org. The first builds should start within a few minutes.

As a bonus, you can include build status images in your README to promote the fact that your module values quality and does continuous integration.

Adding extra modules
--------------------

[](#adding-extra-modules)

If you need to add extra modules during setup, that aren't explicitly included in the module composer requirements, you can use the `--require` parameter.

E.g.

```
php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/behat-extension

```

You can also specify multiple modules by either comma separating the names, or by the addition of multiple `--require` flags. Each name can also be suffixed with `:` to add a version dependency.

E.g.

```
php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/behat-extension:dev-master --require silverstripe-cms:4.0.x-dev

```

or equivalently

```
php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/behat-extension:dev-master,silverstripe-cms:4.0.x-dev

```

PDO DB Connectors
-----------------

[](#pdo-db-connectors)

Many database connectors support connection via PDO. If you would like to include PDO support you can also add the PDO=1 environment variable.

Note that this feature is only supported in SilverStripe 3.2 or later and will be ignored in 3.1 or below

```
env:
  matrix:
    - DB=MYSQL CORE_RELEASE=3.2 PDO=1
    - DB=MYSQL CORE_RELEASE=3.2
```

Working with Pull Requests
--------------------------

[](#working-with-pull-requests)

The logic relies on pulling in different core releases based on the `CORE_RELEASE` constant. This can lead to inconsistencies where pull requests rely on other branches, for example where a pull request for the `cms` module relies on an equivalent in the `framework` module. While there's no clean way to tell Travis which branches to use, temporary modifications to `travis.yml` can help prove a build is passing with the right dependencies.

- Add custom fork `repositories` to your module's `composer.json`. They'll get pulled up into the root `composer.json` automatically
- Set the `CORE_RELEASE` environment variable to the branch name on your fork.
- Create branches with the same name on both `cms` and `framework` modules
- Either create a branch on `installer`, or set a different `CORE_INSTALLER_RELEASE` environment variable
- Set a `CORE_ALIAS` environment variable in order to satisfy [constrains](https://getcomposer.org/doc/articles/aliases.md) (e.g. `4.0.x-dev`)

Note that these `.travis.yml` changes in your fork are temporary, and need to be reverted before the pull request will be merged. Unfortunately Travis CI doesn't support per-build configuration settings outside of version control.

Github Rate Limitation
----------------------

[](#github-rate-limitation)

Composer heavily relies on github's APIs for retrieving repository info and downloading archives. Github has a low rate limitation for unauthenticated requests. This means depending on how often your builds run (and the amount of executed API requests per build), your build can fail because of these side effects.

This script supports a `GITHUB_API_TOKEN` value. If set, it'll write it to a global composer configuration ([details](http://blog.simplytestable.com/creating-and-using-a-github-oauth-token-with-travis-and-composer/)). It can optionally be encrypted through Travis' [secure environment variables](http://about.travis-ci.org/docs/user/build-configuration/#Secure-environment-variables).

In order to activate the configuration, add an entry to `env.global` in your `.travis.yml`:

```
env:
  global:
    - GITHUB_API_TOKEN=
  matrix:
    - ...
```

Alternatively you can add the Token through the Travis CI web interface for your repo under the "settings" area.

Behat and Selenium
------------------

[](#behat-and-selenium)

The scripts also allow behaviour testing through [Behat](http://behat.org). The easiest way to get this going is through a locally running Selenium server and PHP's built-in webserver. Here's a sample setup:

```
language: php

matrix:
  include:
    - php: 5.3
      env: DB=MYSQL CORE_RELEASE=3.1
    - php: 5.4
      env: DB=MYSQL CORE_RELEASE=3.1 BEHAT_TEST=1

before_script:
 - composer self-update
 - phpenv rehash
 - git clone -b tmp/travis-artifacts git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
 - "if [ \"$BEHAT_TEST\" = \"\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss; fi"
 - "if [ \"$BEHAT_TEST\" = \"1\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/behat-extension; fi"
 - cd ~/builds/ss
 - php ~/travis-support/travis_setup_selenium.php --if-env BEHAT_TEST
 - php ~/travis-support/travis_setup_php54_webserver.php --if-env BEHAT_TEST

script:
 - "if [ \"$BEHAT_TEST\" = \"\" ]; then vendor/bin/phpunit framework/tests; fi"
 - "if [ \"$BEHAT_TEST\" = \"1\" ]; then vendor/bin/behat @framework; fi"
```

Artifacts Upload
----------------

[](#artifacts-upload)

Since Travis builds are stateless, you can't inspect anything apart from the actual build log after the build has finished. This is an issue for larger files like server logs, and of course for images.

You can use  for this purpose, allowing upload to Amazon S3. Since Behat creates screenshots of any failed test step already, this is a useful addition to any Behat script. The `behat.yml` created through `travis_setup_selenium.php` is already set up to save its screenshots into `artifacts/screenshots/`.

```
language: php

env:
  global:
    - ARTIFACTS_REGION=us-east-1
    - ARTIFACTS_BUCKET=silverstripe-travis-artifacts
    - secure: "..." # Encrypted ARTIFACTS_KEY
    - secure: "..." # Encrypted ARTIFACTS_SECRET

matrix:
  include:
    - ...

before_script:
 - ...

script:
 - ...

after_script:
 - php ~/travis-support/travis_upload_artifacts.php --if-env BEHAT_TEST,ARTIFACTS_BUCKET,ARTIFACTS_KEY,ARTIFACTS_SECRET --target-path artifacts/$TRAVIS_REPO_SLUG/$TRAVIS_BUILD_ID/$TRAVIS_JOB_ID --artifacts-base-url https://s3.amazonaws.com/$ARTIFACTS_BUCKET/
```

Troubleshooting
---------------

[](#troubleshooting)

### Testing travis\_setup.php locally

[](#testing-travis_setupphp-locally)

While its not 100% accurate, you can get pretty close to reproducing Travis' behaviour on your own environment. Just look at the CLI output from a previous travis build to get started. Here's an example on building a specific commit on the `1.0` branch of the `translatable` module:

```
export TRAVIS_BRANCH=1.0
export TRAVIS_COMMIT=dd792af2fba119cfa22423203dd9f2e70676e651
export TRAVIS_REPO_SLUG=silverstripe/silverstripe-translatable
export DB=MYSQL
export CORE_RELEASE=3.0
git clone --depth=50 --branch=1.0 git://github.com/silverstripe/silverstripe-translatable.git silverstripe/silverstripe-translatable
cd silverstripe/silverstripe-translatable
git checkout -qf dd792af2fba119cfa22423203dd9f2e70676e651
git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
cd ~/builds/ss
phpunit translatable/tests
```

Note: Each SilverStripe module only works as a subfolder in the context of a SilverStripe project, and requires at least the SilverStripe framework. So we need to ensure the plain module checkout which Travis performs by defaults get rewritten to this.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance12

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community29

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3634d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b0cba8b534e20e6ab4fff555a97b237a18436ebca1446fc0b29c8a8b504038b9?d=identicon)[GuySartorelli](/maintainers/GuySartorelli)

![](https://www.gravatar.com/avatar/be6648e60fbab6f70bfc34dd8c14259562d28a47510a934ea9c01fe98633f3c2?d=identicon)[sminnee](/maintainers/sminnee)

---

Top Contributors

[![chillu](https://avatars.githubusercontent.com/u/111025?v=4)](https://github.com/chillu "chillu (52 commits)")[![dhensby](https://avatars.githubusercontent.com/u/563596?v=4)](https://github.com/dhensby "dhensby (22 commits)")[![lozcalver](https://avatars.githubusercontent.com/u/1655548?v=4)](https://github.com/lozcalver "lozcalver (4 commits)")[![halkyon](https://avatars.githubusercontent.com/u/138450?v=4)](https://github.com/halkyon "halkyon (2 commits)")[![wilr](https://avatars.githubusercontent.com/u/101629?v=4)](https://github.com/wilr "wilr (2 commits)")[![willmorgan](https://avatars.githubusercontent.com/u/168688?v=4)](https://github.com/willmorgan "willmorgan (1 commits)")[![assertchris](https://avatars.githubusercontent.com/u/200609?v=4)](https://github.com/assertchris "assertchris (1 commits)")[![zanderwar](https://avatars.githubusercontent.com/u/13566916?v=4)](https://github.com/zanderwar "zanderwar (1 commits)")[![gordonbanderson](https://avatars.githubusercontent.com/u/7060?v=4)](https://github.com/gordonbanderson "gordonbanderson (1 commits)")[![micmania1](https://avatars.githubusercontent.com/u/881537?v=4)](https://github.com/micmania1 "micmania1 (1 commits)")[![robbieaverill](https://avatars.githubusercontent.com/u/5170590?v=4)](https://github.com/robbieaverill "robbieaverill (1 commits)")[![UndefinedOffset](https://avatars.githubusercontent.com/u/1391558?v=4)](https://github.com/UndefinedOffset "UndefinedOffset (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/silverstripe-travis-support/health.svg)

```
[![Health](https://phpackages.com/badges/silverstripe-travis-support/health.svg)](https://phpackages.com/packages/silverstripe-travis-support)
```

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14228.7M342](/packages/dms-phpunit-arraysubset-asserts)[phpbenchmark/phpbenchmark

Easy to use benchmark toolkit for your PHP-application. This library contains classes for comparing algorithms as well as benchmarking application responses

8011.5k2](/packages/phpbenchmark-phpbenchmark)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
