-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenTravis.php
82 lines (74 loc) · 2.35 KB
/
genTravis.php
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
<?php
$travisData = [
'language' => 'php',
'matrix' => [
'include' => [],
],
'before_script' => [
'travis_retry composer self-update',
implode(' ', [
'if [ "$PUG_VERSION" != "" ];',
'then travis_retry composer require "pug-php/pug:${PUG_VERSION}" --no-update;',
'fi;',
]),
'travis_retry composer update --no-interaction',
],
'script' => [
'vendor/bin/phpunit --verbose --coverage-text --coverage-clover=coverage.xml',
],
'after_script' => [
'vendor/bin/test-reporter --coverage-report coverage.xml',
],
'after_success' => [
'bash <(curl -s https://codecov.io/bash)',
],
'addons' => [
'code_climate' => [
'repo_token' => '42424e464a16a1cd50ed98cf9dc112e78f53a443566a26f2b3f7a86d3386d4cd',
],
],
];
$matrix = [
'5.3' => ['2.7.1'],
'5.4' => ['2.7.1'],
'5.5' => ['2.7.1', '3.0.0-alpha3@alpha'],
'5.6' => ['2.7.1', '3.0.0-alpha3@alpha'],
'7.0' => ['2.7.1', '3.0.0-alpha3@alpha'],
'7.1' => ['2.7.1', '3.0.0-alpha3@alpha'],
'7.2' => ['2.7.1', '3.0.0-alpha3@alpha'],
'hhvm' => ['2.7.1', '3.0.0-alpha3@alpha'],
];
foreach ($matrix as $phpVersion => $pugVersions) {
foreach ($pugVersions as $pugVersion) {
$environment = [
'php' => $phpVersion,
'env' => "PUG_VERSION='$pugVersion'",
];
if ($phpVersion === '5.3') {
$environment['dist'] = 'precise';
$environment['sudo'] = 'required';
} elseif ($phpVersion === 'hhvm') {
$environment['dist'] = 'trusty';
$environment['sudo'] = 'required';
}
$travisData['matrix']['include'][] = $environment;
}
}
function compileYaml($data, $indent = 0)
{
$contents = '';
foreach ($data as $key => $value) {
$isAssoc = is_string($key);
$contents .= str_repeat(' ', $indent * 2) . ($isAssoc ? $key . ':' : '-');
if (is_array($value)) {
$value = compileYaml($value, $indent + 1);
$contents .= $isAssoc
? "\n$value"
: ' ' . ltrim($value);
continue;
}
$contents .= ' ' . $value . "\n";
}
return $contents;
}
file_put_contents(__DIR__ . '/../.travis.yml', compileYaml($travisData));