summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-09-23 22:09:36 +0200
committerfranck cuny <franck@lumberjaph.net>2010-09-23 22:09:36 +0200
commit585ce5b679406ffe8644b23e3a267d7af8e3a5de (patch)
tree27dff9a966b9c265e929330b48314f1c38d48428 /scripts
parentignore logs (diff)
downloadjitterbug-585ce5b679406ffe8644b23e3a267d7af8e3a5de.tar.gz
initial import
Diffstat (limited to 'scripts')
-rw-r--r--scripts/builder.pl74
-rwxr-xr-xscripts/builder.sh21
-rwxr-xr-xscripts/capsule.sh26
3 files changed, 121 insertions, 0 deletions
diff --git a/scripts/builder.pl b/scripts/builder.pl
new file mode 100644
index 0000000..d65ace8
--- /dev/null
+++ b/scripts/builder.pl
@@ -0,0 +1,74 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Redis;
+use JSON;
+use YAML qw/LoadFile Dump/;
+use File::Spec;
+use File::Path qw/rmtree/;
+use File::Basename;
+use Git::Repository;
+
+$|++;
+
+my $conf = LoadFile('config.yml');
+my $redis = Redis->new(server => $conf->{redis});
+my $key = join(':', 'jitterbug', 'tasks');
+
+while (1) {
+ my $task_key = $redis->spop($key);
+ if ($task_key) {
+ my $task = $redis->get($task_key);
+ my $desc = JSON::decode_json($task);
+ my $repo = $desc->{repo} . '.git';
+ my $commit = delete $desc->{id};
+ my $project = delete $desc->{project};
+
+ my $report_path =
+ File::Spec->catdir( $conf->{jitterbug}->{reports}->{dir},
+ $project, $commit );
+
+ my $build_dir =
+ File::Spec->catdir( $conf->{jitterbug}->{build}->{dir}, $project );
+
+ # my $r = Git::Repository->create( clone => $repo => $build_dir );
+ # $r->run('checkout', $commit);
+
+ # my $res = `./scripts/capsule.sh $build_dir $report_path`;
+
+ # rmtree($build_dir);
+
+ $redis->del($task_key);
+
+ my $build = {
+ project => $project,
+ repo => $repo,
+ commit => $commit,
+ status => 1,
+ time => time(),
+ %$desc,
+ };
+
+ my @versions = glob($report_path.'/*');
+ foreach my $version (@versions) {
+ open my $fh, '<', $version;
+ my @lines = <$fh>;
+ my $result = pop @lines;
+ chomp $result;
+ $result =~ s/Result:\s//;
+ my ($name, ) = basename($version);
+ $name =~ s/\.txt//;
+ $build->{version}->{$name} = $result;
+ }
+
+ my $build_key = join( ':', 'jitterbug', 'build', $commit );
+ $redis->set( $build_key, JSON::encode_json($build) );
+
+ my $project_build = join( ':', 'jitterbug', 'builds', $project );
+ $redis->sadd( $project_build, $build_key );
+ warn "done, next\n";
+ }
+ sleep 5;
+}
diff --git a/scripts/builder.sh b/scripts/builder.sh
new file mode 100755
index 0000000..01eb92e
--- /dev/null
+++ b/scripts/builder.sh
@@ -0,0 +1,21 @@
+#!/bin/sh -e
+
+gitrepo=$1
+project=$2
+commit=$3
+
+ORIGIN=$(pwd)
+BUILDDIR=$(mktemp -d)
+LOGDIR="/tmp/jitterbug"
+mkdir -p $LOGDIR
+logfile="$LOGDIR/$project.$commit.txt"
+cd $BUILDDIR
+rm -rf $project
+git clone $gitrepo $project
+cd $project
+git checkout $commit
+perl Makefile.PL
+make
+make test 2>&1 > $logfile
+cd ..
+rm -rf $BUILDDIR
diff --git a/scripts/capsule.sh b/scripts/capsule.sh
new file mode 100755
index 0000000..946c38c
--- /dev/null
+++ b/scripts/capsule.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+set -e
+
+builddir=$1
+report_path=$2
+
+mkdir -p $report_path
+
+cd $builddir
+
+source $HOME/perl5/perlbrew/etc/bashrc
+
+for perl in $HOME/perl5/perlbrew/perls/perl-5.12.*
+do
+ theperl="$(basename $perl)"
+ perlbrew switch $theperl
+ hash -r
+
+ perlversion=$(perl -v)
+ logfile="$report_path/$theperl.txt"
+
+ perl Makefile.PL
+ make
+ HARNESS_VERBOSE=1 make test >> $logfile 2>&1
+done