-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proof of concept of syntax sugar (#47)
* Proof of concept of syntax sugar * Update pkg/larker/larker_test.go Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com> * newlines * commented why we need floats * Fixed starlark.Int convertion Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
- Loading branch information
Showing
9 changed files
with
126 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ def main(ctx): | |
"image": "debian:latest", | ||
}, | ||
"script": [ | ||
"true", | ||
"printenv", | ||
], | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
task: | ||
container: | ||
image: debian:latest | ||
script: | ||
- printenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
load("core.star", "task", "container", "script", "always", "artifacts") | ||
|
||
def main(ctx): | ||
return [ | ||
task( | ||
name="Lint", | ||
instance=container("golangci/golangci-lint:latest", cpu=1.0, memory=512), | ||
env={ | ||
"STARLARK": True | ||
}, | ||
instructions=[ | ||
script("lint", "echo $STARLARK", "golangci-lint run -v --out-format json > golangci.json"), | ||
always( | ||
artifacts("report", "golangci.json", type="text/json", format="golangci") | ||
) | ||
] | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
def task(name, instance, env={}, instructions=[]): | ||
result = { | ||
'name': name, | ||
'env': env, | ||
} | ||
result.update(instance.items()) | ||
for instruction in instructions: | ||
result.update(instruction.items()) | ||
return result | ||
|
||
|
||
def script(name, *lines): | ||
return { | ||
name + '_script': lines | ||
} | ||
|
||
|
||
def artifacts(name, path, type="", format=""): | ||
result = { | ||
'path': path, | ||
} | ||
if type != "": | ||
result['type'] = type | ||
if format != "": | ||
result['format'] = format | ||
return { | ||
name + '_artifacts': result | ||
} | ||
|
||
|
||
def container(image="", dockerfile="", cpu=2.0, memory=4096): | ||
result = dict() | ||
if image != "": | ||
result['image'] = image | ||
if dockerfile != "": | ||
result['dockerfile'] = dockerfile | ||
result['cpu'] = cpu | ||
result['memory'] = memory | ||
return { | ||
'container': result | ||
} | ||
|
||
|
||
def always(instruction): | ||
return {'always': instruction} | ||
|
||
|
||
def on_failure(instruction): | ||
return {'on_failure': instruction} | ||
|
||
|
||
def on_sucess(instruction): | ||
return {'on_sucess': instruction} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
task: | ||
name: Lint | ||
env: | ||
STARLARK: true | ||
container: | ||
image: golangci/golangci-lint:latest | ||
cpu: 1 | ||
memory: 512 | ||
lint_script: | ||
- echo $STARLARK | ||
- golangci-lint run -v --out-format json > golangci.json | ||
always: | ||
report_artifacts: | ||
path: golangci.json | ||
type: text/json | ||
format: golangci |