Browse files

Squashed 'maint-travis-ci/' changes from 7d68792..dcbffe2

dcbffe2 support committishes for add
1f58620 add a pull-to-commit version
5c4b012 Blackhole ipv6 for api.metacpan.org till they fix things
ed83258 Tidy travis
9bbf979 Specialise for my tooling
b7aea38 Add dagoldens travis-enable script
14e48d8 Add create_github_repo tool
75aad7e Use squash merges for pull, these histories are getting rediculous
6224e92 remove superflous \n
bb44486 Use dzil test --release instead of xtest/test
9098211 Enable installdeps_early step
dfa51b9 Attempt to fix bug with non-master
6db9993 Add early installdeps
5f9701c load capture::tiny early if were' oblitterating
3e806ca Actually capture output
9a5a08a Experimental specialcasing of binary directories
729fb9b Support more sterile path transplants
652d691 Show more cpanm context
8834633 nonfatalise branch_reset tricks
da3c391 Allow failures on extra-test branches
92bb0e7 Short Circuit properly
804393c Handle variable assignment properly
8a25037 Further attempt to debug parse
2762299 Use --version(s), and show parse output"
01cc441 Attempt to properly handle authordeps on master
2072acb Add pushscript
efd393d Make decoration parsing more obvious
ff1a124 Fix silly error
037ed0b Enhanced Good/Bad tag clearing
5931c84 Improve branch reset code to annihilate new tags
1ffe498 Enable branch reset trick
6fa9119 Add branch reset script
9a094de Corelists also gone
e414000 Remove bogus warning that we've now eliminated the need for

git-subtree-dir: maint-travis-ci
git-subtree-split: dcbffe2
  • Loading branch information...
1 parent 24f13c6 commit 74d42c3ff36a37f512eb1ec20e17913d469884e9 @kentfredric kentfredric committed Jan 14, 2014
Showing with 329 additions and 44 deletions.
  1. +51 −0 branch_reset.pl
  2. +38 −0 create_github_repo.pl
  3. +20 −2 install_deps.pl
  4. +47 −0 install_deps_early.pl
  5. +37 −6 lib/tools.pm
  6. +2 −2 report_fail_ctx.pl
  7. +2 −9 script.pl
  8. +0 −22 sterilize_env.pl
  9. +37 −3 sync_tree.pl
  10. +88 −0 travis_enable.pl
  11. +1 −0 yamls/sterile.yaml
  12. +6 −0 yamls/sterile2.yaml
View
51 branch_reset.pl
@@ -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 );
+ }
+};
View
38 create_github_repo.pl
@@ -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 );
+
View
22 install_deps.pl
@@ -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 {
View
47 install_deps_early.pl
@@ -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;
View
43 lib/tools.pm
@@ -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 ) = @_;
View
4 report_fail_ctx.pl
@@ -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
11 script.pl
@@ -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';
View
22 sterilize_env.pl
@@ -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;
View
40 sync_tree.pl
@@ -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} );
}
View
88 travis_enable.pl
@@ -0,0 +1,88 @@
+#!/usr/bin/env perl
+use v5.10;
+use strict;
+use warnings;
+use Carp;
+use Net::GitHub;
+use Getopt::Lucid ':all';
+use Path::Tiny;
+use FindBin;
+
+my $yamls = path($FindBin::Bin)->child('yamls');
+
+my $opts = Getopt::Lucid->getopt(
+ [
+ #<<< No perltidy
+ Param('repo|r'),
+ #>>>
+ ]
+);
+
+$opts->validate;
+
+sub _detect_repo {
+ my ($origin) = grep { /origin/ } `git remote -v`;
+
+ die "Couldn't determine origin\n" unless $origin;
+
+ chomp $origin;
+ $origin =~ s/^origin\s+//;
+ $origin =~ s/\s+\(.*$//;
+ if ( $origin =~ m{^.+?://github.com/([^/]+)/(.+)\.git$} ) {
+ return [ $1, $2 ];
+ }
+ elsif ( $origin =~ m{^git\@github\.com:([^/]+)/(.+)\.git$} ) {
+ return [ $1, $2 ];
+ }
+ else {
+ die "Can't determine repo name from '$origin'. Try manually with -r REPO\n";
+ }
+}
+
+sub _git_config {
+ my $key = shift;
+ chomp( my $value = `git config --get $key` );
+ croak "Unknown $key" unless $value;
+ return $value;
+}
+
+my $github_user = _git_config("github.user");
+my $github_token = _git_config("github.token");
+my $travis_token = _git_config("travis.token");
+
+my $gh = Net::GitHub->new( access_token => $github_token );
+
+my @repos;
+
+if ( $opts->get_repo ) {
+ @repos = $opts->get_repo;
+}
+else {
+ ( $github_user, @repos ) = @{ _detect_repo() };
+}
+
+my $hook_hash = {
+ name => 'travis',
+ config => {
+ token => $travis_token,
+ user => $github_user,
+ domain => '',
+ },
+ events => [qw/push pull_request issue_comment public member/],
+ active => 1,
+};
+
+my $repos = $gh->repos;
+$repos->set_default_user_repo( $github_user, $repos[0] );
+my $hook = eval { $repos->create_hook($hook_hash) };
+if ($@) {
+ say "Failed: $@";
+}
+else {
+ say "Enabled travis for $repos[0]";
+}
+
+unless ( -f '.travis.yml' ) {
+ $yamls->child('sterile2.yaml')->copy('./.travis.yml');
+ say "copied .travis.yml to current directory";
+}
View
1 yamls/sterile.yaml
@@ -25,6 +25,7 @@ matrix:
env: STERILIZE_ENV=0 RELEASE_TESTING=1 AUTHOR_TESTING=1
before_install:
- perlbrew list
+ - time perl ./maint-travis-ci/branch_reset.pl
- time perl ./maint-travis-ci/sterilize_env.pl
install:
- time perl ./maint-travis-ci/install_deps.pl
View
6 yamls/sterile2.yaml
@@ -1,5 +1,9 @@
language: perl
matrix:
+ allow_failures:
+ - perl: "5.8"
+ - env: STERILIZE_ENV=0 RELEASE_TESTING=1 AUTHOR_TESTING=1
+ - env: STERILIZE_ENV=0 DEVELOPER_DEPS=1
include:
- perl: "5.8"
env: STERILIZE_ENV=0
@@ -27,8 +31,10 @@ matrix:
env: STERILIZE_ENV=0 RELEASE_TESTING=1 AUTHOR_TESTING=1
before_install:
- perlbrew list
+ - time perl ./maint-travis-ci/branch_reset.pl
- time perl ./maint-travis-ci/sterilize_env.pl
install:
+ - time perl ./maint-travis-ci/install_deps_early.pl
- time perl ./maint-travis-ci/install_deps.pl
before_script:
- time perl ./maint-travis-ci/before_script.pl

0 comments on commit 74d42c3

Please sign in to comment.