-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
110 lines (101 loc) · 3.65 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
dist: trusty
language: php
branches:
# Only test the main branch and SemVer tags.
only:
- main
- '/^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+.*$/'
matrix:
include:
-
php: 7.1
env: dependencies=highest
-
php: 7.0.11
-
php: 5.6
env: dependencies=lowest
sudo: false
cache:
directories:
- $HOME/.composer/cache
# Do highest/lowest testing by installing dependencies per the 'dependencies' setting
before_script:
- '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:
- 'composer -n test'
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:[email protected]}"
# If this is a PR that merges into the main 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" ] && [ "main" == "$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 main branch build
###
if [ "main" != "$TRAVIS_BRANCH" ] ; then
echo "composer.lock update only runs on the main 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