Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support executing multiple targets #47

Closed
hinshun opened this issue Mar 24, 2020 · 0 comments · Fixed by #98
Closed

Support executing multiple targets #47

hinshun opened this issue Mar 24, 2020 · 0 comments · Fixed by #98
Labels
design Design for a feature

Comments

@hinshun
Copy link
Contributor

hinshun commented Mar 24, 2020

There's a few use cases for executing multiple targets:

  1. Executing some targets in parallel, some sequentially.
  2. Specifying different outputs for each target

Proposal

HLB CLI

You'll be able to specify multiple targets like:

  • hlb run --target foo --target bar

Or specify a target which is a group, more on that below.

New type group

Currently, the only available targets are functions that return fs. One common ask to run multiple targets in parallel, and multiple targets sequentially, so for that we propose a new type group which provides that functionality.

All fs can be thought of as a single element group, but group cannot be passed as a fs.

group default() {
    foo
    bar
}

fs foo() {
    # ...
}

fs bar() {
    # ...
}

Like fs, the statements are sequential so foo will execute and complete before we start building the graph for bar.

We also define a group function to execute groups in parallel:

# Runs the given targets in parallel.
#
# @param targets the targets to run in parallel.
# @return a group for parallel execution.
group parallel(variadic group targets)

Using function literals, you can define the build pipeline all in one group:

group foo() {
  parallel group {
    a
    b
  } group {
    c
    d
  }
  e
}

When executing target foo, a and c will start immediately. b will start when a finishes, d will start when c finishes, and e will start when both a, b, c, d have finished.

Since groups are also functions, you can define parameters, like in this concrete example:

group pullrequest() {
	unitTests
	lint
}

group ci() {
	parallel group {
		pullrequest
	} group {
		parallel group {
			integrationTests "staging"
		} group {
			integrationTests "prod"
		}
		publish
	}
}

group integrationTests(string environment) {
	# ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Design for a feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant