Permalink
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...
0 parents commit 695fda0109a62691d1a577fd8ad2027dfa4c29ad @kentfredric kentfredric committed Mar 1, 2014
Showing with 930 additions and 0 deletions.
  1. +2 −0 .perltidyrc
  2. +53 −0 README.mkdn
  3. +31 −0 before_script.pl
  4. +51 −0 branch_reset.pl
  5. +38 −0 create_github_repo.pl
  6. +87 −0 install_deps.pl
  7. +47 −0 install_deps_early.pl
  8. +204 −0 lib/tools.pm
  9. +31 −0 merge_travis_yml.pl
  10. +13 −0 report_fail_ctx.pl
  11. +35 −0 script.pl
  12. +23 −0 sterilize_env.pl
  13. +81 −0 sync_tree.pl
  14. +88 −0 travis_enable.pl
  15. +54 −0 yamls/sterile.mkdn
  16. +42 −0 yamls/sterile.yaml
  17. +50 −0 yamls/sterile2.yaml
@@ -0,0 +1,2 @@
+-i 2
+-l 130
@@ -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.
@@ -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;
+ }
+
+}
+
@@ -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 );
+
@@ -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;
@@ -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;
Oops, something went wrong. Retry.

0 comments on commit 695fda0

Please sign in to comment.