Archived
1
0
Fork 0

Add hook on tests to create the testsuite

This commit is contained in:
Mercier Pierre-Olivier 2013-10-01 04:35:35 +02:00
parent 140be16b5c
commit 0d26658a35

View file

@ -19,7 +19,7 @@ exit 0 if ($ENV{GL_REPO} !~ /^subjects\//);
my ($ref, $oldsha, $newsha) = @ARGV;
log WARN, "This is a subject!";
log DONE, "This is a subject repository!";
my %known_tags = (
"defense" => \&tag_defense,
@ -533,7 +533,8 @@ sub tag_ref
# Send data to moulette
log INFO, "Attente d'un processus de compilation...";
if (my $err = Process::Client::launch("moulette_get", {
type => "ref",
type => "tar",
login => "ref",
id => $project_id,
"year" => $year,
"rendu" => $rendu,
@ -561,7 +562,7 @@ sub tag_ref
log ERROR, "Tag long correspondant introuvable : $long_tag.";
}
log USAGE, "Suppression du projet !";
log USAGE, "Suppression du tag de ref !";
if ($long_tag)
{
@ -575,5 +576,111 @@ sub tag_ref
sub tag_tests
{
my $creation = shift;
# From here, we have:
# 0: "tests"
# 1: $id
# 2: rendu-X
# 3: $year
my $project_id = repository_name();
if ($_[1]) {
# Check on ID/flavour_id
if ($_[1] =~ /^\d+$/) {
log ERROR, "tests,* tag can't take version. Tag format: tests,id,rendu,year";
}
$project_id .= "-" . $_[1];
}
$project_id = lc $project_id;
$project_id =~ s/[^a-z0-9-_]/_/g;
my $rendu;
if ($_[2]) {
$rendu = $_[2];
}
else {
$rendu = "*";
}
my $year;
if ($_[3])
{
# Check on year
if ($_[3] !~ /^\d+$/) {
log ERROR, "tests,*,*,* third argument is the year. Tag format: tests,id,rendu,year";
}
$year = $_[3];
}
else {
$year = LDAP::get_year;
}
# Determine full tag
my $long_tag;
{
my $proj_id = $_[1] // "";
$long_tag = "tests,$proj_id,$rendu,$year";
}
if ($creation)
{
my $newref = $ARGV[2];
log INFO, "Création/mise à jour de la testsuite...";
my $content = qx(git show $newref:tests/Makefile);
# Check file exists
if ($?) {
log ERROR, "Un fichier Makefile est requis pour pouvoir compiler la testsuite.";
}
log INFO, "Création de la tarball...";
my $archive = qx(git archive --format=tgz $newref tests/);
# Send data to moulette
log INFO, "Attente d'un processus de compilation...";
if (my $err = Process::Client::launch("moulette_get", {
type => "tests",
id => $project_id,
"year" => $year,
"rendu" => $rendu,
"file" => "tests_$rendu.tgz"
}, { "tests_$rendu.tgz" => $archive }))
{
if (${ $err } ne "Ok") {
log ERROR, "Erreur durant le processus de compilation : " . ${ $err };
}
}
if ($long_tag)
{
qx(git tag -f $long_tag $newref);
if (! $?) {
log INFO, "Tag long créé : $long_tag.";
}
}
}
else
{
# Is the long tag existing
qx(git tag | egrep "^$long_tag\$");
if ($?) {
log ERROR, "Tag long correspondant introuvable : $long_tag.";
}
log USAGE, "Suppression du tag de la testsuite !";
if ($long_tag)
{
qx(git tag -d $long_tag);
if (! $?) {
log INFO, "Tag long supprimé : $long_tag.";
}
}
}
}