mirror of
https://github.com/ohwgiles/laminar.git
synced 2024-10-27 20:34:20 +00:00
resolves #33: laminar start output should reference run number
This commit is contained in:
parent
68d08f369b
commit
4d2388c271
@ -111,22 +111,25 @@ int main(int argc, char** argv) {
|
|||||||
fprintf(stderr, "Usage %s start <jobName>\n", argv[0]);
|
fprintf(stderr, "Usage %s start <jobName>\n", argv[0]);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
kj::Vector<capnp::RemotePromise<LaminarCi::StartResults>> promises;
|
struct: public kj::TaskSet::ErrorHandler {
|
||||||
|
void taskFailed(kj::Exception&&) override {}
|
||||||
|
} ignoreFailed;
|
||||||
|
kj::TaskSet ts(ignoreFailed);
|
||||||
int jobNameIndex = 2;
|
int jobNameIndex = 2;
|
||||||
// make a request for each job specified on the commandline
|
// make a request for each job specified on the commandline
|
||||||
do {
|
do {
|
||||||
auto req = laminar.startRequest();
|
auto req = laminar.startRequest();
|
||||||
req.setJobName(argv[jobNameIndex]);
|
req.setJobName(argv[jobNameIndex]);
|
||||||
int n = setParams(argc - jobNameIndex - 1, &argv[jobNameIndex + 1], req);
|
int n = setParams(argc - jobNameIndex - 1, &argv[jobNameIndex + 1], req);
|
||||||
promises.add(req.send());
|
ts.add(req.send().then([&ret,argv,jobNameIndex](capnp::Response<LaminarCi::StartResults> resp){
|
||||||
jobNameIndex += n + 1;
|
printf("%s:%d\n", argv[jobNameIndex], resp.getBuildNum());
|
||||||
} while(jobNameIndex < argc);
|
if(resp.getResult() != LaminarCi::JobResult::SUCCESS) {
|
||||||
// pend on the promises
|
|
||||||
for(auto& p : promises) {
|
|
||||||
if(p.wait(waitScope).getResult() != LaminarCi::JobResult::SUCCESS) {
|
|
||||||
ret = EFAILED;
|
ret = EFAILED;
|
||||||
}
|
}
|
||||||
}
|
}));
|
||||||
|
jobNameIndex += n + 1;
|
||||||
|
} while(jobNameIndex < argc);
|
||||||
|
ts.onEmpty().wait(waitScope);
|
||||||
} else if(strcmp(argv[1], "set") == 0) {
|
} else if(strcmp(argv[1], "set") == 0) {
|
||||||
if(argc < 3) {
|
if(argc < 3) {
|
||||||
fprintf(stderr, "Usage %s set param=value\n", argv[0]);
|
fprintf(stderr, "Usage %s set param=value\n", argv[0]);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
interface LaminarCi {
|
interface LaminarCi {
|
||||||
|
|
||||||
trigger @0 (jobName :Text, params :List(JobParam)) -> (result :MethodResult);
|
trigger @0 (jobName :Text, params :List(JobParam)) -> (result :MethodResult);
|
||||||
start @1 (jobName :Text, params :List(JobParam)) -> (result :JobResult);
|
start @1 (jobName :Text, params :List(JobParam)) -> (result :JobResult, buildNum :UInt32);
|
||||||
set @2 (jobName :Text, buildNum :UInt32, param :JobParam) -> (result :MethodResult);
|
set @2 (jobName :Text, buildNum :UInt32, param :JobParam) -> (result :MethodResult);
|
||||||
lock @3 (lockName :Text) -> ();
|
lock @3 (lockName :Text) -> ();
|
||||||
release @4 (lockName :Text) -> ();
|
release @4 (lockName :Text) -> ();
|
||||||
|
@ -114,9 +114,11 @@ public:
|
|||||||
}
|
}
|
||||||
std::shared_ptr<Run> run = laminar.queueJob(jobName, params);
|
std::shared_ptr<Run> run = laminar.queueJob(jobName, params);
|
||||||
if(const Run* r = run.get()) {
|
if(const Run* r = run.get()) {
|
||||||
|
uint num = r->build;
|
||||||
runWaiters[r].emplace_back(kj::newPromiseAndFulfiller<RunState>());
|
runWaiters[r].emplace_back(kj::newPromiseAndFulfiller<RunState>());
|
||||||
return runWaiters[r].back().promise.then([context](RunState state) mutable {
|
return runWaiters[r].back().promise.then([context,num](RunState state) mutable {
|
||||||
context.getResults().setResult(fromRunState(state));
|
context.getResults().setResult(fromRunState(state));
|
||||||
|
context.getResults().setBuildNum(num);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
context.getResults().setResult(LaminarCi::JobResult::UNKNOWN);
|
context.getResults().setResult(LaminarCi::JobResult::UNKNOWN);
|
||||||
|
Loading…
Reference in New Issue
Block a user