Clean up the cache use syntax to avoid the confusing re-use of "from"

In the context of the cache {} block, we don't want to use `from` to copy the
cache directives from another stage entirely, rather we want to "use" the named
cached entry.

I think it makes sense to allow caches to be pulled individually. Imagining a
case where a compilation stage might create multiple platform specific
directories or binaries. In such cases, a Windows test-specific stage would only
want to grab the cached entries for Windows, etc.
This commit is contained in:
R Tyler Croy 2019-07-05 18:39:09 -07:00
parent 34359b5d4f
commit 0f66174874
No known key found for this signature in database
GPG Key ID: E5C92681BEF6CEA2
4 changed files with 28 additions and 3 deletions

View File

@ -145,9 +145,18 @@ cache
(
(setting+)
| fromExpr
| cacheUseExpr
)
END
;
/*
* cache {} `use` expressions allow stages to pull in cached entries from
* elsewhere
*/
cacheUseExpr
: USE ID
;
runtime
: RUNTIME BEGIN
(

View File

@ -5,7 +5,7 @@
use {
stdlib;
stdlib
}
blueprint {

View File

@ -70,7 +70,7 @@ pipeline {
}
cache {
from 'gems'
use gems
}
steps {

View File

@ -19,7 +19,6 @@ pipeline are as follows:
* The path of execution must be numbered and trackable within the system. Other
components will need to be able to refer back to the internal representation to
determine where in the execution of the pipeline the process is currently.
* Configuration data must be
=== Example
@ -48,6 +47,10 @@ pipeline {
}
}
cache {
gems = ['vendor/']
}
steps {
sh 'ruby --version'
}
@ -57,6 +60,9 @@ pipeline {
runtime {
from 'Build'
}
cache {
use gems
}
steps {
sh 'env'
}
@ -102,6 +108,13 @@ stages:
- type: 'sh'
args:
- 'ruby --version'
# `capture` and `restore` both would support archiving of artifacts and
# caching of files and directories between the different stages
capture:
gems:
- path: 'gems/'
type: 'directory'
restore:
- name: 'Test'
before:
# Reference the stage by index
@ -111,5 +124,8 @@ stages:
- type: 'sh'
args:
- 'env'
capture:
restore:
- gems
----