2020-05-03 11:50:34 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
"""
|
|
|
|
Continuous Integration helper script.
|
|
|
|
Automatically detects recipes modified in a changeset (compares with master)
|
|
|
|
and recompiles them.
|
|
|
|
|
|
|
|
Current limitations:
|
|
|
|
- will fail on conflicting requirements
|
|
|
|
"""
|
2020-04-11 14:54:31 +02:00
|
|
|
import sh
|
|
|
|
import subprocess
|
2020-04-25 18:28:16 +02:00
|
|
|
from fnmatch import fnmatch
|
2020-05-03 11:50:34 +02:00
|
|
|
from constants import CORE_RECIPES, BROKEN_RECIPES
|
2020-04-25 18:28:16 +02:00
|
|
|
|
2020-04-11 14:54:31 +02:00
|
|
|
|
2020-05-03 11:50:34 +02:00
|
|
|
def modified_recipes(branch="origin/master"):
|
2020-04-11 14:54:31 +02:00
|
|
|
"""
|
|
|
|
Returns a set of modified recipes between the current branch and the one
|
|
|
|
in param.
|
|
|
|
"""
|
|
|
|
# using the contrib version on purpose rather than sh.git, since it comes
|
|
|
|
# with a bunch of fixes, e.g. disabled TTY, see:
|
|
|
|
# https://stackoverflow.com/a/20128598/185510
|
|
|
|
sh.contrib.git.fetch("origin", "master")
|
2020-05-03 11:50:34 +02:00
|
|
|
git_diff = sh.contrib.git.diff("--name-only", branch)
|
2020-04-11 14:54:31 +02:00
|
|
|
recipes = set()
|
|
|
|
for file_path in git_diff:
|
2020-05-03 16:23:08 +02:00
|
|
|
if fnmatch(file_path, "kivy_ios/recipes/*/__init__.py\n"):
|
2020-05-03 11:50:34 +02:00
|
|
|
recipe = file_path.split("/")[1]
|
2020-04-11 14:54:31 +02:00
|
|
|
recipes.add(recipe)
|
|
|
|
return recipes
|
|
|
|
|
2020-04-25 18:28:16 +02:00
|
|
|
|
2020-05-03 11:50:34 +02:00
|
|
|
def main():
|
|
|
|
recipes = modified_recipes()
|
|
|
|
recipes -= CORE_RECIPES
|
|
|
|
recipes -= BROKEN_RECIPES
|
|
|
|
updated_recipes = " ".join(recipes)
|
|
|
|
if updated_recipes != "":
|
|
|
|
subprocess.run(
|
|
|
|
f"python3 toolchain.py build {updated_recipes}", shell=True, check=True
|
|
|
|
)
|
2020-04-11 14:54:31 +02:00
|
|
|
else:
|
2020-04-25 18:28:16 +02:00
|
|
|
print("Nothing to do. No updated recipes.")
|
2020-05-03 11:50:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|