mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge branch 'deploy-script'
This commit is contained in:
commit
d96b8cedc5
11
.travis.yml
Normal file
11
.travis.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
language: python
|
||||||
|
python:
|
||||||
|
- "3.4"
|
||||||
|
before_script:
|
||||||
|
- pip install pygithub
|
||||||
|
- pip install pygithub3
|
||||||
|
script:
|
||||||
|
- python3 tools/deploy.py
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
- secure: "KcJQbknBOdC5lA4nFGKPXVRVIGLDXDRzC8XkHuXJCE9pIR/wbxbkvx8fHKcC6SC9eHgzneC3+o4m4+CjIbVvIwDgslRbJ8Y59i90ncONmdoRx1HUYHwuYWVZm9HJFjCsIbrEqhSyyKS+PB3WZVOLbErtNHsgS8f43PTh5Ujg7Vg="
|
101
tools/deploy.py
Executable file
101
tools/deploy.py
Executable file
@ -0,0 +1,101 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
####################################
|
||||||
|
# ACE3 automatic deployment script #
|
||||||
|
# ================================ #
|
||||||
|
# This is not meant to be run #
|
||||||
|
# directly! #
|
||||||
|
####################################
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import shutil
|
||||||
|
import traceback
|
||||||
|
import subprocess as sp
|
||||||
|
from pygithub3 import Github
|
||||||
|
|
||||||
|
|
||||||
|
TRANSLATIONISSUE = 367
|
||||||
|
TRANSLATIONBODY = """**How to translate ACE3:**
|
||||||
|
https://github.com/acemod/ACE3/blob/master/documentation/development/how-to-translate-ace3.md
|
||||||
|
|
||||||
|
{}
|
||||||
|
"""
|
||||||
|
|
||||||
|
REPOUSER = "acemod"
|
||||||
|
REPONAME = "ACE3"
|
||||||
|
REPOPATH = "{}/{}".format(REPOUSER,REPONAME)
|
||||||
|
|
||||||
|
USERNAME = "ACE3 Travis"
|
||||||
|
USEREMAIL = "travis@ace3mod.com"
|
||||||
|
|
||||||
|
|
||||||
|
def update_translations(token):
|
||||||
|
diag = sp.check_output(["python3", "tools/stringtablediag.py", "--markdown"])
|
||||||
|
diag = str(diag, "utf-8")
|
||||||
|
repo = Github(token).get_repo(REPOPATH)
|
||||||
|
issue = repo.get_issue(TRANSLATIONISSUE)
|
||||||
|
issue.edit(body=TRANSLATIONBODY.format(diag))
|
||||||
|
|
||||||
|
|
||||||
|
def deploy_documentation(token):
|
||||||
|
devnull = open(os.devnull, "w")
|
||||||
|
url = "https://{}@github.com/{}".format(token, REPOPATH)
|
||||||
|
|
||||||
|
sp.check_call(["git", "clone", url, "out", "--depth", "10", "--branch", "gh-pages"], stdout=devnull, stderr=devnull)
|
||||||
|
os.chdir("out")
|
||||||
|
|
||||||
|
sp.check_call(["git", "config", "user.name", USERNAME])
|
||||||
|
sp.check_call(["git", "config", "user.email", USEREMAIL])
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk("../documentation", topdown=False):
|
||||||
|
target = root.replace("../documentation", "wiki")
|
||||||
|
if root == "../documentation":
|
||||||
|
continue
|
||||||
|
for name in files:
|
||||||
|
print("{} => {}".format(os.path.join(root, name), os.path.join(target, name)))
|
||||||
|
shutil.copyfile(os.path.join(root, name), os.path.join(target, name))
|
||||||
|
|
||||||
|
sp.check_call(["git", "add", "--all", "."])
|
||||||
|
sp.check_call(["git", "commit", "-m", "Automatic gh-pages deployment"])
|
||||||
|
sp.check_call(["git", "push", "origin", "gh-pages"], stdout=devnull, stderr=devnull)
|
||||||
|
|
||||||
|
os.chdir("..")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("Obtaining token ...")
|
||||||
|
try:
|
||||||
|
token = os.environ["GH_TOKEN"]
|
||||||
|
except:
|
||||||
|
print("Could not obtain token.")
|
||||||
|
print(traceback.format_exc())
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
print("done.")
|
||||||
|
|
||||||
|
print("\nUpdating translation issue ...")
|
||||||
|
try:
|
||||||
|
update_translations(token)
|
||||||
|
except:
|
||||||
|
print("Failed to update translation issue.")
|
||||||
|
print(traceback.format_exc())
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
print("done.")
|
||||||
|
|
||||||
|
print("\nDeploying documentation ...")
|
||||||
|
try:
|
||||||
|
deploy_documentation(token)
|
||||||
|
except:
|
||||||
|
print("Failed to deploy documentation.")
|
||||||
|
print(traceback.format_exc())
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
print("done.")
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
@ -57,12 +57,14 @@ def main():
|
|||||||
projectpath = os.path.dirname(os.path.dirname(scriptpath))
|
projectpath = os.path.dirname(os.path.dirname(scriptpath))
|
||||||
projectpath = os.path.join(projectpath, "addons")
|
projectpath = os.path.join(projectpath, "addons")
|
||||||
|
|
||||||
|
if "--markdown" not in sys.argv:
|
||||||
print("#########################")
|
print("#########################")
|
||||||
print("# Stringtable Diag Tool #")
|
print("# Stringtable Diag Tool #")
|
||||||
print("#########################")
|
print("#########################")
|
||||||
|
|
||||||
languages = get_all_languages(projectpath)
|
languages = get_all_languages(projectpath)
|
||||||
|
|
||||||
|
if "--markdown" not in sys.argv:
|
||||||
print("\nLanguages present in the repo:")
|
print("\nLanguages present in the repo:")
|
||||||
print(", ".join(languages))
|
print(", ".join(languages))
|
||||||
|
|
||||||
@ -76,19 +78,21 @@ def main():
|
|||||||
if keynumber == 0:
|
if keynumber == 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if "--markdown" not in sys.argv:
|
||||||
print("\n# " + module)
|
print("\n# " + module)
|
||||||
|
|
||||||
keysum += keynumber
|
keysum += keynumber
|
||||||
for i in range(len(localized)):
|
for i in range(len(localized)):
|
||||||
|
if "--markdown" not in sys.argv:
|
||||||
print(" %s %s / %i" % ((languages[i]+":").ljust(10), str(localized[i]).ljust(3), keynumber))
|
print(" %s %s / %i" % ((languages[i]+":").ljust(10), str(localized[i]).ljust(3), keynumber))
|
||||||
localizedsum[i] += localized[i]
|
localizedsum[i] += localized[i]
|
||||||
if localized[i] < keynumber:
|
if localized[i] < keynumber:
|
||||||
missing[i].append(module)
|
missing[i].append(module)
|
||||||
|
|
||||||
|
if "--markdown" not in sys.argv:
|
||||||
print("\n###########")
|
print("\n###########")
|
||||||
print("# RESULTS #")
|
print("# RESULTS #")
|
||||||
print("###########")
|
print("###########")
|
||||||
|
|
||||||
print("\nTotal number of keys: %i\n" % (keysum))
|
print("\nTotal number of keys: %i\n" % (keysum))
|
||||||
|
|
||||||
for i in range(len(languages)):
|
for i in range(len(languages)):
|
||||||
@ -98,9 +102,9 @@ def main():
|
|||||||
print("%s %s missing stringtable entry/entries." % ((languages[i] + ":").ljust(12), str(keysum - localizedsum[i]).rjust(4)), end="")
|
print("%s %s missing stringtable entry/entries." % ((languages[i] + ":").ljust(12), str(keysum - localizedsum[i]).rjust(4)), end="")
|
||||||
print(" ("+", ".join(missing[i])+")")
|
print(" ("+", ".join(missing[i])+")")
|
||||||
|
|
||||||
print("\n\n### MARKDOWN ###")
|
print("\n\n### MARKDOWN ###\n")
|
||||||
|
|
||||||
print("\nTotal number of keys: %i\n" % (keysum))
|
print("Total number of keys: %i\n" % (keysum))
|
||||||
|
|
||||||
print("| Language | Missing Entries | Relevant Modules | % done |")
|
print("| Language | Missing Entries | Relevant Modules | % done |")
|
||||||
print("|----------|----------------:|------------------|--------|")
|
print("|----------|----------------:|------------------|--------|")
|
||||||
|
Loading…
Reference in New Issue
Block a user