summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2014-01-22 11:35:36 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2014-01-22 11:35:36 +0000
commit28196991ede6bd5ed561fc7dc4a2b0084019df19 (patch)
treed069ffb1c48a46fa6f404a63e9613da86aa3e9ec
parent2a702ed211532e277ecbeaff3f0bc345a34cbfe6 (diff)
parent4c1acc88e81971172f6dc5b0d31f1eb8471cd0d2 (diff)
downloadmorph-28196991ede6bd5ed561fc7dc4a2b0084019df19.tar.gz
Merge branch 'baserock/richardmaw/S10135/fixups-v2' of git://git.baserock.org/baserock/baserock/morph
Reviewed-by: Sam Thursfield
-rw-r--r--morphlib/cachekeycomputer.py11
-rw-r--r--tests.as-root/run-in-artifact-with-different-artifacts.stderr2
-rw-r--r--tests.build/bootstrap-mode.stdout4
-rw-r--r--yarns/splitting.yarn91
4 files changed, 102 insertions, 6 deletions
diff --git a/morphlib/cachekeycomputer.py b/morphlib/cachekeycomputer.py
index 2312abc3..bb536f82 100644
--- a/morphlib/cachekeycomputer.py
+++ b/morphlib/cachekeycomputer.py
@@ -81,7 +81,8 @@ class CacheKeyComputer(object):
keys = {
'env': self._filterenv(self._build_env.env),
'filename': artifact.source.filename,
- 'kids': [self.compute_key(x) for x in artifact.dependencies],
+ 'kids': [{'artifact': a.name, 'cache-key': self.compute_key(a)}
+ for a in artifact.dependencies],
'metadata-version': artifact.metadata_version
}
@@ -97,8 +98,12 @@ class CacheKeyComputer(object):
le_dict = dict((k, morphology[k]) for k in morphology.keys())
# Disregard all fields of a morphology that aren't important
- ignored_fields = ('strata', 'build-depends', 'description',
- 'chunks')
+ ignored_fields = (
+ 'description', # purely cosmetic, doesn't change builds
+ # The following are used to determine dependencies,
+ # so are already handled by the 'kids' field.
+ 'strata', 'build-depends', 'chunks',
+ 'products')
for ignored_field in ignored_fields:
if ignored_field in le_dict:
del le_dict[ignored_field]
diff --git a/tests.as-root/run-in-artifact-with-different-artifacts.stderr b/tests.as-root/run-in-artifact-with-different-artifacts.stderr
index 236954f8..9241fbb5 100644
--- a/tests.as-root/run-in-artifact-with-different-artifacts.stderr
+++ b/tests.as-root/run-in-artifact-with-different-artifacts.stderr
@@ -1 +1 @@
-ERROR: Artifact TMP/cache/artifacts/4a8b7a698ae79f417b1ff1541b883bd9f99fdf287a0d1a4176e7353dbe51a5fa.stratum.linux-stratum-runtime cannot be extracted or mounted
+ERROR: Artifact TMP/cache/artifacts/e8e771e742c8f2199bd9f1e29cbeca07dbd51dd8880136d6521093711d37d8bf.stratum.linux-stratum-runtime cannot be extracted or mounted
diff --git a/tests.build/bootstrap-mode.stdout b/tests.build/bootstrap-mode.stdout
index b59d0029..e1747b15 100644
--- a/tests.build/bootstrap-mode.stdout
+++ b/tests.build/bootstrap-mode.stdout
@@ -1,7 +1,7 @@
build-essential strata:
-./5bbfd4cb94017e7b72e20ee4f91a76bed8085aa96176cf87ecce54ec71d5ddae.stratum.build-essential-devel
+./2271bef9cb222b1fd49bd2bcf3da435e02b4e0ce9fdddbcdf9358f608f51b547.stratum.build-essential-devel
["xxxx.chunk.cc-devel", "xxxx.chunk.cc-doc"]
-./c8fe8efd4f8c6edcd309bb2cf0a308c93dfd905bbff64be98c5b07f350951fde.stratum.build-essential-runtime
+./2a908a170acf10b4e9e131a007c8f3f0fa4961a7227c60793b3550c107f4c312.stratum.build-essential-runtime
["xxxx.chunk.cc-bins", "xxxx.chunk.cc-libs", "xxxx.chunk.cc-locale", "xxxx.chunk.cc-misc"]
hello-system:
diff --git a/yarns/splitting.yarn b/yarns/splitting.yarn
index e3324190..e55d5ed0 100644
--- a/yarns/splitting.yarn
+++ b/yarns/splitting.yarn
@@ -1,32 +1,85 @@
Artifact splitting tests
========================
+Parsing and validation
+----------------------
+
+To verify that the products fields are parsed correctly, we have a
+scenario that uses all of them, not relying on the default rules.
+
SCENARIO building a system with morphologies that have splitting rules
GIVEN a workspace
AND a git server
+To test that all the fields are recognised, we set the new fields to
+their default values.
+
AND chunk test-chunk includes the default splitting rules
AND stratum test-stratum includes the default splitting rules
AND system test-system includes the default splitting rules
+The default rules produce a system that is identical to not providing
+them, and since this test is about validation, we don't care about the
+result, so much as it succeeding to build something.
+
WHEN the user checks out the system branch called master
THEN morph build the system test-system of the branch master
+Smaller systems
+---------------
+An example use-case for splitting is to only include the runtime
+strata for a target system, rather than including all the development
+information, such as the documentation, C library headers and C static
+libraries.
SCENARIO building a system only using runtime strata
GIVEN a workspace
AND a git server
+
+The only change we need to make is to add a field to the system morphology
+to select which artifact to use in the system.
+
AND system test-system only uses test-stratum-runtime from test-stratum
WHEN the user checks out the system branch called master
+
+The best way to test that only using some stratum artifacts works is
+to check which files the output has, so we deploy a tarball and inspect
+its contents.
+
GIVEN a cluster called test-cluster for deploying only the test-system system as type tar in system branch master
WHEN the user builds the system test-system in branch master
AND the user attempts to deploy the cluster test-cluster in branch master with options system.location="$DATADIR/test.tar"
+
+The -runtime artifacts include executables and shared libraries.
+
THEN tarball test.tar contains bin/test
AND tarball test.tar contains lib/libtest.so
+
+The -devel artifacts include static libraries and documentation, so if
+we've successfully excluded it, we won't have those files.
+
AND tarball test.tar doesn't contain lib/libtest.a
AND tarball test.tar doesn't contain man/man3/test.3.gz
+As a consequence of how dependencies are generated, if we select strata
+to go into our system, such that there are chunk artifacts that are not
+needed, then they don't get built.
+
+ SCENARIO building a system that has unused chunks
+ GIVEN a workspace
+ AND a git server
+
+This GIVEN has a chunk in the stratum that never successfully builds,
+so we know that if the system successfully builds, then we only built
+chunks that were needed.
+
+ AND stratum test-stratum has chunks that aren't used in test-stratum-minimal
+ AND system test-system only uses test-stratum-minimal from test-stratum
+ WHEN the user checks out the system branch called master
+ THEN morph build the system test-system of the branch master
+
+
Implementations
---------------
@@ -127,3 +180,41 @@ Implementations
' "$DATADIR/gits/morphs/$MATCH_1.morph" "$MATCH_2" "$MATCH_3"
run_in "$DATADIR/gits/morphs" git add "$MATCH_1.morph"
run_in "$DATADIR/gits/morphs" git commit -m "Make $MATCH_1 only use $MATCH_2"
+
+ IMPLEMENTS GIVEN stratum (\S+) has chunks that aren't used in (\1-\S+)
+ # Create an extra chunk that will never successfully build
+ cat >"$DATADIR/gits/test-chunk/unbuildable-chunk.morph" <<EOF
+ name: unbuildable-chunk
+ kind: chunk
+ install-commands:
+ - "false"
+ EOF
+ run_in "$DATADIR/gits/test-chunk" git add unbuildable-chunk.morph
+ run_in "$DATADIR/gits/test-chunk" git commit -m 'Add unbuildable chunk'
+
+ # Create a stratum that has an artifact that doesn't include any
+ # artifacts from unbuildable-chunk
+ cat >"$DATADIR/gits/morphs/$MATCH_1.morph" <<EOF
+ name: $MATCH_1
+ kind: stratum
+ products:
+ - artifact: $MATCH_2
+ include:
+ - test-chunk-.*
+ chunks:
+ - name: test-chunk
+ repo: test:test-chunk
+ ref: master
+ morph: test-chunk
+ build-mode: test
+ build-depends: []
+ - name: unbuildable-chunk
+ repo: test:test-chunk
+ ref: refs/heads/master
+ morph: unbuildable-chunk
+ build-mode: test
+ build-depends:
+ - test-chunk
+ EOF
+ run_in "$DATADIR/gits/morphs" git add "$MATCH_1.morph"
+ run_in "$DATADIR/gits/morphs" git commit -m "add -$MATCH_2 to stratum"