From 62c8e20ddafb2ce5ff08e5df681905e6ca1e0c03 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Fri, 8 Nov 2019 12:01:33 +1300
Subject: [PATCH 2/2] CI

---
 appveyor.yml  | 25 +++++++++++++++++++++++++
 buildsetup.pl | 38 ++++++++++++++++++++++++++++++++++++++
 dumpregr.pl   | 20 ++++++++++++++++++++
 3 files changed, 83 insertions(+)
 create mode 100644 appveyor.yml
 create mode 100644 buildsetup.pl
 create mode 100644 dumpregr.pl

diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000000..72f5c2b7e9
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,25 @@
+#  appveyor.yml
+
+image: Visual Studio 2015
+
+install:
+  - appveyor-retry cinst winflexbison
+  - '"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64'
+  - '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64'
+
+before_build:
+  - rename c:\ProgramData\chocolatey\bin\win_flex.exe flex.exe
+  - rename c:\ProgramData\chocolatey\bin\win_bison.exe bison.exe
+  - perl buildsetup.pl
+
+build:
+  project: pgsql.sln
+
+test_script:
+  - cd src\tools\msvc && vcregress check
+
+on_failure:
+  - perl dumpregr.pl
+
+configuration:
+  - Release
diff --git a/buildsetup.pl b/buildsetup.pl
new file mode 100644
index 0000000000..23df2fb1aa
--- /dev/null
+++ b/buildsetup.pl
@@ -0,0 +1,38 @@
+# first part of postgres build.pl, just doesn't run msbuild
+
+use strict;
+
+BEGIN
+{
+
+    chdir("../../..") if (-d "../msvc" && -d "../../../src");
+
+}
+
+use lib "src/tools/msvc";
+
+use Cwd;
+
+use Mkvcbuild;
+
+# buildenv.pl 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/buildenv.pl")
+{
+    do "src/tools/msvc/buildenv.pl";
+}
+elsif (-e "./buildenv.pl")
+{
+    do "./buildenv.pl";
+}
+
+# set up the project
+our $config;
+do "config_default.pl";
+do "config.pl" if (-f "src/tools/msvc/config.pl");
+
+# print "PATH: $_\n" foreach (split(';',$ENV{PATH}));
+
+Mkvcbuild::mkvcbuild($config);
diff --git a/dumpregr.pl b/dumpregr.pl
new file mode 100644
index 0000000000..08d276b52d
--- /dev/null
+++ b/dumpregr.pl
@@ -0,0 +1,20 @@
+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; }
+    }
+  }
+}
-- 
2.23.0

