-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
54 lines (39 loc) · 1.61 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from pathlib import Path
from minimalci.executors import LocalContainer, Local, Stash
from minimalci.tasks import Task, Status
from minimalci import task_util
image_name: str
source: Stash
class Setup(Task):
def run(self) -> None:
# github_auth = Path("/secrets/github_auth.txt").read_text().strip()
with Local() as exe:
exe.sh(f"echo secretstuff", censor=["secretstuff"])
global source, image_name
source = exe.stash_from_git_archive(self.state.commit)
image_name = f"minimalci:{self.state.commit}"
exe.sh(f"docker build . -t {image_name}")
class Test(Task):
run_after = [Setup]
def run(self) -> None:
with LocalContainer(image_name, temp_path=True, mount_docker=True) as exe:
exe.unstash(source)
exe.sh("make test")
class Lint(Task):
run_after = [Setup]
def run(self) -> None:
with LocalContainer(image_name, temp_path=True) as exe:
exe.unstash(source)
exe.sh("make check")
class ErrorHandler(Task):
run_after = [Test, Lint]
run_always = True
def run(self) -> None:
if all(task.status in [Status.success, Status.skipped] for task in self.state.tasks if task is not self):
if self.state.identifier: # If running on CI server
print("Set github status", task_util.GithubState.success.name)
print("GREAT SUCCESS")
else:
if self.state.identifier: # If running on CI server
print("Set github status", task_util.GithubState.failure.name)
print("SOMETHING FAILED")