2017-02-21 15:59:23 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# CiTest.pm - Create Travis configuration file for continuous integration testing
|
|
|
|
####################################################################################################################################
|
|
|
|
package pgBackRestTest::Common::CiTest;
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Perl includes
|
|
|
|
####################################################################################################################################
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
|
|
|
use English '-no_match_vars';
|
|
|
|
|
|
|
|
use Cwd qw(abs_path);
|
|
|
|
use Exporter qw(import);
|
|
|
|
our @EXPORT = qw();
|
|
|
|
use File::Basename qw(dirname);
|
|
|
|
use POSIX qw(ceil);
|
|
|
|
use Time::HiRes qw(gettimeofday);
|
|
|
|
|
|
|
|
use pgBackRest::DbVersion;
|
|
|
|
use pgBackRest::Common::Exception;
|
|
|
|
use pgBackRest::Common::Log;
|
|
|
|
use pgBackRest::Common::String;
|
|
|
|
use pgBackRest::Version;
|
|
|
|
|
|
|
|
use pgBackRestTest::Common::ContainerTest;
|
|
|
|
use pgBackRestTest::Common::DefineTest;
|
|
|
|
use pgBackRestTest::Common::ExecuteTest;
|
|
|
|
use pgBackRestTest::Common::ListTest;
|
|
|
|
use pgBackRestTest::Common::VmTest;
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# new
|
|
|
|
####################################################################################################################################
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my $class = shift; # Class name
|
|
|
|
|
|
|
|
# Create the class hash
|
|
|
|
my $self = {};
|
|
|
|
bless $self, $class;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
(
|
|
|
|
my $strOperation,
|
2017-06-09 23:51:41 +02:00
|
|
|
$self->{oStorage},
|
2017-02-21 15:59:23 +02:00
|
|
|
) =
|
|
|
|
logDebugParam
|
|
|
|
(
|
|
|
|
__PACKAGE__ . '->new', \@_,
|
2017-06-09 23:51:41 +02:00
|
|
|
{name => 'oStorage'},
|
2017-02-21 15:59:23 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
{name => 'self', value => $self, trace => true}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# process
|
|
|
|
####################################################################################################################################
|
|
|
|
sub process
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
(my $strOperation) = logDebugParam (__PACKAGE__ . '->process', \@_,);
|
|
|
|
|
|
|
|
# Configure environment
|
|
|
|
my $strConfig =
|
|
|
|
"branches:\n" .
|
|
|
|
" only:\n" .
|
|
|
|
" - integration\n" .
|
|
|
|
" - /-ci\$/\n" .
|
|
|
|
"\n" .
|
|
|
|
"dist: trusty\n" .
|
|
|
|
"sudo: required\n" .
|
|
|
|
"\n" .
|
|
|
|
"language: c\n" .
|
|
|
|
"\n" .
|
|
|
|
"services:\n" .
|
|
|
|
" - docker\n" .
|
|
|
|
"\n" .
|
|
|
|
"env:\n";
|
|
|
|
|
|
|
|
# Iterate each OS
|
|
|
|
foreach my $strVm (VM_LIST)
|
|
|
|
{
|
2017-06-25 00:04:02 +02:00
|
|
|
$strConfig .= " - PGB_CI=\"--vm=${strVm} test\"\n";
|
2017-02-21 15:59:23 +02:00
|
|
|
}
|
|
|
|
|
2017-06-25 00:04:02 +02:00
|
|
|
$strConfig .= " - PGB_CI=\"doc\"\n";
|
|
|
|
|
2017-02-21 15:59:23 +02:00
|
|
|
# Configure install and script
|
|
|
|
$strConfig .=
|
|
|
|
"\n" .
|
|
|
|
"before_install:\n" .
|
2017-06-09 23:51:41 +02:00
|
|
|
" - sudo apt-get -qq update && sudo apt-get install libxml-checker-perl libdbd-pg-perl libperl-critic-perl" .
|
|
|
|
" libtemplate-perl libpod-coverage-perl libtest-differences-perl libhtml-parser-perl lintian debhelper txt2man" .
|
2018-04-08 16:19:24 +02:00
|
|
|
" devscripts libjson-perl libio-socket-ssl-perl libxml-libxml-perl libyaml-libyaml-perl python-pip lcov\n" .
|
2017-06-09 23:51:41 +02:00
|
|
|
" - |\n" .
|
2017-06-12 16:52:32 +02:00
|
|
|
" # Install & Configure AWS CLI\n" .
|
|
|
|
" pip install --upgrade --user awscli\n" .
|
|
|
|
" aws configure set region us-east-1\n" .
|
|
|
|
" aws configure set aws_access_key_id accessKey1\n" .
|
|
|
|
" aws configure set aws_secret_access_key verySecretKey1\n" .
|
|
|
|
" aws help --version\n" .
|
|
|
|
" aws configure list\n" .
|
|
|
|
" - |\n" .
|
2017-06-24 16:59:00 +02:00
|
|
|
" # Install Devel::Cover\n" .
|
2017-11-19 03:14:14 +02:00
|
|
|
" sudo dpkg -i \${TRAVIS_BUILD_DIR?}/test/package/u14-" . packageDevelCover(VM_ARCH_AMD64) . "\n" .
|
2017-06-09 23:51:41 +02:00
|
|
|
' ' . LIB_COVER_EXE . " -v\n" .
|
2017-02-21 15:59:23 +02:00
|
|
|
"\n" .
|
|
|
|
"install:\n" .
|
2017-06-09 23:51:41 +02:00
|
|
|
" - |\n" .
|
|
|
|
" # User Configuration\n" .
|
|
|
|
" sudo adduser --ingroup=\${USER?} --disabled-password --gecos \"\" " . BACKREST_USER . "\n" .
|
|
|
|
" umask 0022\n" .
|
|
|
|
" cd ~ && pwd && whoami && umask && groups\n" .
|
|
|
|
" mv \${TRAVIS_BUILD_DIR?} " . BACKREST_EXE . "\n" .
|
|
|
|
" rm -rf \${TRAVIS_BUILD_DIR?}\n" .
|
2017-02-21 15:59:23 +02:00
|
|
|
"\n" .
|
|
|
|
"script:\n" .
|
2017-06-25 00:04:02 +02:00
|
|
|
" - " . BACKREST_EXE . "/test/travis.pl \${PGB_CI?}\n";
|
2017-02-21 15:59:23 +02:00
|
|
|
|
2017-06-09 23:51:41 +02:00
|
|
|
$self->{oStorage}->put('.travis.yml', $strConfig);
|
2017-02-21 15:59:23 +02:00
|
|
|
|
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn($strOperation);
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|