You've already forked pgbackrest
							
							
				mirror of
				https://github.com/pgbackrest/pgbackrest.git
				synced 2025-10-30 23:37:45 +02:00 
			
		
		
		
	Add documentation builds to CI.
This commit is contained in:
		
							
								
								
									
										12
									
								
								.travis.yml
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								.travis.yml
									
									
									
									
									
								
							| @@ -14,10 +14,11 @@ services: | ||||
|   - docker | ||||
|  | ||||
| env: | ||||
|   - PGB_TEST_VM="co6" PGB_TEST_PARAM="" | ||||
|   - PGB_TEST_VM="u16" PGB_TEST_PARAM=" --no-lint" | ||||
|   - PGB_TEST_VM="co7" PGB_TEST_PARAM=" --no-lint" | ||||
|   - PGB_TEST_VM="u14" PGB_TEST_PARAM=" --no-lint" | ||||
|   - PGB_CI="--vm=co6 test" | ||||
|   - PGB_CI="--vm=u16 test" | ||||
|   - PGB_CI="--vm=co7 test" | ||||
|   - PGB_CI="--vm=u14 test" | ||||
|   - PGB_CI="doc" | ||||
|  | ||||
| before_install: | ||||
|   - 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 devscripts libjson-perl libio-socket-ssl-perl libxml-libxml-perl python-pip | ||||
| @@ -42,7 +43,6 @@ install: | ||||
|     cd ~ && pwd && whoami && umask && groups | ||||
|     mv ${TRAVIS_BUILD_DIR?} pgbackrest | ||||
|     rm -rf ${TRAVIS_BUILD_DIR?} | ||||
|   - pgbackrest/test/test.pl --vm-build --vm=${PGB_TEST_VM?} | ||||
|  | ||||
| script: | ||||
|   - pgbackrest/test/test.pl --vm-max=2 --vm-host=u14 --vm=${PGB_TEST_VM?} ${PGB_TEST_PARAM?} | ||||
|   - pgbackrest/test/travis.pl ${PGB_CI?} | ||||
|   | ||||
| @@ -29,7 +29,7 @@ use BackRestDoc::Common::DocManifest; | ||||
| #################################################################################################################################### | ||||
| # User that's building the docs | ||||
| #################################################################################################################################### | ||||
| use constant DOC_USER                                              => 'ubuntu'; | ||||
| use constant DOC_USER                                              => getpwuid($UID) . ''; | ||||
|  | ||||
| #################################################################################################################################### | ||||
| # CONSTRUCTOR | ||||
|   | ||||
| @@ -142,13 +142,13 @@ eval | ||||
|         # Generate deployment docs for RHEL/Centos 6 | ||||
|         &log(INFO, "Generate RHEL/CentOS 6 documentation"); | ||||
|  | ||||
|         executeTest("${strDocExe} --deploy --keyword=co6 --out=pdf"); | ||||
|         executeTest("${strDocExe} --deploy --keyword=co6 --out=pdf", {bShowOutputAsync => true}); | ||||
|         executeTest("${strDocExe} --deploy --cache-only --keyword=co6 --out=pdf --var=\"project-name=Crunchy BackRest\""); | ||||
|  | ||||
|         # Generate deployment docs for Debian | ||||
|         &log(INFO, "Generate Debian/Ubuntu documentation"); | ||||
|  | ||||
|         executeTest("${strDocExe} --deploy"); | ||||
|         executeTest("${strDocExe} --deploy", {bShowOutputAsync => true}); | ||||
|         executeTest("${strDocExe} --deploy --cache-only --out=man --out=html --var=project-url-root=index.html"); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -238,6 +238,10 @@ | ||||
|                 </release-bug-list> | ||||
|  | ||||
|                 <release-refactor-list> | ||||
|                     <release-item> | ||||
|                         <p>Add documentation builds to CI.</p> | ||||
|                     </release-item> | ||||
|  | ||||
|                     <release-item> | ||||
|                         <p>Remove patch directory before Debian package builds.</p> | ||||
|                     </release-item> | ||||
|   | ||||
| @@ -11,6 +11,13 @@ | ||||
|         <variable key="user-guide-os" keyword="default">Debian/Ubuntu</variable> | ||||
|         <variable key="user-guide-os" keyword="co6">RHEL/CentOS 6</variable> | ||||
|  | ||||
|         <variable key="pgbackrest-base-dir" eval="y"> | ||||
|             use File::Basename qw(dirname); | ||||
|             use Cwd qw(abs_path); | ||||
|  | ||||
|             dirname(dirname(abs_path($0))); | ||||
|         </variable> | ||||
|  | ||||
|         <variable key="pg-version" keyword="default">9.4</variable> | ||||
|         <variable key="pg-version" keyword="co6">9.5</variable> | ||||
|         <variable key="pg-version-upgrade" keyword="default">9.5</variable> | ||||
| @@ -63,8 +70,8 @@ | ||||
|         <variable key="host-os" keyword="default">u14</variable> | ||||
|         <variable key="host-os" keyword="co6">co6</variable> | ||||
|  | ||||
|         <variable key="host-user">ubuntu</variable> | ||||
|         <variable key="host-mount">/backrest:/backrest</variable> | ||||
|         <variable key="host-user" eval="y">use English; getpwuid($UID) . ''</variable> | ||||
|         <variable key="host-mount">{[pgbackrest-base-dir]}:/backrest</variable> | ||||
|         <variable key="image-repo">pgbackrest/test</variable> | ||||
|  | ||||
|         <variable key="host-s3-server">s3-server</variable> | ||||
|   | ||||
							
								
								
									
										2
									
								
								test/Vagrantfile
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								test/Vagrantfile
									
									
									
									
										vendored
									
									
								
							| @@ -8,7 +8,7 @@ Vagrant.configure(2) do |config| | ||||
