mirror of
				https://github.com/ohwgiles/laminar.git
				synced 2025-06-13 12:54:29 +00:00 
			
		
		
		
	laminarc: replace start with run
This commit is contained in:
		
							parent
							
								
									4d2388c271
								
							
						
					
					
						commit
						a5d8b985f1
					
				
							
								
								
									
										16
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								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.
 | 
					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
 | 
					```bash
 | 
				
			||||||
#!/bin/bash -xe
 | 
					#!/bin/bash -xe
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# simultaneously starts example-test-qemu and example-test-target
 | 
					# simultaneously starts example-test-qemu and example-test-target
 | 
				
			||||||
# and returns a non-zero error code if either of them fail
 | 
					# 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
 | 
					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
 | 
					```bash
 | 
				
			||||||
if [ ... ]; then
 | 
					if [ ... ]; then
 | 
				
			||||||
  laminarc start example-downstream-special
 | 
					  laminarc run example-downstream-special
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
  laminarc start example-downstream-regular
 | 
					  laminarc run example-downstream-regular
 | 
				
			||||||
fi
 | 
					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
 | 
					### Parameterized runs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -534,14 +534,14 @@ Laminar will also export variables in the form `KEY=VALUE` found in these files:
 | 
				
			|||||||
- `nodes/$NODE.env`
 | 
					- `nodes/$NODE.env`
 | 
				
			||||||
- `jobs/$JOB.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`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
`laminarc` commands are:
 | 
					`laminarc` commands are:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- `trigger [JOB [PARAMS...]]...` triggers one or more jobs with optional parameters, returning immediately.
 | 
					- `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
 | 
					- `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`
 | 
					- `lock [NAME]` acquires the [lock](#locks) named `NAME`
 | 
				
			||||||
- `release [NAME]` releases the lock named `NAME`
 | 
					- `release [NAME]` releases the lock named `NAME`
 | 
				
			||||||
 | 
				
			|||||||
@ -106,11 +106,14 @@ int main(int argc, char** argv) {
 | 
				
			|||||||
                return ENOENT;
 | 
					                return ENOENT;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else if(strcmp(argv[1], "start") == 0) {
 | 
					    } else if(strcmp(argv[1], "run") == 0 || strcmp(argv[1], "start") == 0) {
 | 
				
			||||||
        if(argc < 3) {
 | 
					        if(argc < 3) {
 | 
				
			||||||
            fprintf(stderr, "Usage %s start <jobName>\n", argv[0]);
 | 
					            fprintf(stderr, "Usage %s run <jobName>\n", argv[0]);
 | 
				
			||||||
            return EINVAL;
 | 
					            return EINVAL;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if(strcmp(argv[1], "start") == 0) {
 | 
				
			||||||
 | 
					            fprintf(stderr, "Warning: \"start\" is deprecated, please use \"run\" instead\n");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        struct: public kj::TaskSet::ErrorHandler {
 | 
					        struct: public kj::TaskSet::ErrorHandler {
 | 
				
			||||||
            void taskFailed(kj::Exception&&) override {}
 | 
					            void taskFailed(kj::Exception&&) override {}
 | 
				
			||||||
        } ignoreFailed;
 | 
					        } ignoreFailed;
 | 
				
			||||||
@ -118,10 +121,10 @@ int main(int argc, char** argv) {
 | 
				
			|||||||
        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.runRequest();
 | 
				
			||||||
            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);
 | 
				
			||||||
            ts.add(req.send().then([&ret,argv,jobNameIndex](capnp::Response<LaminarCi::StartResults> resp){
 | 
					            ts.add(req.send().then([&ret,argv,jobNameIndex](capnp::Response<LaminarCi::RunResults> resp){
 | 
				
			||||||
                printf("%s:%d\n", argv[jobNameIndex], resp.getBuildNum());
 | 
					                printf("%s:%d\n", argv[jobNameIndex], resp.getBuildNum());
 | 
				
			||||||
                if(resp.getResult() != LaminarCi::JobResult::SUCCESS) {
 | 
					                if(resp.getResult() != LaminarCi::JobResult::SUCCESS) {
 | 
				
			||||||
                    ret = EFAILED;
 | 
					                    ret = EFAILED;
 | 
				
			||||||
 | 
				
			|||||||
@ -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, buildNum :UInt32);
 | 
					    run @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) -> ();
 | 
				
			||||||
 | 
				
			|||||||
@ -105,9 +105,9 @@ public:
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Start a job and wait for the result
 | 
					    // Start a job and wait for the result
 | 
				
			||||||
    kj::Promise<void> start(StartContext context) override {
 | 
					    kj::Promise<void> run(RunContext context) override {
 | 
				
			||||||
        std::string jobName = context.getParams().getJobName();
 | 
					        std::string jobName = context.getParams().getJobName();
 | 
				
			||||||
        LLOG(INFO, "RPC start", jobName);
 | 
					        LLOG(INFO, "RPC run", jobName);
 | 
				
			||||||
        ParamMap params;
 | 
					        ParamMap params;
 | 
				
			||||||
        for(auto p : context.getParams().getParams()) {
 | 
					        for(auto p : context.getParams().getParams()) {
 | 
				
			||||||
            params[p.getName().cStr()] = p.getValue().cStr();
 | 
					            params[p.getName().cStr()] = p.getValue().cStr();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user