Continuous Integration

From PostgreSQL wiki

Jump to: navigation, search

Here is some information about how to use a variety of free continuous integration services, for PostgreSQL hackers. You'll need a BitBucket, GitHub, GitLab or other public source repository account. Then you'll need to select one or more CI service and tell it to watch your account. In the case of the popular repo hosts you don't have to create a new account on the CI provider websites, just grant access. Finally you'll have to tell it how to builds your branches with a control file in your source tree. In some case the configuration can also be out-of-tree instead.



AppVeyor builds and tests code on Windows. This is especially interesting to people developing on Unix systems, who otherwise might not find out they've broken the code for Windows until their patch is committed. Support for GitHub, GitHub Enterprise, Bitbucket, GitLab, VSTS, Kiln or custom repos. If you have an account on those systems you can log in directly and authorise it to access your repo. Then check the box to ask it to build all branches that contain an appveyor.yml file. An example control file is included in the patch above. Discussion

Here is an appveyor.yml file that works as at the time of writing:

  - appveyor-retry cinst winflexbison
  - '"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64'
  - '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64'

  - rename c:\ProgramData\chocolatey\bin\win_flex.exe flex.exe
  - rename c:\ProgramData\chocolatey\bin\win_bison.exe bison.exe
  - perl

  project: pgsql.sln

  - cd src\tools\msvc && vcregress check

  - perl

  - Release

This needs two other files at top level, called (TODO: strip unnecessary junk out of here, and figure out how to stuff whatever remains into the appveyor.yml file):

use strict;


    chdir("../../..") if (-d "../msvc" && -d "../../../src");


use lib "src/tools/msvc";

use Cwd;

use Mkvcbuild;

# is for specifying the build environment settings
# it should contain lines like:
# $ENV{PATH} = "c:/path/to/bison/bin;$ENV{PATH}";

if (-e "src/tools/msvc/")
    do "src/tools/msvc/";
elsif (-e "./")
    do "./";

# set up the project
our $config;
do "";
do "" if (-f "src/tools/msvc/");

# print "PATH: $_\n" foreach (split(';',$ENV{PATH}));


... and to spit out the regression diffs, if there are any (this also should be crammed into appveyor.yml):

use strict;
use warnings FATAL => qw(all);

use File::Find;

my $Target = "regression.diffs";

find(\&dump, "src");

sub dump {
  if ($_ eq $Target) {
    my $path = $File::Find::name;
    print "=== \$path ===\\n";
    open(my $fh, "<", $_) || die "wtf";
    while (my $line = <$fh>) {
      print $line;
      if ($. > 1000) { last; }

If you want AppVeyor to spit out a .zip file that contains the build results, try adding the following to appveyor.yml:

  - path: Release

Then look for the 'artifacts' link on the AppVeyor build results page. I don't know how to actually run the resulting PostgreSQL build on a Windows system; if someone has instructions for that, please add them here, as it may help non-Windows developers do some limited kinds of cave-man testing on Windows virtual machines with no local build environment.

I hope someone will figure out how to do a better job of this, and spit out more information about failures (backtraces etc).




CodeCov is not a CI system, but is closely related and worth mentioning. If you configure Travis CI to build and test your branches with coverage enabled, you might also be interested to see code coverage information in a nice web interface on CodeCov. (There are several competing services that might be worth mentioning too.)



Travis CI

Travis CI builds and tests code on Ubuntu GNU/Linux (and possibly also macOS?) This might be interesting for people developing primarily on Windows. Works only with GitHub. Controlled by a .travis.yml file. An example control file is included in the patch above, similar to the one used by the (unofficial) Commitfest Patch Tester.

Personal tools