From a5d8b985f1575d5a5d90ba8ed65933e7dff35f7b Mon Sep 17 00:00:00 2001 From: Oliver Giles Date: Fri, 6 Apr 2018 13:43:38 +0300 Subject: [PATCH] laminarc: replace start with run --- README.md | 16 ++++++++-------- src/client.cpp | 11 +++++++---- src/laminar.capnp | 2 +- src/server.cpp | 4 ++-- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 77c9701..77c9f3b 100644 --- a/README.md +++ b/README.md @@ -181,29 +181,29 @@ A typical pipeline may involve several steps, such as build, test and deploy. De The preferred way to accomplish this in Laminar is to use the same method as [regular run triggering](#triggering-a-run), that is, calling `laminarc` directly in your `example.run` scripts. -In addition to `laminarc trigger`, `laminar start` triggers a job run, but waits for its completion and returns a non-zero exit code if the run failed. Furthermore, both `trigger` and `start` will accept multiple jobs in a single invocation: +In addition to `laminarc trigger`, `laminar run` triggers a job run, but waits for its completion and returns a non-zero exit code if the run failed. Furthermore, both `trigger` and `run` will accept multiple jobs in a single invocation: ```bash #!/bin/bash -xe # simultaneously starts example-test-qemu and example-test-target # and returns a non-zero error code if either of them fail -laminarc start example-test-qemu example-test-target +laminarc run example-test-qemu example-test-target ``` An advantage to using this `laminarc` approach from bash or other scripting language is that it enables highly dynamic pipelines, since you can execute commands like ```bash if [ ... ]; then - laminarc start example-downstream-special + laminarc run example-downstream-special else - laminarc start example-downstream-regular + laminarc run example-downstream-regular fi -laminarc start example-test-$TARGET_PLATFORM +laminarc run example-test-$TARGET_PLATFORM ``` -`laminarc` reads the `$JOB` and `$RUN` variables set by `laminard` and passes them as part of the trigger/start request so the dependency chain can always be traced back. +`laminarc` reads the `$JOB` and `$RUN` variables set by `laminard` and passes them as part of the trigger/run request so the dependency chain can always be traced back. ### Parameterized runs @@ -534,14 +534,14 @@ Laminar will also export variables in the form `KEY=VALUE` found in these files: - `nodes/$NODE.env` - `jobs/$JOB.env` -Finally, variables supplied on the command-line call to `laminarc start` or `laminarc trigger` will be available. See [parameterized builds](#parameterized-builds) +Finally, variables supplied on the command-line call to `laminarc run` or `laminarc trigger` will be available. See [parameterized builds](#parameterized-builds) ### `laminarc` `laminarc` commands are: - `trigger [JOB [PARAMS...]]...` triggers one or more jobs with optional parameters, returning immediately. -- `start [JOB [PARAMS...]]...` triggers one or more jobs with optional parameters and waits for the completion of all jobs. Returns a non-zero error code if any job failed. +- `run [JOB [PARAMS...]]...` triggers one or more jobs with optional parameters and waits for the completion of all jobs. Returns a non-zero error code if any job failed. - `set [VARIABLE=VALUE]...` sets one or more variables to be exported in subsequent scripts for the run identified by the `$JOB` and `$RUN` environment variables - `lock [NAME]` acquires the [lock](#locks) named `NAME` - `release [NAME]` releases the lock named `NAME` diff --git a/src/client.cpp b/src/client.cpp index c112b21..e1835c0 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -106,11 +106,14 @@ int main(int argc, char** argv) { return ENOENT; } } - } else if(strcmp(argv[1], "start") == 0) { + } else if(strcmp(argv[1], "run") == 0 || strcmp(argv[1], "start") == 0) { if(argc < 3) { - fprintf(stderr, "Usage %s start \n", argv[0]); + fprintf(stderr, "Usage %s run \n", argv[0]); return EINVAL; } + if(strcmp(argv[1], "start") == 0) { + fprintf(stderr, "Warning: \"start\" is deprecated, please use \"run\" instead\n"); + } struct: public kj::TaskSet::ErrorHandler { void taskFailed(kj::Exception&&) override {} } ignoreFailed; @@ -118,10 +121,10 @@ int main(int argc, char** argv) { int jobNameIndex = 2; // make a request for each job specified on the commandline do { - auto req = laminar.startRequest(); + auto req = laminar.runRequest(); req.setJobName(argv[jobNameIndex]); int n = setParams(argc - jobNameIndex - 1, &argv[jobNameIndex + 1], req); - ts.add(req.send().then([&ret,argv,jobNameIndex](capnp::Response resp){ + ts.add(req.send().then([&ret,argv,jobNameIndex](capnp::Response resp){ printf("%s:%d\n", argv[jobNameIndex], resp.getBuildNum()); if(resp.getResult() != LaminarCi::JobResult::SUCCESS) { ret = EFAILED; diff --git a/src/laminar.capnp b/src/laminar.capnp index 17ae0c1..3b467f2 100644 --- a/src/laminar.capnp +++ b/src/laminar.capnp @@ -3,7 +3,7 @@ interface LaminarCi { trigger @0 (jobName :Text, params :List(JobParam)) -> (result :MethodResult); - start @1 (jobName :Text, params :List(JobParam)) -> (result :JobResult, buildNum :UInt32); + run @1 (jobName :Text, params :List(JobParam)) -> (result :JobResult, buildNum :UInt32); set @2 (jobName :Text, buildNum :UInt32, param :JobParam) -> (result :MethodResult); lock @3 (lockName :Text) -> (); release @4 (lockName :Text) -> (); diff --git a/src/server.cpp b/src/server.cpp index b4ff9f7..878da20 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -105,9 +105,9 @@ public: } // Start a job and wait for the result - kj::Promise start(StartContext context) override { + kj::Promise run(RunContext context) override { std::string jobName = context.getParams().getJobName(); - LLOG(INFO, "RPC start", jobName); + LLOG(INFO, "RPC run", jobName); ParamMap params; for(auto p : context.getParams().getParams()) { params[p.getName().cStr()] = p.getValue().cStr();