Skip to content

Instantly share code, notes, and snippets.

@terabyte
Created December 8, 2017 23:52
Show Gist options
  • Save terabyte/846b91842470341b4c28a83937266b32 to your computer and use it in GitHub Desktop.
Save terabyte/846b91842470341b4c28a83937266b32 to your computer and use it in GitHub Desktop.
import com.google.common.collect.ImmutableList;
import java.nio.file.Paths;
import org.apache.commons.lang3.tuple.Pair;
import qbt.artifactcacher.CompoundArtifactCacher;
import qbt.artifactcacher.LocalArtifactCacher;
import qbt.config.CompoundQbtRemoteFinder;
import qbt.config.FormatLocalRepoFinder;
import qbt.config.FormatQbtRemoteFinder;
import qbt.config.MapQbtRemoteFinder;
import qbt.config.PatternMultiplexingLocalRepoFinder;
import qbt.config.QbtConfig;
import qbt.pins.SimpleLocalPinsRepo;
import qbt.remote.FormatQbtRemote;
import qbt.remote.GithubQbtRemote;
import qbt.vcs.VcsRegistry;
def dotQbt = Paths.get(System.getenv("HOME")).resolve(".qbt");
def gitRemoteVcs = VcsRegistry.getRawRemoteVcs("git");
def gitLocalVcs = gitRemoteVcs.getLocalVcs();
return new QbtConfig(
// First config argument -- where are my overrides? My simple choice is
// "next to meta". LocalRepoFinder is an interface and it's entirely
// plausible to implement it in other ways, possibly even in qbt-config
// itself.
new PatternMultiplexingLocalRepoFinder(
[
Pair.of("inlined", new FormatLocalRepoFinder(gitLocalVcs, workspaceRoot.toString())),
Pair.of(".*", new FormatLocalRepoFinder(
gitLocalVcs,
workspaceRoot.resolve(System.getenv("NO_OVERRIDES") ? "/dev/null" : "../%r").toString(),
)),
]
),
// Second config argument -- where are my local pins? local pins are commits in
// package repositories that are pointed to by the manifest. If you push the
// repository that the manifest file lives in to other people, they can't use it
// unless they can also get all the commits listed in that manifest, so pins are
// how QBT accomplishes this.
//
// I put them in my home directory so they're shared between workspaces. Since
// this is an immutable, append-only store sharing mostly makes sense. I notice
// this is slightly inconsistent specification-wise: most of the rest are
// formats and this one is root directory that it makes subdirs of. Should
// probably go back and change this to format.
new SimpleLocalPinsRepo(
gitRemoteVcs,
dotQbt.resolve("pins/v1"),
),
// Third config argument -- where are my remotes? This is just a
// programmatic mapping from mere string to full-on QbtRemote platform
// object.
//
// The first half specifies two fixed ones by name. "origin" is my QBT
// universe on GitHub and "amling" is keith amling's universe.
// This means anywhere that takes a remote can be given "origin" or "amling"
// and it will pick these guys.
//
// The second half will always hit and treats the string as a format
// string. This means I could pass those above format string in place of
// their short names and get the same effect, just like how you can "git fetch"
// a git url or a remote name.
new CompoundQbtRemoteFinder([
new MapQbtRemoteFinder([
cmyers: new FormatQbtRemote(
gitRemoteVcs,
"[email protected]:TerabyteQbt/%r.git"
),
/*
amling: new FormatQbtRemote(
gitRemoteVcs,
"[email protected]:AmlingQbt/%r.git"
),
example: new GithubQbtRemote(
gitRemoteVcs,
github_api_token,
"username_or_organization",
"optional-repo-pattern-with-%r",
),
origin: new FormatQbtRemote(
gitRemoteVcs,
"ssh://[email protected]/TerabyteQbt/%r.git",
),
amling: new FormatQbtRemote(
gitRemoteVcs,
"ssh://[email protected]/AmlingQbt/%r.git",
),
githubuser: new GithubQbtRemote(
gitRemoteVcs,
test_token,
"theterabyteautomated",
),
*/
]),
new FormatQbtRemoteFinder(
gitRemoteVcs,
),
]),
// Finally, artifact caching locations and the size of the local cache. You can
// probably use this unmodified.
new CompoundArtifactCacher(
System.getenv("NO_CACHE") ? ImmutableList.of() :
ImmutableList.of(
new LocalArtifactCacher(
dotQbt.resolve("artifacts/v1"),
25L * (1024 * 1024 * 1024)
),
),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment