--- a/convey.yml Mon Mar 02 17:09:03 2020 -0600
+++ b/convey.yml Mon Mar 02 20:42:15 2020 -0600
@@ -25,39 +25,38 @@
workdir: ${CONVEY_WORKSPACE}
+ workdir: ${CONVEY_WORKSPACE} + command: go build -o convey-${CONVEY_VERSION}-${GOOS}-${GOARCH}${SUFFIX}
- workdir: ${CONVEY_WORKSPACE}
- command: go build -o convey-${CONVEY_VERSION}-${GOOS}-${GOARCH}
- image: golang:1.12-buster
- workdir: ${CONVEY_WORKSPACE}
- command: go build -o convey-${CONVEY_VERSION}-${GOOS}-${GOARCH}.exe
- workdir: ${CONVEY_WORKSPACE}
- command: go build -o convey-${CONVEY_VERSION}-${GOOS}-${GOARCH}
- workdir: ${CONVEY_WORKSPACE}
- command: go build -o convey-${CONVEY_VERSION}-${GOOS}-${GOARCH}
--- a/docker/run.go Mon Mar 02 17:09:03 2020 -0600
+++ b/docker/run.go Mon Mar 02 20:42:15 2020 -0600
@@ -68,6 +68,10 @@
+func (r *Run) ReadEnvironment() []string { + return []string(r.Environment) // writeScript will write a shell script to the given tempfile for the given commands
func (r *Run) writeScript(name string, rt *runtime.Runtime, fullEnv *environment.Environment) (string, string, string, error) {
// create our task directory if it doesn't exist already
--- a/environment/environment.go Mon Mar 02 17:09:03 2020 -0600
+++ b/environment/environment.go Mon Mar 02 20:42:15 2020 -0600
@@ -24,6 +24,10 @@
+type EnvironmentReader interface { + ReadEnvironment() []string type Environment struct {
--- a/loaders/convey/tasks.go Mon Mar 02 17:09:03 2020 -0600
+++ b/loaders/convey/tasks.go Mon Mar 02 20:42:15 2020 -0600
@@ -65,7 +65,7 @@
- return nil, fmt.Errorf("task '%s' not found", rawType)
+ return nil, fmt.Errorf("task type %q not found", rawType) @@ -94,5 +94,16 @@
realTasks[name] = realTask
+ // now resolve any subtasks + for name, task := range realTasks { + if subtask, ok := task.(*tasks.SubTask); ok { + if parent, found := realTasks[subtask.Base]; found { + subtask.Parent = parent + return nil, fmt.Errorf("failed to find parent task %q for task %q", subtask.Base, name) --- a/tasks/README.md Mon Mar 02 17:09:03 2020 -0600
+++ b/tasks/README.md Mon Mar 02 20:42:15 2020 -0600
@@ -55,3 +55,37 @@
+A subtask lets reuse existing tasks by setting the environment. +As of right now, a subtask can **NOT** override an environment variable in it's +parent task, but you can mimic that but having all subtasks setting the +| Name | Required | Default | Description | +| -------- | -------- | ------- | ----------- | +| base | Yes | | The name of the parent task | + command: go build -o foo-${GOOS}-${GOARCH} --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tasks/subtask.go Mon Mar 02 20:42:15 2020 -0600
@@ -0,0 +1,58 @@
+// Copyright 2016-2020 Gary Kramlich <grim@reaperworld.com> +// 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 +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. + log "github.com/sirupsen/logrus" + "hg.sr.ht/~grim/convey/environment" + "hg.sr.ht/~grim/convey/runtime" + "hg.sr.ht/~grim/convey/yaml" + Base string `yaml:"base"` + Environment yaml.StringOrSlice `yaml:"environment"` +func (t *SubTask) New() Task { +func (t *SubTask) Valid() error { + return fmt.Errorf("no base task specified") +func (t *SubTask) Execute(name string, logger *log.Entry, env *environment.Environment, rt *runtime.Runtime) error { + _ = t.Parent.(environment.EnvironmentReader) + if e, ok := t.Parent.(environment.EnvironmentReader); ok { + fullEnv.MergeSlice(e.ReadEnvironment()) + fullEnv.MergeSlice(t.Environment).Merge(rt.Environment) + return t.Parent.Execute(name, logger, fullEnv, rt) --- a/tasks/tasks.go Mon Mar 02 17:09:03 2020 -0600
+++ b/tasks/tasks.go Mon Mar 02 20:42:15 2020 -0600
@@ -27,11 +27,12 @@
// Tasks is the list of tasks defined in this package.