-
Notifications
You must be signed in to change notification settings - Fork 0
/
activities.py
79 lines (59 loc) · 2.8 KB
/
activities.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from temporalio import activity
import coloredlogs, logging
from dataclasses import dataclass
from temporalio import workflow
from release_dataclasses import DeployInfo, ReleaseInfo
import release_management
coloredlogs.install()
# todo add more activities here
# such as validate release,
# deploy (child workflow here),
# validate deploy, check security (prints to console), deploy (moves files)
# etc
@activity.defn
async def say_hello(name: str) -> str:
return f"Hello, {name}!"
@activity.defn
async def build(deploy: DeployInfo) -> str:
return release_management.build(deploy)
@activity.defn
async def testInDev(deploy: DeployInfo) -> str:
return release_management.test(deploy, release_management.development)
@activity.defn
async def testInTest(deploy: DeployInfo) -> str:
return release_management.test(deploy, release_management.testing)
@activity.defn
async def testInQC(deploy: DeployInfo) -> str:
return release_management.test(deploy, release_management.qualitycontrol)
@activity.defn
async def testInProd(deploy: DeployInfo) -> str:
return release_management.test(deploy, release_management.production)
@activity.defn
async def deployToDev(deploy: DeployInfo) -> str:
return release_management.deploy(deploy, release_management.development)
@activity.defn
async def deployToTest(deploy: DeployInfo) -> str:
return release_management.deploy(deploy, release_management.testing)
@activity.defn
async def deployToQC(deploy: DeployInfo) -> str:
return release_management.deploy(deploy, release_management.qualitycontrol)
@activity.defn
async def deployToProd(deploy: DeployInfo) -> str:
return release_management.deploy(deploy, release_management.production)
@activity.defn
async def collect_deploys(release_info: ReleaseInfo) -> ReleaseInfo:
""" collect_releases: gather all releases for this deploy
This is mocked for demo purposes but in the future all it needs to do is collect releasable
items from input or from a deployment source, like a database, JSON/YAML file, or API """
logging.info("Collecting Release Info for %s ", release_info.release_key)
release_info = release_management.gather_deployments(release_info)
logging.info("Release Info for %s collected.", release_info.release_key)
return release_info
@activity.defn
async def collect_release_approval(release_info: ReleaseInfo) -> ReleaseInfo:
""" collect_release_approval: gather approval for this deploy
This is mocked for demo purposes but in the future it could await a signal or approval in another system via API """
logging.info("Collecting Approval Info for %s ", release_info.release_key)
release_info = release_management.gather_release_approval(release_info)
logging.info("Release Approval for %s collected.", release_info.release_key)
return release_info