-
-
Notifications
You must be signed in to change notification settings - Fork 132
/
.travis.yml
120 lines (106 loc) · 4.53 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
# TravisCI configuration for username/projectname
# TravisCI Build Config Explorer
# https://config.travis-ci.com/explore
# TravisCI Bash functions
# https://github.com/travis-ci/travis-build/tree/master/lib/travis/build/bash
_shared_script_check_author: &script_check_author |
Check_author()
{
local author="$1"
local github_api_url="https://api.github.com/search/users"
echo "Checking ${author} ..."
test "${author%@users.noreply.github.com}" == "${author}" || return 0
curl -s -G --data-urlencode "q=type:user in:email ${author}" "${github_api_url}" \
| grep -F -x ' "total_count": 1,'
}
test -z "${TRAVIS_COMMIT_RANGE}" \
|| git show --no-patch --pretty="format:%ae" "${TRAVIS_COMMIT_RANGE}" \
| sort -u \
| while read -r author; do Check_author "${author}"; done
_shared_script_check_executable: &script_check_executable |
# Scripts should be executable, all other files should not be executable
test -z "$(find bin/ -type f -name "*.sh" -not -executable)"
test -z "$(find . -type f -not -path "./.git/*" -not -path "./bin/*.sh" -executable)"
_shared_script_verify_exported_files: &script_verify_exported_files |
EXPECTED_FILES="CONTRIBUTING.md,LICENSE,README.md,composer.json,phpcs.xml.dist,phpstan.neon.dist,phpunit.xml.dist"
mkdir -p tests/ourselves
echo '{"repositories":[{"type":"path","url":"../../../","options":{"symlink":false}}],"minimum-stability":"dev"}' >tests/ourselves/composer.json
composer require --working-dir=tests/ourselves 'vendor/name:*'
CURRENT_FILES="$(find tests/ourselves/vendor/vendor/name/ -type f -not -path 'tests/ourselves/vendor/vendor/name/src/*' -printf '%f\0'|LC_ALL=C sort -z|paste -s -z -d ','|tr -d '\000')"
echo "$EXPECTED_FILES"
echo "$CURRENT_FILES"
test "$EXPECTED_FILES" == "$CURRENT_FILES"
_shared_script_install_phive: &script_install_phive |
# Install PHIVE (cached)
if [ ! -r "${HOME}/.phive/phive.phar" ]; then
mkdir -p "${HOME}/bin" "${HOME}/.phive"
if [ "$(phpenv version-name)" == 7.1 ]; then
# PHIVE v0.13.3 last version supporting PHP 7.1
travis_retry wget -O "${HOME}/.phive/phive.phar" \
"https://github.com/phar-io/phive/releases/download/0.13.3/phive-0.13.3.phar"
travis_retry wget -O "${HOME}/.phive/phive.phar.asc" \
"https://github.com/phar-io/phive/releases/download/0.13.3/phive-0.13.3.phar.asc"
else
travis_retry wget -O "${HOME}/.phive/phive.phar" "https://phar.io/releases/phive.phar"
travis_retry wget -O "${HOME}/.phive/phive.phar.asc" "https://phar.io/releases/phive.phar.asc"
fi
travis_retry gpg --batch --keyserver keys.openpgp.org --keyserver-options timeout=30 \
--recv-keys 0x9D8A98B29B2D5D79
if ! gpg --batch --verify "${HOME}/.phive/phive.phar.asc" "${HOME}/.phive/phive.phar"; then
echo "Invalid phive signature" 1>&2
rm -f "${HOME}/.phive/phive.phar"
exit 11
fi
rm "${HOME}/.phive/phive.phar.asc"
fi
install --verbose --mode=0755 --no-target-directory -D "${HOME}/.phive/phive.phar" "${HOME}/bin/phive"
export PATH="${HOME}/bin:${PATH}"
# On CI-s without "travis_retry"
# gpg --batch --keyserver keys.openpgp.org --keyserver-options timeout=30 --recv-keys 0x9D8A98B29B2D5D79 \
# || gpg --batch --keyserver keys.openpgp.org --keyserver-options timeout=30 --recv-keys 0x9D8A98B29B2D5D79
if: "branch = master"
language: "php"
os:
- "linux"
# 12.04 Precise: 5.2 - 7.3
# 14.04 Trusty: 5.4 - 7.4
# 16.04 Xenial: 5.6 - 8.1
# 18.04 Bionic: 7.1 - 8.1
# 20.04 Focal: 7.4 - 8.1
# 22.04 Jammy: 8.1
dist: "bionic"
stages:
- "commits"
- "test"
env:
global:
- APP_ENV: "testing"
jobs:
include:
-
stage: "commits"
name: "Check committers have a GitHub account"
before_install: "skip"
install: "skip"
before_script: "skip"
script: *script_check_author
after_script: "skip"
-
stage: "commits"
name: "Check file permissions"
before_install: "skip"
install: "skip"
before_script: "skip"
script: *script_check_executable
after_script: "skip"
cache:
directories:
- "${HOME}/.phive"
- "${HOME}/.composer/cache"
before_install:
- "phpenv config-rm xdebug.ini"
- *script_install_phive
- "travis_retry phive install --force-accept-unsigned --trust-gpg-keys TRUSTED-KEY1,TRUSTED-KEY2"
# Use Composer v1
- "composer self-update --1"
- "composer validate --strict"