-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Allow Tox Environments to be Configured As Skippable via platform-matrix #19965
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/usr/bin/env python | ||
|
||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import argparse | ||
|
||
FULL_BUILD_SET = [ | ||
"whl", | ||
"sdist", | ||
"depends", | ||
"latestdependency", | ||
"mindependency", | ||
"whl_no_aio", | ||
] | ||
PR_BUILD_SET = ["whl", "sdist", "mindependency"] | ||
|
||
|
||
def resolve_devops_variable(var_value): | ||
if var_value.startswith("$("): | ||
return [] | ||
else: | ||
return [tox_env.strip() for tox_env in var_value.split(",") if tox_env.strip()] | ||
|
||
|
||
def set_devops_value(resolved_set): | ||
string_value = ",".join(resolved_set) | ||
|
||
print('Setting environment variable toxenv with value "{}"'.format(string_value)) | ||
print("##vso[task.setvariable variable=toxenv]{}".format(string_value)) | ||
|
||
|
||
def remove_unsupported_values(selected_set, unsupported_values): | ||
for unsupported_tox_env in unsupported_values: | ||
if unsupported_tox_env in selected_set: | ||
selected_set.remove(unsupported_tox_env) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser( | ||
description="This script is used to resolve a set of arguments (that correspond to devops runtime variables) and determine which tox environments should be run for the current job." | ||
) | ||
|
||
parser.add_argument( | ||
"-t", "--team-project", dest="team_project", help="", required=True | ||
) | ||
|
||
parser.add_argument( | ||
"-o", | ||
"--override", | ||
dest="override_set", | ||
help="", | ||
) | ||
|
||
parser.add_argument( | ||
"-u", | ||
"--unsupported", | ||
dest="unsupported", | ||
help="", | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
team_project = resolve_devops_variable(args.team_project) | ||
override_set = resolve_devops_variable(args.override_set) | ||
unsupported = resolve_devops_variable(args.unsupported) | ||
|
||
# by default, we should always start with the default set | ||
selected_set = PR_BUILD_SET | ||
|
||
# however if we are internal, use the full set | ||
if "internal" in team_project: | ||
selected_set = FULL_BUILD_SET | ||
|
||
# if there is an override present, that will win ALWAYS | ||
if override_set: | ||
selected_set = override_set | ||
|
||
# however we never run unsupported values | ||
remove_unsupported_values(selected_set, unsupported) | ||
|
||
# and finally output | ||
set_devops_value(selected_set) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why the "@0"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the version of the job! The way that you access native devops tasks is by the name + the version. here is the index of native tasks