Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[REBUILD] Fix failures in full-rebuild-from-commits
The bash script pulls and based on commit message titles tells the
build script to do a full rebuild. However, if another build run
is currently running, the build script will just exit. The next
build run now won't see those commits and no full rebuild is done.

Fix by leaving a marker file lying around when we're bailing out due
to another run being active and a full rebuild was requested.
  • Loading branch information
zoffixznet committed Aug 4, 2017
1 parent 6be4574 commit 2863c4b
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions bin/build-project-list.pl
Expand Up @@ -7,22 +7,20 @@
use File::Spec::Functions qw/catdir catfile/;
use Getopt::Long;
use Pod::Usage;
use Mojo::File qw/path/;

use lib qw/lib/;
use ModulesPerl6::DbBuilder;

use constant FULL_REBUILD_MARK_FILE => 'do-full-rebuild-next-time';
use constant DB_FILE => 'modulesperl6.db';
use constant GITHUB_TOKEN_FILE => 'github-token';
use constant APP => 'bin/ModulesPerl6.pl';
use constant LOGOS_DIR => catdir qw/public content-pics dist-logos/;
use constant META_LIST_FILE => 'https://raw.githubusercontent.com'
. '/perl6/ecosystem/master/META.list';

### This flock exists to allow only one copy of the script to run at a time
unless ( flock DATA, LOCK_EX | LOCK_NB ) {
print "Found duplicate script run. Stopping\n" if $ENV{MODULESPERL6_DEBUG};
exit -1;
}
exit_if_another_run_is_active();

my $meta_list = META_LIST_FILE;
my $github_token_file = GITHUB_TOKEN_FILE;
Expand Down Expand Up @@ -56,6 +54,31 @@
restart_app => $restart_app,
)->run;


sub exit_if_another_run_is_active {
my $file = path FULL_REBUILD_MARK_FILE;
my $mark = 'ModulesPerl6Org full build marker file';

### This flock exists to allow only one copy of the script to run at a time
unless ( flock DATA, LOCK_EX | LOCK_NB ) {
print "Found duplicate script run. Stopping\n"
if $ENV{MODULESPERL6_DEBUG};

# did previous run wanted us to do a full rebuild, leave a marker
# file around so that the next run knows to do the full rebuild

$file->spurt("$mark; created on " . localtime)
if $ENV{FULL_REBUILD} and not -e $file;

exit -1;
}

if (-e $file and $file->slurp =~ /^\Q$mark\E/) {
unlink $file;
$ENV{FULL_REBUILD} = 1;
}
}

### DO NOT REMOVE THE FOLLOWING LINES from __DATA__ ###
### This exists to allow only one copy of the script to run at a time
__DATA__
Expand Down

0 comments on commit 2863c4b

Please sign in to comment.