Skip to content

Commit

Permalink
ci: test_plan: add tags based on manifest change
Browse files Browse the repository at this point in the history
When manifest changes, add tags based on the changed project names.t

Signed-off-by: Anas Nashif <[email protected]>
  • Loading branch information
nashif authored and carlescufi committed Aug 22, 2023
1 parent b9585ad commit d4169c9
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions scripts/ci/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import sys
from pathlib import Path
from git import Repo
from west.manifest import Manifest

if "ZEPHYR_BASE" not in os.environ:
exit("$ZEPHYR_BASE environment variable undefined.")
Expand Down Expand Up @@ -96,6 +97,7 @@ def __init__(self, modified_files, pull_request=False, platforms=[]):
self.default_run = False

def process(self):
self.find_modules()
self.find_tags()
self.find_tests()
if not self.platforms:
Expand All @@ -122,6 +124,44 @@ def get_plan(self, options, integration=False):
if os.path.exists(fname):
os.remove(fname)

def find_modules(self):
if 'west.yml' in self.modified_files:
print(f"Manifest file 'west.yml' changed")
print("=========")
old_manifest_content = repo.git.show(f"{args.commits[:-2]}:west.yml")
with open("west_old.yml", "w") as manifest:
manifest.write(old_manifest_content)
old_manifest = Manifest.from_file("west_old.yml")
new_manifest = Manifest.from_file("west.yml")
old_projs = set((p.name, p.revision) for p in old_manifest.projects)
new_projs = set((p.name, p.revision) for p in new_manifest.projects)
logging.debug(f'old_projs: {old_projs}')
logging.debug(f'new_projs: {new_projs}')
# Removed projects
rprojs = set(filter(lambda p: p[0] not in list(p[0] for p in new_projs),
old_projs - new_projs))
# Updated projects
uprojs = set(filter(lambda p: p[0] in list(p[0] for p in old_projs),
new_projs - old_projs))
# Added projects
aprojs = new_projs - old_projs - uprojs

# All projs
projs = rprojs | uprojs | aprojs
projs_names = [name for name, rev in projs]

logging.info(f'rprojs: {rprojs}')
logging.info(f'uprojs: {uprojs}')
logging.info(f'aprojs: {aprojs}')
logging.info(f'project: {projs_names}')

_options = []
for p in projs_names:
_options.extend(["-t", p ])

self.get_plan(_options, True)


def find_archs(self):
# we match both arch/<arch>/* and include/arch/<arch> and skip common.
# Some architectures like riscv require special handling, i.e. riscv
Expand Down Expand Up @@ -331,6 +371,7 @@ def parse_args():
print("\n".join(files))
print("=========")


f = Filters(files, args.pull_request, args.platform)
f.process()

Expand Down

0 comments on commit d4169c9

Please sign in to comment.