This repository has been archived by the owner on Apr 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun-ci.py
68 lines (53 loc) · 1.45 KB
/
run-ci.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
import argparse
import os
import shutil
import sys
import tankerci
GITHUB_URL = "[email protected]:TankerHQ/filekit-tuto-app"
def check():
shutil.copy("src/config.dev.js", "src/config.js")
tankerci.run("yarn")
with tankerci.run_in_background("yarn", "start"):
# fmt: off
tankerci.run(
"poetry", "run", "pytest",
"--verbose",
"--capture=no",
"--headless",
)
# fmt: on
def deploy():
shutil.copy("src/config.prod.js", "src/config.js")
tankerci.run("yarn")
tankerci.run("yarn", "build")
commit_sha = os.environ["CI_COMMIT_SHA"]
message = f"Deploy {commit_sha}"
# Ensure 'github' remote exists
tankerci.run("git", "remote", "remove", "github", check=False)
tankerci.run("git", "remote", "add", "github", GITHUB_URL)
# fmt: off
tankerci.run(
"ghp-import",
"--message", message,
"--remote", "github",
"--push",
"--force",
"--no-jekyll",
"build/",
)
# fmt:on
def main():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(title="subcommands", dest="command")
subparsers.add_parser("check")
subparsers.add_parser("deploy")
args = parser.parse_args()
if args.command == "check":
check()
elif args.command == "deploy":
deploy()
else:
parser.print_help()
sys.exit(1)
if __name__ == "__main__":
main()