Skip to content

Instantly share code, notes, and snippets.

@mjesuele
Created April 8, 2020 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjesuele/2a02b5317a1ee1a921ca67478f43ee41 to your computer and use it in GitHub Desktop.
Save mjesuele/2a02b5317a1ee1a921ca67478f43ee41 to your computer and use it in GitHub Desktop.
DoltHub CI Example Script
#!/usr/bin/perl -w
use strict;
my $owner = $ENV{'owner'};
my $repo = $ENV{'repo'};
my $branch = $ENV{'branch'};
my $head = $ENV{'head'};
my $prev = $ENV{'prev'};
system("rm -r $repo");
run_command("dolt clone $owner/$repo", "Could not clone $owner/$repo");
chdir($repo);
run_command("dolt checkout -b jenkins-test $head",
"Could not switch to commit $head");
# Check for no NULL values in the places country_region column
my $results =
`dolt sql -q "select count(*) from places where country_region is NULL"`;
if ( $results !~ /\s0\s/ ) {
die "Unexpected NULL results found in places table, country_region column";
} else {
print "No NULL values in places table, country_region column\n";
}
$results = `dolt diff --summary $head $prev cases`;
if ( $results ) {
my $cases_cells_modified;
if ( $results =~ /([\d+,])\s+Cells?\sModified/ ) {
my $cases_cells_modified = $1;
if ( $cases_cells_modified > 0 ) {
die "Data from a previous date was updated";
} else {
print "Only received new time series data since last update\n";
}
} else {
die "Could not find Cells Modified";
}
} else {
print "Time series data not modified in this commit. Skipping check.";
}
run_command("dolt checkout $branch", "Could not switch to branch $branch");
run_command("dolt branch -d jenkins-test",
"Could not delete jenkins-test branch");
chdir('..');
exit 0;
sub run_command {
my $command = shift;
my $error = shift;
print "Running: $command\n";
my $exitcode = system($command);
print "\n";
die "$error\n" if ( $exitcode != 0 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment