Skip to content

Instantly share code, notes, and snippets.

@Rarst
Last active November 11, 2016 12:20
Show Gist options
  • Save Rarst/2f1c5599f7be1256e8a0 to your computer and use it in GitHub Desktop.
Save Rarst/2f1c5599f7be1256e8a0 to your computer and use it in GitHub Desktop.
Travis matrix generator for Yoast SEO.
<?php
$php_max = 7.0;
$php_min = 5.2;
$php_versions = array_filter( range( $php_max, $php_min + 0.1, 0.1 ), function ( $version ) {
return version_compare( $version, 5.6, '<=' ) || version_compare( $version, 7.0, '>=' );
} );
$wp_max = 4.6;
$wp_min = 4.4;
$include = [ ];
// bleeding edge with all checks
$include[] = [
'php' => number_format( $php_max, 1 ),
'env' => [
'WP_VERSION' => 'master',
'WP_MULTISITE' => 1,
'PHPLINT' => 1,
'PHPCS' => 1,
'CHECKJS' => 1,
'COVERAGE' => 1,
'TRAVIS_NODE_VERSION' => 'node',
],
];
// minimum PHP with multisite and lint
$include[] = [
'php' => number_format( $php_min, 1 ),
'env' => [
'WP_VERSION' => number_format( $wp_max, 1 ),
'WP_MULTISITE' => 1,
'PHPLINT' => 1,
],
];
// every WP version with stable PHP
$wp = $wp_max;
do {
$php = ( $wp < 4.3 && $php_max > 5.6 ) ? 5.6 : $php_max;
$include[] = [
'php' => number_format( $php, 1 ),
'env' => [
'WP_VERSION' => number_format( $wp, 1 )
],
];
$wp -= 0.1;
} while ( $wp >= $wp_min );
// every PHP version with current WP
foreach ( $php_versions as $php ) {
$include[] = [
'php' => number_format( $php, 1 ),
'env' => [
'WP_VERSION' => number_format( $wp_max, 1 )
],
];
}
// HHVM
$include[] = [
'php' => 'hhvm',
'env' => [
'WP_VERSION' => number_format( $wp_max, 1 )
],
];
$include = array_unique( $include, SORT_REGULAR );
$output = <<<MATRIX
matrix:
allow_failures:
- php: hhvm
include:
MATRIX;
foreach ( $include as $item ) {
$output .= " - php: {$item['php']}\n";
$output .= " env:";
foreach ( $item['env'] as $key => $value ) {
$output .= " {$key}={$value}";
}
$output .= "\n";
}
echo $output;
@Ramoonus
Copy link

it doesn`t include disabling xdebug to speed up

@Rarst
Copy link
Author

Rarst commented Dec 21, 2015

Not sure what you mean, this just makes a matrix part — not a whole file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment