Permalink
Browse files

Synchronise git subtree maint-travis-ci

  • Loading branch information...
2 parents 3cd1cb2 + 74d42c3 commit 41e7dc4f79bb5d757d83a9ce100d3211447b2ff6 @kentfredric kentfredric committed Jan 13, 2014
@@ -0,0 +1,51 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+use tools;
+
+if ( not env_true('TRAVIS') ) {
+ diag('Is not running under travis!');
+ exit 1;
+}
+diag("Resetting branch to \e[32m$ENV{TRAVIS_BRANCH}\e[0m @ \e[33m$ENV{TRAVIS_COMMIT}\e[0m");
+git( 'checkout', $ENV{TRAVIS_BRANCH} );
+git( 'reset', '--hard', $ENV{TRAVIS_COMMIT} );
+my $goodtag;
+do {
+ my ( $output, $return ) = capture_stdout {
+ safe_exec_nonfatal( 'git', 'describe', '--tags', '--abbrev=0', $ENV{TRAVIS_BRANCH} );
+ };
+ ($goodtag) = split /\n/, $output;
+ if ( not $return ) {
+ diag("TIP Version tag is \e[32m$goodtag\e[0m");
+ }
+};
+my %good_tags;
+do {
+ my $output = capture_stdout {
+ git( 'log', '--simplify-by-decoration', '--pretty=format:%d' );
+ };
+ for my $line ( split /\n/, $output ) {
+ if ( $line =~ /\(tag:\s+(.*)\)/ ) {
+ my $tag = $1;
+ diag("Good tag: \e[32m$tag\e[0m");
+ $good_tags{$tag} = 1;
+ }
+ else {
+ diag("Line not matched regexp: <\e[31m$line\e[0m>");
+ }
+ }
+};
+do {
+ my $output = capture_stdout {
+ git('tag');
+ };
+ for my $line ( split /\n/, $output ) {
+ next if $good_tags{$line};
+ diag("Bad tag: \e[31m$line\e[0m");
+ git( 'tag', '-d', $line );
+ }
+};
@@ -0,0 +1,38 @@
+#!/usr/bin/env perl
+# FILENAME: create_github_repo.pl
+# CREATED: 12/21/13 22:40:10 by Kent Fredric (kentnl) <kentfredric@gmail.com>
+# ABSTRACT: Create a github repo for the current repository
+
+use strict;
+use warnings;
+use utf8;
+use Carp qw(croak);
+
+sub _git_config {
+ my $key = shift;
+ chomp( my $value = `git config --get $key` );
+ croak "Unknown $key" unless $value;
+ return $value;
+}
+
+if ( not @ARGV == 2 ) {
+ die "$0 Repo-Name-Here \"Some Description\"";
+}
+
+my $github_user = _git_config('github.user');
+my $github_token = _git_config('github.token');
+
+use Net::GitHub;
+my $gh = Net::GitHub->new( access_token => $github_token );
+my $reponame = "git\@github.com:" . $github_user . "/" . $ARGV[0] . ".git";
+print "Creating $reponame \n";
+
+my $rp = $gh->repos->create(
+ {
+ name => $ARGV[0],
+ description => $ARGV[1],
+ }
+);
+
+system( 'git', 'remote', 'add', 'origin', $reponame );
+
@@ -37,11 +37,29 @@
cpanm( @params, split /\n/, $stdout );
}
$stdout = capture_stdout {
- safe_exec( 'dzil', 'listdeps', '--missing' );
+ safe_exec( 'dzil', 'listdeps', '--author', '--versions', '--missing' );
};
if ( $stdout !~ /^\s*$/msx ) {
- cpanm( @params, split /\n/, $stdout );
+ my @deps = split /\n/, $stdout;
+ my @parsedeps;
+ for my $dep ( split /\n/, $stdout ) {
+ diag("Missing: \e[31m$dep\e[0m");
+ if ( $dep =~ /^\s*([^=\s]+)\s*=\s*(.*$)/ ) {
+ my ( $module, $version ) = ( $1, $2 );
+ diag("Module: \e[31m$module\e[0m -> \e[32m$version\e[0m");
+ if ( $version =~ /^\s*0\s*$/ ) {
+ push @parsedeps, $module;
+ next;
+ }
+ if ( $version =~ /^v?[0-9._]+/ ) {
+ push @parsedeps, "$module~>=$version";
+ next;
+ }
+ push @parsedeps, "$module~$version";
+ }
+ }
+ cpanm( @params, @parsedeps );
}
}
else {
@@ -0,0 +1,47 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use utf8;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+use tools;
+
+if ( not env_exists('TRAVIS') ) {
+ diag('Is not running under travis!');
+ exit 1;
+}
+if ( not env_exists('STERILIZE_ENV') ) {
+ diag("\e[31STERILIZE_ENV is not set, skipping, because this is probably Travis's Default ( and unwanted ) target");
+ exit 0;
+}
+
+# See https://github.com/dbsrgits/dbix-class/commit/8c11c33f8
+safe_exec_nonfatal( 'sudo', 'ip6tables', '-I', 'OUTPUT', '-d', 'api.metacpan.org', '-j', 'REJECT' );
+my (@params) = qw[ --quiet --notest --mirror http://cpan.metacpan.org/ --no-man-pages ];
+my ($branch) = $ENV{TRAVIS_BRANCH};
+my ($prefix) = './.travis_early_installdeps.';
+
+$branch =~ s{/}{_}g;
+my ($depsfile) = ( $prefix . $branch );
+my ($paramsfile) = ( $prefix . 'params.' . $branch );
+
+if ( not( -e $depsfile and -f $depsfile ) ) {
+ diag("\e[31m$depsfile does not exist, no extra deps\e[0m");
+ exit 0;
+}
+
+my (@deps) = split /\n/, do {
+ open my $fh, '<', $depsfile;
+ local $/ = undef;
+ scalar <$fh>;
+};
+if ( -e $paramsfile and -f $paramsfile ) {
+ push @params, split /\n/, do {
+ open my $fh, '<', $paramsfile;
+ local $/ = undef;
+ scalar <$fh>;
+ };
+}
+cpanm( @params, @deps );
+exit 0;
@@ -6,6 +6,11 @@ package tools;
use Cwd qw(cwd);
use Config;
+sub capture_stdout(&) {
+ require Capture::Tiny;
+ goto &Capture::Tiny::capture_stdout;
+}
+
sub diag {
my $handle = \*STDERR;
for (@_) {
@@ -53,9 +58,11 @@ sub safe_exec {
sub cpanm {
my (@params) = @_;
+ my $cpanm_lines = 4000;
my $exit_code = safe_exec_nonfatal( 'cpanm', @params );
if ( $exit_code != 0 ) {
- safe_exec( 'tail', '-n', '200', '/home/travis/.cpanm/build.log' );
+ diag("\e[32m cpanm \e[0m failed, showing last \e[31m$cpanm_lines\e[0m lines");
+ safe_exec( 'tail', '-n', $cpanm_lines, '/home/travis/.cpanm/build.log' );
exit $exit_code;
}
return 1;
@@ -108,6 +115,9 @@ my $sterile_deployed;
sub deploy_sterile {
return if $sterile_deployed;
+ cpanm( '--skip-satisfied', 'Capture::Tiny' );
+ require Capture::Tiny; # load before we oblitterate everything.
+
fixup_sterile();
for my $key ( keys %Config ) {
next unless $key =~ /(lib|arch)exp$/;
@@ -123,6 +133,32 @@ sub deploy_sterile {
safe_exec( 'rsync', '-a', '--delete-delay', $clean_path, $value );
}
}
+ for my $key ( keys %Config ) {
+ next unless $key =~ /(prefix|bin|scriptdir|script)exp$/;
+ my $value = $Config{$key};
+ next unless defined $value;
+ next unless length $value;
+ my $clean_path = '/tmp/perl5-sterile/' . $key;
+ diag("\e[32m?$clean_path\e[0m");
+ if ( -e $clean_path and -d $clean_path ) {
+ diag("\e[31mPre-Cleaning $value\e[0m");
+ my $content = capture_stdout {
+ safe_exec( 'find', $value, '-type', 'f', '-executable', '-print0' );
+ };
+ for my $file ( split /\0/, $content ) {
+ if ( -B $file ) {
+ diag("\e[33m: Protected\e[34m: $file\e[0m");
+ next;
+ }
+ unlink $file;
+ diag("\e[31m: Removed:\e[34m: $file\e[0m");
+ }
+ diag("\e[31mRsyncing over $value\e[0m");
+ $clean_path =~ s{/?$}{/};
+ $value =~ s{/?$}{/};
+ safe_exec( 'rsync', '-a', $clean_path, $value );
+ }
+ }
}
sub cpanm_fix {
@@ -140,11 +176,6 @@ sub parse_meta_json {
return CPAN::Meta->load_file( $_[0] );
}
-sub capture_stdout(&) {
- require Capture::Tiny;
- goto &Capture::Tiny::capture_stdout;
-}
-
sub import {
my ( $self, @args ) = @_;
@@ -8,6 +8,6 @@
use lib "$FindBin::Bin/lib";
use tools;
-diag("\e[31mLast 1000 lines of cpanm build log\e[0m");
-safe_exec( 'tail', '-n', '1000', $ENV{HOME} . '/.cpanm/build.log' );
+diag("\e[31mLast 4000 lines of cpanm build log\e[0m");
+safe_exec( 'tail', '-n', '4000', $ENV{HOME} . '/.cpanm/build.log' );
View
@@ -21,15 +21,8 @@
exit 0;
}
if ( env_is( 'TRAVIS_BRANCH', 'master' ) ) {
- my $xtest = safe_exec_nonfatal( 'dzil', 'xtest' );
- my $test = safe_exec_nonfatal( 'dzil', 'test' );
- if ( $test != 0 ) {
- exit $test;
- }
- if ( $xtest != 0 ) {
- exit $xtest;
- }
- exit 0;
+ $ENV{HARNESS_OPTIONS} = 'j100:c';
+ safe_exec( 'dzil', 'test', '--release' );
}
else {
my @paths = './t';
@@ -6,28 +6,6 @@
use lib "$FindBin::Bin/lib";
use tools;
-my $corelists = "$FindBin::Bin/corelist-data";
-
-sub no_sterile_warning {
- if ( env_is( 'TRAVIS_PERL_VERSION', '5.8' )
- or env_is( 'TRAVIS_PERL_VERSION', '5.10' ) )
- {
- diag("\e[31m TREE STERILIZATION IMPOSSIBLE <= 5.10\e[0m");
- diag("\e[32m ... because prior to 5.11.*, dual-life installed to \e[33mprivlib\e[0m");
- diag("\e[32m ... because prior to 5.11.*, \e[33m\@INC\e[32m order was \e[33mprivlib,sitelib\e[0m");
- diag("\e[32m ... whereas after to 5.11.*, \e[33m\@INC\e[32m order is \e[33msitelib,privlib\e[0m");
- diag("\e[32m ... and now most dual-life things simply install to \e[33msitelib\e[0m");
- diag("\e[34m ( However, there are still a few naughty CPAN modules that install to \e[33mprivlib\e[34m )");
- diag(
- "\e[32m but the net effect of this is that installing \e[33mModule::Build 0.4007\e[32m which pulls \e[33mPerl::OSType\e[0m"
- );
- diag("\e[32m and results in \e[33mPerl::OSType\e[32m being later removed \e[0m");
- diag("\e[32m leaving behind a broken \e[33mModule::Build 0.4007\e[32m\e[0m");
- diag("\e[34m Set \e[35m MAYBE_BREAK_MODULE_BUILD=1\e[34m if this is ok\e[0m");
- exit 0 unless env_true('MAYBE_BREAK_MODULE_BUILD');
- diag("\e[35m PROCEEDING\e[0m");
- }
-}
if ( not env_exists('STERILIZE_ENV') ) {
diag("\e[31STERILIZE_ENV is not set, skipping, because this is probably Travis's Default ( and unwanted ) target");
exit 0;
@@ -18,10 +18,44 @@ sub git_subtree {
my $travis = 'https://github.com/kentfredric/travis-scripts.git';
my $prefix = 'maint-travis-ci';
-if ( not -d -e $root->child($prefix) ) {
- git_subtree( 'add', '--prefix=' . $prefix, $travis, 'master' );
+my $opts = { pushas => 'incomming' };
+
+for my $id ( 0 .. $#ARGV ) {
+ my ($field) = $ARGV[$id];
+ next unless $field;
+ next unless $field =~ /^-+(.*?$)/;
+ my ($field_name) = $1;
+ my ($value) = $ARGV[ $id + 1 ];
+ undef $ARGV[$id];
+ undef $ARGV[ $id + 1 ];
+ if ( $field_name eq 'push' ) {
+ $opts->{push} = 1;
+ $opts->{push_to} = $value;
+ next;
+ }
+ if ( $field_name eq 'pushas' ) {
+ $opts->{pushas} = $value;
+ next;
+ }
+ if ( $field_name eq 'mc' ) {
+ $opts->{has_commit} = 1;
+ $opts->{commit} = $value;
+ next;
+ }
+}
+if ( not $opts->{push} ) {
+ my $commitish = 'master';
+ $commitish = $opts->{commit} if $opts->{has_commit};
+
+ if ( not -d -e $root->child($prefix) ) {
+ git_subtree( 'add', '--squash', '--prefix=' . $prefix, $travis, $commitish );
+ }
+ else {
+ git_subtree( 'pull', '--squash', '-m', 'Synchronise git subtree maint-travis-ci', '--prefix=' . $prefix, $travis,
+ $commitish );
+ }
}
else {
- git_subtree( 'pull', '-m', 'Synchronise git subtree maint-travis-ci', '--prefix=' . $prefix, $travis, 'master' );
+ git_subtree( 'push', '--prefix=' . $prefix, $opts->{push_to}, $opts->{pushas} );
}
Oops, something went wrong.

0 comments on commit 41e7dc4

Please sign in to comment.