Created
April 8, 2020 21:52
DoltHub CI Example Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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