-
Notifications
You must be signed in to change notification settings - Fork 6
/
test_workflow.py
executable file
·45 lines (32 loc) · 994 Bytes
/
test_workflow.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
#!/bin/env python3
"""
This scripts executes the test workflow locally.
"""
import subprocess
import yaml
skip_steps = "install", "coveralls"
def load_workflow():
with open(".github/workflows/test.yaml") as f:
return yaml.safe_load(f)
def iter_steps(workflow: dict, job="test"):
steps = workflow["jobs"][job]["steps"]
for step in steps:
step_run = step.get("run", None)
if step_run is None:
continue
step_name = step.get("name", "")
if any(skip_name in step_name.lower() for skip_name in skip_steps):
continue
yield step_name, step_run
def run_job(workflow: dict, job="test"):
for name, run in iter_steps(workflow, job):
print(name)
ret = subprocess.run(run, shell=True)
if ret.returncode != 0:
exit(ret.returncode)
def main():
workflow = load_workflow()
run_job(workflow, "lint")
run_job(workflow, "test")
if __name__ == "__main__":
main()