summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2015-01-23 11:23:22 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2015-01-23 11:23:22 +0000
commit1710aa1c5f4bc95695f5030c900d37174fe05ad7 (patch)
tree2fe98b7585dbdcf87e42fa0d23f0e856a46325a1
parentf2f3e4e5f3d5162890d03494f405cff5177aaad8 (diff)
parent837a7a34df88ae2e10339e42553010b08d92fc62 (diff)
downloadmorph-1710aa1c5f4bc95695f5030c900d37174fe05ad7.tar.gz
Merge branch 'baserock/richardipsum/build-command-tweak-v3'
Reviewed by: Adam Coldrick <adam.coldrick@codethink.co.uk> Richard Maw <richard.maw@gmail.com>
-rw-r--r--morphlib/plugins/build_plugin.py8
-rw-r--r--morphlib/plugins/deploy_plugin.py6
-rw-r--r--morphlib/sysbranchdir.py8
-rw-r--r--yarns/building.yarn30
-rw-r--r--yarns/deployment.yarn45
-rw-r--r--yarns/implementations.yarn61
6 files changed, 124 insertions, 34 deletions
diff --git a/morphlib/plugins/build_plugin.py b/morphlib/plugins/build_plugin.py
index c5adffb7..e9290b8d 100644
--- a/morphlib/plugins/build_plugin.py
+++ b/morphlib/plugins/build_plugin.py
@@ -17,6 +17,7 @@
import cliapp
import contextlib
import uuid
+import logging
import morphlib
@@ -160,11 +161,14 @@ class BuildPlugin(cliapp.Plugin):
self.app.settings['cachedir'],
self.app.settings['cachedir-min-space'])
- system_filename = morphlib.util.sanitise_morphology_path(args[0])
-
ws = morphlib.workspace.open('.')
sb = morphlib.sysbranchdir.open_from_within('.')
+ system_filename = morphlib.util.sanitise_morphology_path(args[0])
+ system_filename = sb.relative_to_root_repo(system_filename)
+
+ logging.debug('System branch is %s' % sb.root_directory)
+
if self.use_distbuild:
addr = self.app.settings['controller-initiator-address']
port = self.app.settings['controller-initiator-port']
diff --git a/morphlib/plugins/deploy_plugin.py b/morphlib/plugins/deploy_plugin.py
index 87fd259f..6d506a21 100644
--- a/morphlib/plugins/deploy_plugin.py
+++ b/morphlib/plugins/deploy_plugin.py
@@ -335,11 +335,12 @@ class DeployPlugin(cliapp.Plugin):
self.app.settings['tempdir-min-space'],
'/', 0)
- cluster_filename = morphlib.util.sanitise_morphology_path(args[0])
-
ws = morphlib.workspace.open('.')
sb = morphlib.sysbranchdir.open_from_within('.')
+ cluster_filename = morphlib.util.sanitise_morphology_path(args[0])
+ cluster_filename = sb.relative_to_root_repo(cluster_filename)
+
build_uuid = uuid.uuid4().hex
build_command = morphlib.buildcommand.BuildCommand(self.app)
@@ -351,6 +352,7 @@ class DeployPlugin(cliapp.Plugin):
build_ref_prefix = self.app.settings['build-ref-prefix']
root_repo_dir = morphlib.gitdir.GitDirectory(
sb.get_git_directory_name(sb.root_repository_url))
+
cluster_text = root_repo_dir.read_file(cluster_filename)
cluster_morphology = loader.load_from_string(cluster_text,
filename=cluster_filename)
diff --git a/morphlib/sysbranchdir.py b/morphlib/sysbranchdir.py
index 4dbc5f6c..80e56b33 100644
--- a/morphlib/sysbranchdir.py
+++ b/morphlib/sysbranchdir.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2014 Codethink Limited
+# Copyright (C) 2013-2015 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -107,6 +107,11 @@ class SystemBranchDirectory(object):
return os.path.join(self.root_directory, relative)
+ def relative_to_root_repo(self, path): # pragma: no cover
+ gitdirpath = self.get_git_directory_name(self.root_repository_url)
+
+ return os.path.relpath(os.path.abspath(path), gitdirpath)
+
def get_git_directory_name(self, repo_url):
'''Return directory pathname for a given git repository.
@@ -123,6 +128,7 @@ class SystemBranchDirectory(object):
'''
found_repo = self._find_git_directory(repo_url)
+
if not found_repo:
return self._fabricate_git_directory_name(repo_url)
return found_repo
diff --git a/yarns/building.yarn b/yarns/building.yarn
index 253b3b3c..52f2b561 100644
--- a/yarns/building.yarn
+++ b/yarns/building.yarn
@@ -6,7 +6,35 @@ Morph Building Tests
AND a git server
WHEN the user checks out the system branch called master
AND the user creates an uncommitted system morphology called systems/base-system.morph for our architecture in system branch master
- THEN morph build the system systems/base-system.morph of the branch master
+ AND the user attempts to build the system systems/base-system.morph in branch master
+ THEN morph succeeded
+ FINALLY the git server is shut down
+
+ SCENARIO build system with relative path
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ AND the user creates an uncommitted system morphology called systems/base-system.morph for our architecture in system branch master
+ AND from the directory workspace/master/test/morphs/systems the user attempts to morph build the system base-system.morph
+ THEN morph succeeded
+ FINALLY the git server is shut down
+
+ SCENARIO build system with relative path (second variant)
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ AND the user creates an uncommitted system morphology called systems/base-system.morph for our architecture in system branch master
+ AND from the directory workspace/master/test/morphs/systems the user attempts to morph build the system ../systems/base-system.morph
+ THEN morph succeeded
+ FINALLY the git server is shut down
+
+ SCENARIO build system with absolute path
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ AND the user creates an uncommitted system morphology called systems/base-system.morph for our architecture in system branch master
+ AND from the directory workspace/master/test/morphs/systems the user attempts to morph build the system using the absolute path to base-system.morph
+ THEN morph succeeded
FINALLY the git server is shut down
System integrations
diff --git a/yarns/deployment.yarn b/yarns/deployment.yarn
index 0782c7c1..47aeff5d 100644
--- a/yarns/deployment.yarn
+++ b/yarns/deployment.yarn
@@ -14,13 +14,35 @@ Morph Deployment Tests
GIVEN a workspace
AND a git server
WHEN the user checks out the system branch called master
- GIVEN a cluster called test-cluster.morph in system branch master
- AND a system in cluster test-cluster.morph in branch master called test-system
- AND system test-system in cluster test-cluster.morph in branch master builds systems/test-system.morph
- AND system test-system in cluster test-cluster.morph in branch master has deployment type: tar
- AND system test-system in cluster test-cluster.morph in branch master has deployment location: test.tar
- WHEN the user builds the system systems/test-system.morph in branch master
- AND the user attempts to deploy the cluster test-cluster.morph in branch master
+ AND the user builds the system systems/test-system.morph in branch master
+ AND the user attempts to deploy the cluster clusters/test-cluster.morph in branch master
+ THEN morph succeeded
+ FINALLY the git server is shut down
+
+ SCENARIO deploying a cluster using a relative path
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ AND the user builds the system systems/test-system.morph in branch master
+ AND from directory workspace/master/test/morphs/clusters the user attempts to deploy the cluster test-cluster.morph in branch master
+ THEN morph succeeded
+ FINALLY the git server is shut down
+
+ SCENARIO deploying a cluster using a relative path (second variant)
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ AND the user builds the system systems/test-system.morph in branch master
+ AND from directory workspace/master/test/morphs/clusters the user attempts to deploy the cluster ../clusters/test-cluster.morph in branch master
+ THEN morph succeeded
+ FINALLY the git server is shut down
+
+ SCENARIO deploying a cluster using an absolute path
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ AND the user builds the system systems/test-system.morph in branch master
+ AND from directory workspace/master/test/morphs/clusters the user attempts to deploy the cluster using the absolute path to test-cluster.morph in branch master
THEN morph succeeded
FINALLY the git server is shut down
@@ -31,13 +53,8 @@ this clear.
GIVEN a workspace
AND a git server
WHEN the user checks out the system branch called master
- GIVEN a cluster called test-cluster.morph in system branch master
- AND a system in cluster test-cluster.morph in branch master called test-system
- AND system test-system in cluster test-cluster.morph in branch master builds systems/test-system.morph
- AND system test-system in cluster test-cluster.morph in branch master has deployment type: tar
- AND system test-system in cluster test-cluster.morph in branch master has deployment location: test.tar
- WHEN the user builds the system systems/test-system.morph in branch master
- AND the user attempts to upgrade the cluster test-cluster.morph in branch master
+ AND the user builds the system systems/test-system.morph in branch master
+ AND the user attempts to upgrade the cluster clusters/test-cluster.morph in branch master
THEN morph failed
FINALLY the git server is shut down
diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn
index e1ae271f..8b43286f 100644
--- a/yarns/implementations.yarn
+++ b/yarns/implementations.yarn
@@ -247,6 +247,19 @@ another to hold a chunk.
morph: strata/core.morph
EOF
+ mkdir "$DATADIR/gits/morphs/clusters"
+ cd "$DATADIR/gits/morphs"
+ install -m644 -D /dev/stdin << EOF "clusters/test-cluster.morph"
+ name: test-cluster
+ kind: cluster
+ systems:
+ - morph: systems/test-system.morph
+ deploy:
+ test-system:
+ type: tar
+ location: test.tar
+ EOF
+
install -m644 -D /dev/stdin << EOF "strata/build-essential.morph"
name: build-essential
kind: stratum
@@ -703,7 +716,7 @@ Implementation sections for building
====================================
IMPLEMENTS WHEN the user (attempts to )?((dist)?build)s? the system (\S+) in branch (\S+)
- cd "$DATADIR/workspace/$MATCH_5"
+ cd "$DATADIR/workspace/$MATCH_5/test/morphs"
set "$MATCH_2" "$MATCH_4"
if [ "$MATCH_1" != "attempts to " ]; then run_morph "$@"
else attempt_morph "$@"; fi
@@ -712,7 +725,7 @@ Implementation sections for cross-bootstraping
==============================================
IMPLEMENTS THEN the user cross-bootstraps the system (\S+) in branch (\S+) of repo (\S+) to the arch (\S+)
- cd "$DATADIR/workspace/$MATCH_2"
+ cd "$DATADIR/workspace/$MATCH_2/test/morphs"
set -- cross-bootstrap "$MATCH_4" "$MATCH_3" "$MATCH_2" "$MATCH_1"
run_morph "$@"
@@ -723,32 +736,44 @@ Defaults are set in the cluster morphology, so we can deploy without
setting any extra parameters, but we also need to be able to override
them, so they can be added to the end of the implements section.
- IMPLEMENTS WHEN the user (attempts to deploy|deploys) the (system|cluster) (\S+) in branch (\S+)( with options (.*))?
- cd "$DATADIR/workspace/$MATCH_4"
- set -- deploy "$MATCH_3"
- if [ "$MATCH_5" != '' ]; then
+ IMPLEMENTS WHEN (from directory (\S+) )?the user (attempts to deploy|deploys) the (system|cluster) (using the absolute path to )?(\S+) in branch (\S+)( with options (.*))?
+ if [ "$MATCH_1" != "" ]
+ then
+ cd "$DATADIR/$MATCH_2"
+ else
+ cd "$DATADIR/workspace/$MATCH_7/test/morphs"
+ fi
+
+ if [ "$MATCH_5" != "" ]
+ then
+ set -- deploy "$(pwd)/$MATCH_6"
+ else
+ set -- deploy "$MATCH_6"
+ fi
+
+ if [ "$MATCH_8" != '' ]; then
# eval used so word splitting in the text is preserved
- eval set -- '"$@"' $MATCH_6
+ eval set -- '"$@"' $MATCH_9
fi
- if [ $MATCH_1 == "deploys" ]; then run_morph "$@"
+ if [ "$MATCH_3" = "deploys" ]; then run_morph "$@"
else attempt_morph "$@"; fi
IMPLEMENTS WHEN the user (attempts to deploy|deploys) (.*) from cluster (\S+) in branch (\S+)
- cd "$DATADIR/workspace/$MATCH_4"
+ cd "$DATADIR/workspace/$MATCH_4/test/morphs"
set -- deploy "$MATCH_3"
systems=$(echo "$MATCH_2" | sed -e 's/, /\n/g' -e 's/ and /\n/g')
set -- "$@" $systems
- if [ $MATCH_1 == "deploys" ]; then run_morph "$@"
+ if [ "$MATCH_1" = "deploys" ]; then run_morph "$@"
else attempt_morph "$@"; fi
IMPLEMENTS WHEN the user (attempts to upgrade|upgrades) the (system|cluster) (\S+) in branch (\S+)( with options (.*))?
- cd "$DATADIR/workspace/$MATCH_4"
+ cd "$DATADIR/workspace/$MATCH_4/test/morphs"
set -- upgrade "$MATCH_3"
if [ "$MATCH_5" != '' ]; then
# eval used so word splitting in the text is preserved
eval set -- '"$@"' $MATCH_6
fi
- if [ $MATCH_1 == "upgrades" ]; then run_morph "$@"
+ if [ "$MATCH_1" = "upgrades" ]; then run_morph "$@"
else attempt_morph "$@"; fi
Implementations sections for reading error messages
@@ -892,13 +917,21 @@ Implementations for building systems
------------------------------------
IMPLEMENTS THEN morph ((dist)?build) the system (\S+) of the (branch|tag) (\S+)
- cd "$DATADIR/workspace/$MATCH_5"
+ cd "$DATADIR/workspace/$MATCH_5/test/morphs"
run_morph "$MATCH_1" "$MATCH_3"
IMPLEMENTS WHEN the user builds (\S+) of the (\S+) (branch|tag)
- cd "$DATADIR/workspace/$MATCH_2"
+ cd "$DATADIR/workspace/$MATCH_2/test/morphs"
run_morph build "$MATCH_1"
+ IMPLEMENTS WHEN from the directory (\S+) the user attempts to morph build the system (\S+)
+ cd "$DATADIR/$MATCH_1"
+ attempt_morph build "$MATCH_2"
+
+ IMPLEMENTS WHEN from the directory (\S+) the user attempts to morph build the system using the absolute path to (\S+)
+ cd "$DATADIR/$MATCH_1"
+ attempt_morph build "$(pwd)/$MATCH_2"
+
Implementations for tarball inspection
--------------------------------------