forked from consolidation/robo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.travis.yml
123 lines (113 loc) · 4.17 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
dist: trusty
language: php
branches:
# Only test the master branch and SemVer tags.
only:
- master
- /^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+.*$/
matrix:
include:
- php: 7.1
env: dependencies=highest DO_POST_BUILD_ACTIONS=1
- php: 7.0.11
- php: 5.6
- php: 5.5
env: dependencies=lowest
sudo: false
cache:
directories:
- $HOME/.composer/cache
before_script:
# Do highest/lowest testing by installing dependencies per the 'dependencies' setting
- if [ -z "$dependencies" ]; then composer install --prefer-dist; fi;
- if [ "$dependencies" = "lowest" ]; then composer update --prefer-dist --prefer-lowest -n; fi;
- if [ "$dependencies" = "highest" ]; then composer update --prefer-dist -n; fi;
script:
- ./robo test --coverage
- ./robo sniff -n
after_success:
- travis_retry php vendor/bin/coveralls -v
- |
# Only do post-build actions in one environment, and only if there is a GITHUB token.
if [ -z "$DO_POST_BUILD_ACTIONS" ] ; then
return
fi
if [ -z "$GITHUB_TOKEN" ]; then
echo "No GITHUB_TOKEN defined; exiting."
return
fi
# Inject GITHUB_TOKEN into remote origin so that we have push access
# to merge or create a pull request
remote=$(git config --get remote.origin.url)
git remote set-url origin "${remote/github.com/$GITHUB_TOKEN:x-oauth-basic@github.com}"
# If this is a PR that merges into the master branch, then try to merge it if it contains only composer.lock
# n.b. TRAVIS_BRANCH is the branch the pull request will merge into. TRAVIS_PULL_REQUEST_BRANCH
# is the branch that holds the commits for the pull request.
if [ -n "$TRAVIS_COMMIT_RANGE" ] && [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ] && [ "master" == "$TRAVIS_BRANCH" ]; then
changed_files=$(git diff --name-status "$TRAVIS_COMMIT_RANGE" | tr '\t' ' ')
if [[ "$changed_files" == "M composer.lock" ]] ; then
(
echo "Only composer.lock was modified: auto-merging to $TRAVIS_BRANCH in repository $remote."
git status
git reset "$TRAVIS_BRANCH"
git stash
git checkout "$TRAVIS_BRANCH"
git stash pop
git add composer.lock
git commit -m "Auto-update dependencies in composer.lock from PR #$TRAVIS_PULL_REQUEST (https://github.com/$TRAVIS_REPO_SLUG/pull/$TRAVIS_PULL_REQUEST)."
git push origin "$TRAVIS_BRANCH"
) 2>&1 | sed -e "s/$GITHUB_TOKEN/REDACTED/g"
else
echo "Not auto-merging, because multiple files were changed"
fi
fi
###
# Run composer lock update on cron jobs.
# See: https://github.com/danielbachhuber/composer-lock-updater
###
if [ "$TRAVIS_EVENT_TYPE" != "cron" ] ; then
echo "Not a cron job; exiting."
return
fi
###
# Only run on one job of a master branch build
###
if [ "master" != "$TRAVIS_BRANCH" ] ; then
echo "composer.lock update only runs on the master branch."
return
fi
###
# Install composer-lock-updater
###
export PATH="$HOME/.composer/vendor/bin:$PATH"
composer global require danielbachhuber/composer-lock-updater
###
# Optional: install Sensio Labs security checker to include security advisories in PR comments
###
mkdir -p $HOME/bin
wget -O $HOME/bin/security-checker.phar http://get.sensiolabs.org/security-checker.phar
chmod +x $HOME/bin/security-checker.phar
export PATH="$HOME/bin:$PATH"
###
# Install hub for creating GitHub pull requests
###
wget -O hub.tgz https://github.com/github/hub/releases/download/v2.2.9/hub-linux-amd64-2.2.9.tgz
tar -zxvf hub.tgz
export PATH=$PATH:$PWD/hub-linux-amd64-2.2.9/bin/
###
# Run composer-lock-updater
###
clu
# Prior to a deploy, build a fresh robo.phar
before_deploy:
- ./robo phar:build
# Deploy instructions set up via `travis setup releases` per
# https://docs.travis-ci.com/user/deployment/releases
deploy:
provider: releases
api_key:
secure: EdmB1nW5gj5nggYfmHv20enSgvRIAl1PIWV5GKmkxAJwuummh3UqdI7z0ecTGdw2IBgJx9lizNvqhcWjXbpNhE9VaaT1sHFCKv4Zust6sLb9bneK3oLRdJk2wemfrrZQpdH900zA0o7b3CHVth8UhkrCB4FXVDjUW13K061EXG8=
file: robo.phar
skip_cleanup: true
on:
tags: true