Skip to content

action: Allow the user to set the west manifest import flag #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions action.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ def cmd2str(cmd):

return " ".join(shlex.quote(word) for word in cmd)

# Taken from Zephyr's check_compliance script

def str2import_flag(import_flag):
flags = {'all': ImportFlag.DEFAULT, 'none': ImportFlag.IGNORE,
'self': ImportFlag.IGNORE_PROJECTS}
return flags[import_flag]

# Taken from Zephyr's check_compliance script
def git(*args, cwd=None):
# Helper for running a Git command. Returns the rstrip()ed stdout output.
# Called like git("diff"). Exits with SystemError (raised by sys.exit()) on
Expand Down Expand Up @@ -238,7 +241,7 @@ def _get_manifests_from_gh(token, gh_repo, mpath, new_mfile, base_sha):

return (old_manifest, new_manifest)

def _get_manifests_from_tree(mpath, gh_pr, checkout, base_sha):
def _get_manifests_from_tree(mpath, gh_pr, checkout, base_sha, import_flag):
# Check if current tree is at the right location

mfile = (Path(checkout) / Path(mpath)).resolve()
Expand All @@ -253,7 +256,7 @@ def manifest_at_rev(sha):
# Use --quiet to avoid Git writing a warning about a commit left
# behind in stderr
git('checkout', '--quiet', '--detach', sha, cwd=checkout)
return Manifest.from_file(mfile)
return Manifest.from_file(mfile, import_flags=import_flag)

old_manifest = manifest_at_rev(base_sha)
new_manifest = manifest_at_rev(gh_pr.head.sha)
Expand Down Expand Up @@ -337,6 +340,10 @@ def main():
required=False,
help='Use a checked-out tree to parse the manifests.')

parser.add_argument('--west-import-flag', action='store',
required=False, choices=['all', 'none', 'self'],
help='Use a checked-out tree to parse the manifests.')

parser.add_argument('--check-impostor-commits', action='store',
required=False,
help='Check for impostor commits.')
Expand Down Expand Up @@ -366,6 +373,7 @@ def main():

message = args.message if args.message != 'none' else None
checkout = args.checkout_path if args.checkout_path != 'none' else None
import_flag = str2import_flag(args.west_import_flag or 'all')
use_tree = args.use_tree_checkout != 'false'
check_impostor = args.check_impostor_commits != 'false'
labels = [x.strip() for x in args.labels.split(',')] \
Expand Down Expand Up @@ -414,7 +422,8 @@ def main():
if use_tree:
(old_manifest, new_manifest) = _get_manifests_from_tree(mpath,
gh_pr, checkout,
base_sha)
base_sha,
import_flag)
else:
(old_manifest, new_manifest) = _get_manifests_from_gh(token, gh_repo,
mpath, new_mfile,
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ inputs:
description: 'If true, comparison will be made on Git tree checkouts'
default: 'false'
required: false
west-import-flag:
description: 'West import flag to use when parsing the checked out manifest.
Choices are all, none, self'
default: 'all'
required: false
check-impostor-commits:
description: 'If true, a check for impostor commits will be performed'
default: 'false'
Expand Down Expand Up @@ -62,6 +67,7 @@ runs:
-l "${{ inputs.labels }}" --label-prefix "${{ inputs.label-prefix }}" \
--dnm-labels "${{ inputs.dnm-labels }}" -v "${{ inputs.verbosity-level }}" \
--use-tree-checkout "${{ inputs.use-tree-checkout }}" \
--west-import-flag "${{ inputs.west-import-flag }}" \
--check-impostor-commits "${{ inputs.check-impostor-commits }}"
shell: bash
env:
Expand Down