mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Run documentation dependencies extractor on Travis deployment
This commit is contained in:
parent
d1d23c55bc
commit
2182b2c742
@ -18,7 +18,7 @@ script:
|
|||||||
fi
|
fi
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- secure: KcJQbknBOdC5lA4nFGKPXVRVIGLDXDRzC8XkHuXJCE9pIR/wbxbkvx8fHKcC6SC9eHgzneC3+o4m4+CjIbVvIwDgslRbJ8Y59i90ncONmdoRx1HUYHwuYWVZm9HJFjCsIbrEqhSyyKS+PB3WZVOLbErtNHsgS8f43PTh5Ujg7Vg=
|
- secure: cdxkn5cAx+s1C9Ne5m+odEhde1uuSg6XGMDgepN4DwSAJwtMnUv3ZmDebd5YJC1raZJdep+n09Cj0GoTNICQRkco50DxHKHYNad41wetY0tn0cs9gmPYzyFE5q4vuWiQ47dlGhQQ7IJDyX0nU++gG5E50/PhlZfebdedGSprN/4=
|
||||||
notifications:
|
notifications:
|
||||||
slack:
|
slack:
|
||||||
rooms:
|
rooms:
|
||||||
|
@ -12,7 +12,7 @@ import sys
|
|||||||
import shutil
|
import shutil
|
||||||
import traceback
|
import traceback
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
from pygithub3 import Github
|
from github import Github, InputGitAuthor
|
||||||
|
|
||||||
|
|
||||||
TRANSLATIONISSUE = 367
|
TRANSLATIONISSUE = 367
|
||||||
@ -21,39 +21,69 @@ TRANSLATIONBODY = """**[ACE3 Translation Guide](http://ace3mod.com/wiki/developm
|
|||||||
{}
|
{}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
DEPENDENCIESPATH = "docs/_includes/dependencies_list.md"
|
||||||
|
|
||||||
REPOUSER = "acemod"
|
REPOUSER = "acemod"
|
||||||
REPONAME = "ACE3"
|
REPONAME = "ACE3"
|
||||||
REPOPATH = "{}/{}".format(REPOUSER,REPONAME)
|
REPOPATH = "{}/{}".format(REPOUSER,REPONAME)
|
||||||
|
|
||||||
|
|
||||||
def update_translations(token):
|
def update_translations(repo):
|
||||||
diag = sp.check_output(["python3", "tools/stringtablediag.py", "--markdown"])
|
diag = sp.check_output(["python3", "tools/stringtablediag.py", "--markdown"])
|
||||||
diag = str(diag, "utf-8")
|
diag = str(diag, "utf-8")
|
||||||
repo = Github(token).get_repo(REPOPATH)
|
|
||||||
issue = repo.get_issue(TRANSLATIONISSUE)
|
issue = repo.get_issue(TRANSLATIONISSUE)
|
||||||
issue.edit(body=TRANSLATIONBODY.format(diag))
|
issue.edit(body=TRANSLATIONBODY.format(diag))
|
||||||
|
|
||||||
|
def update_dependencies(repo):
|
||||||
|
dependencies = sp.check_output(["python3", "tools/extract_dependencies.py", "--markdown"])
|
||||||
|
dependencies = str(dependencies, "utf-8")
|
||||||
|
diff = sp.check_output(["git", "diff", "--name-only", DEPENDENCIESPATH])
|
||||||
|
diff = str(diff, "utf-8")
|
||||||
|
|
||||||
|
if diff != "":
|
||||||
|
sha = repo.get_contents(DEPENDENCIESPATH
|
||||||
|
#, ref="travisForDocs" # Debug
|
||||||
|
).sha
|
||||||
|
repo.update_file(
|
||||||
|
path="/{}".format(DEPENDENCIESPATH),
|
||||||
|
message="[Docs] Update component dependencies\nAutomatically committed through Travis CI.\n\n[ci skip]",
|
||||||
|
content=dependencies, sha=sha, committer=InputGitAuthor("ace3mod", "ace3mod@gmail.com")
|
||||||
|
#, branch="travisForDocs" # Debug
|
||||||
|
)
|
||||||
|
print("Dependencies successfully updated.")
|
||||||
|
else:
|
||||||
|
print("Dependencies skipped - no change.")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("Obtaining token ...")
|
print("Obtaining token ...")
|
||||||
try:
|
try:
|
||||||
token = os.environ["GH_TOKEN"]
|
token = os.environ["GH_TOKEN"]
|
||||||
|
repo = Github(token).get_repo(REPOPATH)
|
||||||
except:
|
except:
|
||||||
print("Could not obtain token.")
|
print("Could not obtain token.")
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
print("done.")
|
print("Token sucessfully obtained.")
|
||||||
|
|
||||||
print("\nUpdating translation issue ...")
|
print("\nUpdating translation issue ...")
|
||||||
try:
|
try:
|
||||||
update_translations(token)
|
update_translations(repo)
|
||||||
except:
|
except:
|
||||||
print("Failed to update translation issue.")
|
print("Failed to update translation issue.")
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
print("done.")
|
print("Translation issue successfully updated.")
|
||||||
|
|
||||||
|
print("\nUpdating dependencies list ...")
|
||||||
|
try:
|
||||||
|
update_dependencies(repo)
|
||||||
|
except:
|
||||||
|
print("Failed to update dependencies.")
|
||||||
|
print(traceback.format_exc())
|
||||||
|
return 1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ def get_dependencies(line):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
if "--markdown" not in sys.argv:
|
||||||
print("""
|
print("""
|
||||||
####################################
|
####################################
|
||||||
# Extract ACE3 Module Dependencies #
|
# Extract ACE3 Module Dependencies #
|
||||||
@ -44,6 +45,8 @@ def main():
|
|||||||
|
|
||||||
# Open config.cpp file and extract dependencies
|
# Open config.cpp file and extract dependencies
|
||||||
data = []
|
data = []
|
||||||
|
configfile = os.path.join(addonspath, folder, "config.cpp")
|
||||||
|
if os.path.exists(configfile):
|
||||||
with open(os.path.join(addonspath, folder, "config.cpp")) as file:
|
with open(os.path.join(addonspath, folder, "config.cpp")) as file:
|
||||||
match = False
|
match = False
|
||||||
for line in file:
|
for line in file:
|
||||||
@ -70,15 +73,21 @@ def main():
|
|||||||
|
|
||||||
data = "`, `".join(data)
|
data = "`, `".join(data)
|
||||||
data = "`{}`".format(data)
|
data = "`{}`".format(data)
|
||||||
print("{}: {}".format(folder,data))
|
|
||||||
|
|
||||||
with open(dependenciespath, "a", newline="\n") as file:
|
jekyll_statement = "".join([
|
||||||
file.writelines([
|
|
||||||
"{% if include.component == \"" + folder + "\" %}\n",
|
"{% if include.component == \"" + folder + "\" %}\n",
|
||||||
"{}\n".format(data),
|
"{}\n".format(data),
|
||||||
"{% endif %}\n\n",
|
"{% endif %}\n"
|
||||||
])
|
])
|
||||||
|
|
||||||
|
with open(dependenciespath, "a", newline="\n") as file:
|
||||||
|
file.writelines([jekyll_statement, "\n"])
|
||||||
|
|
||||||
|
if "--markdown" not in sys.argv:
|
||||||
|
print("{}: {}".format(folder,data))
|
||||||
|
else:
|
||||||
|
print(jekyll_statement)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user