Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

subrepo clone: https://github.com/kentfredric/travis-scripts.git (mas…

…ter) -> maint-travis-ci/

  subdir: maint-travis-ci
  remote: https://github.com/kentfredric/travis-scripts.git
  branch: master
  commit: 7c80dff

git-subrepo version: 0.1.0
  • Loading branch information...
commit 695fda0109a62691d1a577fd8ad2027dfa4c29ad 0 parents
@kentfredric kentfredric authored
2  .perltidyrc
@@ -0,0 +1,2 @@
+-i 2
+-l 130
53 README.mkdn
@@ -0,0 +1,53 @@
+# ABOUT
+
+This repository contains a directory full of utilities to bolt on
+to CPAN-targeting distributions, to add useful `travis-ci` features to those dists.
+
+# PREREQS
+
+All that is needed at present to get started, is a copy of `git` that provides `git subtree`, and a copy of `Path::FindDev` from `CPAN`.
+
+You don't need `Path::FindDev` during deployment, its just used to streamline
+automated patching.
+
+# INSTALLING
+
+First, check out a copy of these scripts, it can be a temporary directory,
+and you'll only need to do this once.
+
+```shell
+$ mkdir /tmp/tci-scripts
+$ cd /tmp/tci-scripts
+$ git clone https://github.com/kentfredric/travis-scripts.git
+```
+
+Then, chdir to the root of your project
+
+```shell
+$ chdir $PROJECT
+```
+
+And lastly, execute the installer
+
+```shell
+$ /tmp/tci-scripts/sync_tree.pl
+```
+
+This will create the folder called `maint-travis-ci` within your distribution,
+with a tree installed by `git subtree`, which will track this distribution.
+
+To update your copy of `/maint-travis-ci` to the latest, simply execute
+
+```shell
+$ $PROJECT/maint-travis-ci/sync_tree.pl
+```
+
+While somewhere in your project.
+
+# CAVEATS
+
+Note, this tool uses `Path::FindDev`, and by proxy, `Path::IsDev` to find a development
+root directory somewhere in the ancestry of `$CWD`.
+
+As such, you will likely need to appease `Path::IsDev` by having a file of some description that
+marks the root of the development tree.
31 before_script.pl
@@ -0,0 +1,31 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+use tools;
+
+if ( not env_exists('STERILIZE_ENV') ) {
+ diag("\e[31mSTERILIZE_ENV \e[32munset\e[0m, skipping");
+ exit 0;
+}
+if ( env_is( 'TRAVIS_BRANCH', 'master' ) ) {
+ diag("before_script skipped, TRAVIS_BRANCH=master");
+ exit 0;
+}
+else {
+ if ( -e './Build.PL' ) {
+ safe_exec( $^X, './Build.PL' );
+ safe_exec("./Build");
+ exit 0;
+ }
+ if ( -e './Makefile.PL' ) {
+ safe_exec( $^X, './Makefile.PL' );
+ safe_exec("make");
+ exit 0;
+ }
+
+}
+
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 );
+ }
+};
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 );
+
87 install_deps.pl
@@ -0,0 +1,87 @@
+#!/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;
+}
+if ( env_is( 'TRAVIS_BRANCH', 'master' ) and env_is( 'TRAVIS_PERL_VERSION', '5.8' ) ) {
+ diag("\e[31minstalldeps skipped on 5.8 on master, because \@Git, a dependency of \@Author::KENTNL, is unavailble on 5.8\e[0m");
+ exit 0;
+}
+my (@params) = qw[ --quiet --notest --mirror http://cpan.metacpan.org/ --no-man-pages ];
+if ( env_true('DEVELOPER_DEPS') ) {
+ push @params, '--dev';
+}
+if ( env_is( 'TRAVIS_BRANCH', 'master' ) ) {
+ cpanm( @params, 'Devel::Confess' );
+ $ENV{PERL5OPT} = '-MDevel::Confess';
+ cpanm( @params, 'Dist::Zilla', 'Capture::Tiny', 'Pod::Weaver' );
+ cpanm( @params, '--dev', 'Dist::Zilla~>5.002', 'Pod::Weaver' );
+ safe_exec( 'git', 'config', '--global', 'user.email', 'kentfredric+travisci@gmail.com' );
+ safe_exec( 'git', 'config', '--global', 'user.name', 'Travis CI ( On behalf of Kent Fredric )' );
+
+ my $stdout = capture_stdout {
+ safe_exec( 'dzil', 'authordeps', '--missing' );
+ };
+
+ if ( $stdout !~ /^\s*$/msx ) {
+ cpanm( @params, split /\n/, $stdout );
+ }
+ $stdout = capture_stdout {
+ safe_exec( 'dzil', 'listdeps', '--author', '--versions', '--missing' );
+ };
+
+ if ( $stdout !~ /^\s*$/msx ) {
+ 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 {
+ cpanm( @params, '--installdeps', '.' );
+ if ( env_true('AUTHOR_TESTING') or env_true('RELEASE_TESTING') ) {
+ my $prereqs = parse_meta_json()->effective_prereqs;
+ my $reqs = $prereqs->requirements_for( 'develop', 'requires' );
+ my @wanted;
+
+ for my $want ( $reqs->required_modules ) {
+ my $module_requirement = $reqs->requirements_for_module($want);
+ if ( $module_requirement =~ /^\d/ ) {
+ push @wanted, $want . '~>=' . $module_requirement;
+ next;
+ }
+ push @wanted, $want . '~' . $module_requirement;
+ }
+ cpanm( @params, @wanted );
+
+ }
+}
+
+exit 0;
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;
204 lib/tools.pm
@@ -0,0 +1,204 @@
+use strict;
+use warnings;
+
+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 (@_) {
+ print {$handle} $_;
+ }
+ print {$handle} "\n";
+}
+
+sub env_exists {
+ return exists $ENV{ $_[0] };
+}
+
+sub env_true {
+ return ( env_exists( $_[0] ) and $ENV{ $_[0] } );
+}
+sub env_is { return ( env_exists( $_[0] ) and $ENV{ $_[0] } eq $_[1] ) }
+
+sub safe_exec_nonfatal {
+ my ( $command, @params ) = @_;
+ diag("running $command @params");
+ my $exit = system( $command, @params );
+ if ( $exit != 0 ) {
+ my $low = $exit & 0b11111111;
+ my $high = $exit >> 8;
+ warn "$command failed: $? $! and exit = $high , flags = $low";
+ if ( $high != 0 ) {
+ return $high;
+ }
+ else {
+ return 1;
+ }
+
+ }
+ return 0;
+}
+
+sub safe_exec {
+ my ( $command, @params ) = @_;
+ my $exit_code = safe_exec_nonfatal( $command, @params );
+ if ( $exit_code != 0 ) {
+ exit $exit_code;
+ }
+ return 1;
+}
+
+sub cpanm {
+ my (@params) = @_;
+ my $cpanm_lines = 4000;
+ my $exit_code = safe_exec_nonfatal( 'cpanm', @params );
+ if ( $exit_code != 0 ) {
+ 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;
+}
+
+sub git {
+ my (@params) = @_;
+ safe_exec( 'git', @params );
+}
+
+my $got_fixes;
+
+sub get_fixes {
+ return if $got_fixes;
+ my $cwd = cwd();
+ chdir '/tmp';
+ safe_exec( 'git', 'clone', 'https://github.com/kentfredric/cpan-fixes.git' );
+ chdir $cwd;
+ $got_fixes = 1;
+}
+
+my $got_sterile;
+
+sub get_sterile {
+ return if $got_sterile;
+ my $cwd = cwd();
+ chdir '/tmp';
+ my $version = $];
+ safe_exec(
+ 'git', 'clone', '--depth=1',
+ '--branch=' . $version,
+ 'https://github.com/kentfredric/perl5-sterile.git',
+ 'perl5-sterile'
+ );
+ chdir $cwd;
+ $got_sterile = 1;
+}
+my $fixed_up;
+
+sub fixup_sterile {
+ return if $fixed_up;
+ get_sterile();
+ my $cwd = cwd();
+ chdir '/tmp/perl5-sterile';
+ safe_exec( 'bash', 'patch_fixlist.sh', '/home/travis/perl5/perlbrew/perls/' . $ENV{TRAVIS_PERL_VERSION} );
+ chdir $cwd;
+ $fixed_up = 1;
+}
+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$/;
+ 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[31mRsyncing over $value\e[0m");
+ $clean_path =~ s{/?$}{/};
+ $value =~ s{/?$}{/};
+ 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 {
+ my (@params) = @_;
+ get_fixes();
+ my $cwd = cwd();
+ chdir '/tmp/cpan-fixes';
+ cpanm(@params);
+ chdir $cwd;
+}
+
+sub parse_meta_json {
+ $_[0] ||= 'META.json';
+ require CPAN::Meta;
+ return CPAN::Meta->load_file( $_[0] );
+}
+
+sub import {
+ my ( $self, @args ) = @_;
+
+ my $caller = [caller]->[0];
+
+ my $caller_stash = do {
+ no strict 'refs';
+ *{ $caller . '::' };
+ };
+
+ $caller_stash->{diag} = *diag;
+ $caller_stash->{env_exists} = *env_exists;
+ $caller_stash->{env_true} = *env_true;
+ $caller_stash->{env_is} = *env_is;
+ $caller_stash->{safe_exec_nonfatal} = *safe_exec_nonfatal;
+ $caller_stash->{safe_exec} = *safe_exec;
+ $caller_stash->{cpanm} = *cpanm;
+ $caller_stash->{git} = *git;
+ $caller_stash->{get_fixes} = *get_fixes;
+ $caller_stash->{cpanm_fix} = *cpanm_fix;
+ $caller_stash->{parse_meta_json} = *parse_meta_json;
+ $caller_stash->{capture_stdout} = *capture_stdout;
+ $caller_stash->{deploy_sterile} = *deploy_sterile;
+}
+
+1;
31 merge_travis_yml.pl
@@ -0,0 +1,31 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use utf8;
+
+use Path::FindDev qw( find_dev );
+
+my $hashref = {};
+
+my $template = find_dev('./')->child('.travis-template.yml');
+my $target = find_dev('./')->child('.travis.yml');
+
+if ( -f -e $template ) {
+ require YAML::Loader;
+ my $loader = YAML::Loader->new();
+ $hashref = $loader->load( $template->slurp );
+}
+
+if ( not exists $hashref->{language} ) {
+ $hashref->{language} = 'perl';
+}
+if ( not exists $hashref->{perl} ) {
+ $hashref->{perl} = [ '5.18', '5.19' ];
+}
+
+use Data::Dump qw(pp);
+pp($hashref);
+require YAML::Dumper;
+my $dumper = YAML::Dumper->new();
+$target->spew( $dumper->dump($hashref) );
13 report_fail_ctx.pl
@@ -0,0 +1,13 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use utf8;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+use tools;
+
+diag("\e[31mLast 4000 lines of cpanm build log\e[0m");
+safe_exec( 'tail', '-n', '4000', $ENV{HOME} . '/.cpanm/build.log' );
+
35 script.pl
@@ -0,0 +1,35 @@
+#!/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[31mSTERILIZE_ENV is not set, skipping, because this is probably Travis's Default ( and unwanted ) target");
+ exit 0;
+}
+if ( env_is( 'TRAVIS_BRANCH', 'master' ) and env_is( 'TRAVIS_PERL_VERSION', '5.8' ) ) {
+ diag("\e[31mscript skipped on 5.8 on master\e[32m, because \@Git, a dependency of \@Author::KENTNL, is unavailble on 5.8\e[0m");
+ exit 0;
+}
+if ( env_is( 'TRAVIS_BRANCH', 'master' ) ) {
+ $ENV{HARNESS_OPTIONS} = 'j100:c';
+ $ENV{PERL5OPT} = '-MDevel::Confess';
+ safe_exec( 'dzil', 'test', '--release' );
+}
+else {
+ my @paths = './t';
+
+ if ( env_true('AUTHOR_TESTING') or env_true('RELEASE_TESTING') ) {
+ push @paths, './xt';
+ }
+ safe_exec( 'prove', '--blib', '--shuffle', '--color', '--recurse', '--timer', '--jobs', 30, @paths );
+}
23 sterilize_env.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+use tools;
+
+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;
+}
+if ( not env_true('STERILIZE_ENV') ) {
+ diag('STERILIZE_ENV unset or false, not sterilizing');
+ exit 0;
+}
+
+if ( not env_true('TRAVIS') ) {
+ diag('Is not running under travis!');
+ exit 1;
+}
+
+deploy_sterile();
81 sync_tree.pl
@@ -0,0 +1,81 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+use tools;
+
+use Path::FindDev qw( find_dev );
+my $root = find_dev('./');
+
+chdir "$root";
+
+sub git_subtree {
+ safe_exec( 'git', 'subtree', @_ );
+}
+
+sub git_subrepo {
+ safe_exec( 'git', 'subrepo', @_ );
+}
+
+my $travis = 'https://github.com/kentfredric/travis-scripts.git';
+my $prefix = 'maint-travis-ci';
+
+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) ) {
+ if ( $ENV{"SUBREPO"} ) {
+ git_subrepo( 'clone', $travis, $prefix, '-b', $commitish );
+ }
+ else {
+ git_subtree( 'add', '--squash', '--prefix=' . $prefix, $travis, $commitish );
+ }
+ }
+ else {
+ if ( $ENV{"SUBREPO"} ) {
+ git_subrepo( 'pull', $prefix, '-b', $commitish );
+ }
+ else {
+
+ git_subtree(
+ 'pull', '--squash', '-m',
+ 'Synchronise git subtree maint-travis-ci',
+ '--prefix=' . $prefix,
+ $travis, $commitish
+ );
+ }
+ }
+}
+else {
+ die "NO!" if $ENV{"SUBREPO"};
+ git_subtree( 'push', '--prefix=' . $prefix, $opts->{push_to}, $opts->{pushas} );
+}
+
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";
+}
54 yamls/sterile.mkdn
@@ -0,0 +1,54 @@
+## ABOUT
+
+ sterile.yaml
+
+## Tests
+
+### Version conformance tests
+
+Every version of Perl that can be tested on travis is tested.
+
+ - perl: <V>
+ env: STERILIZE_ENV=0
+
+This is to test simply that the code works on that platform
+
+### Installable tests
+
+This tests both the maximum and minimum perls on travis to ensure
+that:
+
+ a. All dependencies are installable on all versions of Perl
+ b. No dependencies are inherently required by the code which are not specified.
+
+ - perl: <V>
+ env: STERILIZE_ENV=1
+
+Tree sterilization occurs here to ensure that only the versions of things
+that are provided by that version of perl exists prior to installing dependencies.
+
+### Pending upstream breakage
+
+This tests that of all the listed direct dependencies, that the code works as expected
+after upgrading to the latest version of all direct dependencies.
+
+Presently this only runs on the newest `perl` on travis, because it is seemed that
+if "-dev" versions are going to be a problem, they'll exhibit the same problems on all perls.
+
+Tree sterilization is not performed here, though may be in future, because that will reveal breakages
+between downstream dependencies.
+
+ - perl: <V>
+ env: STERILIZE_ENV=0 DEVELOPER_DEPS=1
+
+### Author Testing
+
+This is the most dependency expensive method, as this mode pulls in all dependencies
+listed in `develop.requires`, and additionally runs `xt/*`
+
+This is presently only performed on the latest perl due to the time expensiveness
+of this, requiring significantly more dependencies to perform tests.
+
+ - perl: <V>
+ env: STERILIZE_ENV=0 RELEASE_TESTING=1 AUTHOR_TESTING=1
+
42 yamls/sterile.yaml
@@ -0,0 +1,42 @@
+language: perl
+matrix:
+ include:
+ - perl: "5.8"
+ env: STERILIZE_ENV=0
+ - perl: "5.10"
+ env: STERILIZE_ENV=0
+ - perl: "5.12"
+ env: STERILIZE_ENV=0
+ - perl: "5.14"
+ env: STERILIZE_ENV=0
+ - perl: "5.16"
+ env: STERILIZE_ENV=0
+ - perl: "5.18"
+ env: STERILIZE_ENV=0
+ - perl: "5.19"
+ env: STERILIZE_ENV=0
+ - perl: "5.12"
+ env: STERILIZE_ENV=1
+ - perl: "5.19"
+ env: STERILIZE_ENV=1
+ - perl: "5.19"
+ env: STERILIZE_ENV=0 DEVELOPER_DEPS=1
+ - perl: "5.19"
+ 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
+before_script:
+ - time perl ./maint-travis-ci/before_script.pl
+script:
+ - time perl ./maint-travis-ci/script.pl
+after_failure:
+ - perl ./maint-travis-ci/report_fail_ctx.pl
+branches:
+ only:
+ - "build/master"
+ - "releases"
+
50 yamls/sterile2.yaml
@@ -0,0 +1,50 @@
+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
+ - perl: "5.10"
+ env: STERILIZE_ENV=0
+ - perl: "5.12"
+ env: STERILIZE_ENV=0
+ - perl: "5.14"
+ env: STERILIZE_ENV=0
+ - perl: "5.16"
+ env: STERILIZE_ENV=0
+ - perl: "5.18"
+ env: STERILIZE_ENV=0
+ - perl: "5.19"
+ env: STERILIZE_ENV=0
+ - perl: "5.8"
+ env: STERILIZE_ENV=1
+ - perl: "5.10"
+ env: STERILIZE_ENV=1
+ - perl: "5.19"
+ env: STERILIZE_ENV=1
+ - perl: "5.19"
+ env: STERILIZE_ENV=0 DEVELOPER_DEPS=1
+ - perl: "5.19"
+ 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
+script:
+ - time perl ./maint-travis-ci/script.pl
+after_failure:
+ - perl ./maint-travis-ci/report_fail_ctx.pl
+branches:
+ only:
+ - "master"
+ - "build/master"
+ - "releases"
+
Please sign in to comment.
Something went wrong with that request. Please try again.