|     config.vm.box_version = "20170603.0.0" | ||||
|  | ||||
|     # vagrant plugin install vagrant-disksize | ||||
|     config.disksize.size = '64GB' | ||||
|     # config.disksize.size = '64GB' | ||||
|  | ||||
|     config.vm.provider :virtualbox do |vb| | ||||
|         vb.name = "pgbackrest-test" | ||||
|   | ||||
| @@ -89,16 +89,14 @@ sub process | ||||
|         "\n" . | ||||
|         "env:\n"; | ||||
|  | ||||
|     my $bFirst = true; | ||||
|  | ||||
|     # Iterate each OS | ||||
|     foreach my $strVm (VM_LIST) | ||||
|     { | ||||
|         $strConfig .= | ||||
|             "  - PGB_TEST_VM=\"${strVm}\" PGB_TEST_PARAM=\"" . ($bFirst ? '' : " --no-lint") . "\"\n"; | ||||
|         $bFirst = false; | ||||
|         $strConfig .= "  - PGB_CI=\"--vm=${strVm} test\"\n"; | ||||
|     } | ||||
|  | ||||
|     $strConfig .= "  - PGB_CI=\"doc\"\n"; | ||||
|  | ||||
|     # Configure install and script | ||||
|     $strConfig .= | ||||
|         "\n" . | ||||
| @@ -127,10 +125,9 @@ sub process | ||||
|         "    cd ~ && pwd && whoami && umask && groups\n" . | ||||
|         "    mv \${TRAVIS_BUILD_DIR?} " . BACKREST_EXE . "\n" . | ||||
|         "    rm -rf \${TRAVIS_BUILD_DIR?}\n" . | ||||
|         "  - " . BACKREST_EXE . "/test/test.pl --vm-build --vm=\${PGB_TEST_VM?}\n" . | ||||
|         "\n" . | ||||
|         "script:\n" . | ||||
|         "  - " . BACKREST_EXE . "/test/test.pl --vm-max=2 --vm-host=u14 --vm=\${PGB_TEST_VM?} \${PGB_TEST_PARAM?}\n"; | ||||
|         "  - " . BACKREST_EXE . "/test/travis.pl \${PGB_CI?}\n"; | ||||
|  | ||||
|     $self->{oStorage}->put('.travis.yml', $strConfig); | ||||
|  | ||||
|   | ||||
| @@ -104,7 +104,7 @@ sub begin | ||||
|  | ||||
|     # Record start time and set process timeout | ||||
|     $self->{iProcessTimeout} = 540; | ||||
|     $self->{lTimeStart} = time(); | ||||
|     $self->{lTimeLast} = time(); | ||||
|  | ||||
|     if (!defined($self->{hError})) | ||||
|     { | ||||
| @@ -141,7 +141,7 @@ sub endRetry | ||||
|         my $bFound = false; | ||||
|  | ||||
|         # Error if process has been running longer than timeout | ||||
|         if (time() - $self->{lTimeStart} > $self->{iProcessTimeout}) | ||||
|         if (time() - $self->{lTimeLast} > $self->{iProcessTimeout}) | ||||
|         { | ||||
|             confess &log(ASSERT, | ||||
|                 "timeout after $self->{iProcessTimeout} seconds waiting for process to complete: $self->{strCommand}"); | ||||
| @@ -150,6 +150,8 @@ sub endRetry | ||||
|         # Drain the stdout stream and look for test points | ||||
|         while (defined(my $strLine = $self->{oIo}->readLine(true, false))) | ||||
|         { | ||||
|             $self->{lTimeLast} = time(); | ||||
|  | ||||
|             $self->{strOutLog} .= "${strLine}\n"; | ||||
|             $bFound = true; | ||||
|  | ||||
|   | ||||
							
								
								
									
										193
									
								
								test/travis.pl
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										193
									
								
								test/travis.pl
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,193 @@ | ||||
| #!/usr/bin/perl | ||||
| #################################################################################################################################### | ||||
| # Travis CI Test Wrapper | ||||
| #################################################################################################################################### | ||||
|  | ||||
| #################################################################################################################################### | ||||
| # Perl includes | ||||
| #################################################################################################################################### | ||||
| use strict; | ||||
| use warnings FATAL => qw(all); | ||||
| use Carp qw(confess longmess); | ||||
| use English '-no_match_vars'; | ||||
|  | ||||
| # Convert die to confess to capture the stack trace | ||||
| $SIG{__DIE__} = sub { Carp::confess @_ }; | ||||
|  | ||||
| use File::Basename qw(dirname); | ||||
| use Getopt::Long qw(GetOptions); | ||||
| use Cwd qw(abs_path); | ||||
|  | ||||
| use lib dirname($0) . '/lib'; | ||||
| use lib dirname(dirname($0)) . '/lib'; | ||||
|  | ||||
| use pgBackRest::Common::Exception; | ||||
| use pgBackRest::Common::Log; | ||||
|  | ||||
| use pgBackRestTest::Common::ExecuteTest; | ||||
| use pgBackRestTest::Common::VmTest; | ||||
|  | ||||
| #################################################################################################################################### | ||||
| # Usage | ||||
| #################################################################################################################################### | ||||
|  | ||||
| =head1 NAME | ||||
|  | ||||
| travis.pl - Travis CI Test Wrapper | ||||
|  | ||||
| =head1 SYNOPSIS | ||||
|  | ||||
| test.pl [options] doc|test | ||||
|  | ||||
|  VM Options: | ||||
|    --vm                 docker container to build/test | ||||
|  | ||||
|  General Options: | ||||
|    --help               display usage and exit | ||||
| =cut | ||||
|  | ||||
| #################################################################################################################################### | ||||
| # Command line parameters | ||||
| #################################################################################################################################### | ||||
| my $strVm; | ||||
| my $bHelp; | ||||
|  | ||||
| GetOptions ('help' => \$bHelp, | ||||
|             'vm=s' => \$strVm) | ||||
|     or pod2usage(2); | ||||
|  | ||||
| #################################################################################################################################### | ||||
| # Begin/end functions to track timing | ||||
| #################################################################################################################################### | ||||
| my $lProcessBegin; | ||||
| my $strProcessTitle; | ||||
|  | ||||
| sub processBegin | ||||
| { | ||||
|     $strProcessTitle = shift; | ||||
|  | ||||
|     &log(INFO, "Begin ${strProcessTitle}"); | ||||
|     $lProcessBegin = time(); | ||||
| } | ||||
|  | ||||
| sub processEnd | ||||
| { | ||||
|     &log(INFO, "End ${strProcessTitle} (" . (time() - $lProcessBegin) . 's)'); | ||||
| } | ||||
|  | ||||
| #################################################################################################################################### | ||||
| # Run in eval block to catch errors | ||||
| #################################################################################################################################### | ||||
| eval | ||||
| { | ||||
|     # Display version and exit if requested | ||||
|     if ($bHelp) | ||||
|     { | ||||
|         syswrite(*STDOUT, "Travis CI Test Wrapper\n"); | ||||
|  | ||||
|         syswrite(*STDOUT, "\n"); | ||||
|         pod2usage(); | ||||
|  | ||||
|         exit 0; | ||||
|     } | ||||
|  | ||||
|     if (@ARGV != 1) | ||||
|     { | ||||
|         syswrite(*STDOUT, "test|doc required\n\n"); | ||||
|         pod2usage(); | ||||
|     } | ||||
|  | ||||
|     ################################################################################################################################ | ||||
|     # Paths | ||||
|     ################################################################################################################################ | ||||
|     my $strBackRestBase = dirname(dirname(abs_path($0))); | ||||
|     my $strReleaseExe = "${strBackRestBase}/doc/release.pl"; | ||||
|     my $strTestExe = "${strBackRestBase}/test/test.pl"; | ||||
|  | ||||
|     logLevelSet(INFO, INFO, OFF); | ||||
|  | ||||
|     ################################################################################################################################ | ||||
|     # Build documentation | ||||
|     ################################################################################################################################ | ||||
|     if ($ARGV[0] eq 'doc') | ||||
|     { | ||||
|         processBegin('LaTeX install'); | ||||
|         executeTest( | ||||
|             'sudo apt-get install -y --no-install-recommends texlive-latex-base texlive-latex-extra texlive-fonts-recommended', | ||||
|             {bSuppressStdErr => true}); | ||||
|         executeTest('sudo apt-get install -y texlive-font-utils latex-xcolor', {bSuppressStdErr => true}); | ||||
|         processEnd(); | ||||
|  | ||||
|         processBegin(VM_CO6 . ' build'); | ||||
|         executeTest("${strTestExe} --vm-build --vm=" . VM_CO6, {bShowOutputAsync => true}); | ||||
|         processEnd(); | ||||
|  | ||||
|         processBegin(VM_U14 . ' build'); | ||||
|         executeTest("${strTestExe} --vm-build --vm=" . VM_U14, {bShowOutputAsync => true}); | ||||
|         processEnd(); | ||||
|  | ||||
|         processBegin('release documentation doc'); | ||||
|         executeTest("${strReleaseExe} --build", {bShowOutputAsync => true}); | ||||
|         processEnd(); | ||||
|     } | ||||
|  | ||||
|     ################################################################################################################################ | ||||
|     # Run test | ||||
|     ################################################################################################################################ | ||||
|     elsif ($ARGV[0] eq 'test') | ||||
|     { | ||||
|         # VM must be defined | ||||
|         if (!defined($strVm)) | ||||
|         { | ||||
|             confess &log(ERROR, '--vm is required'); | ||||
|         } | ||||
|  | ||||
|         # Only lint on CO6 | ||||
|         my $strParam = undef; | ||||
|  | ||||
|         if ($strVm ne VM_CO6) | ||||
|         { | ||||
|             $strParam .= '--no-lint'; | ||||
|         } | ||||
|  | ||||
|         processBegin("${strVm} build"); | ||||
|         executeTest("${strTestExe} --vm-build --vm=${strVm}", {bShowOutputAsync => true}); | ||||
|         processEnd(); | ||||
|  | ||||
|         processBegin("${strVm} test" . (defined($strParam) ? ": ${strParam}" : '')); | ||||
|         executeTest( | ||||
|             "${strTestExe} --vm-host=u14 --vm-max=2 --vm=${strVm}" . (defined($strParam) ? " ${strParam}" : ''), | ||||
|             {bShowOutputAsync => true}); | ||||
|         processEnd(); | ||||
|     } | ||||
|  | ||||
|     ################################################################################################################################ | ||||
|     # Catch error | ||||
|     ################################################################################################################################ | ||||
|     else | ||||
|     { | ||||
|         confess &log(ERROR, 'invalid command ' . $ARGV[0]); | ||||
|     } | ||||
|  | ||||
|     &log(INFO, "CI Complete"); | ||||
|  | ||||
|     # Exit with success | ||||
|     exit 0; | ||||
| } | ||||
|  | ||||
| #################################################################################################################################### | ||||
| # Check for errors | ||||
| #################################################################################################################################### | ||||
| or do | ||||
| { | ||||
|     # If a backrest exception then return the code | ||||
|     exit $EVAL_ERROR->code() if (isException($EVAL_ERROR)); | ||||
|  | ||||
|     # Else output the unhandled error | ||||
|     print $EVAL_ERROR; | ||||
|     exit ERROR_UNHANDLED; | ||||
| }; | ||||
|  | ||||
| # It shouldn't be possible to get here | ||||
| &log(ASSERT, 'execution reached invalid location in ' . __FILE__ . ', line ' . __LINE__); | ||||
| exit ERROR_ASSERT; | ||||
		Reference in New Issue
	
	Block a user