Skip to content

Commit

Permalink
eng, sdk automation, typespec, no longer validate namespace option (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
weidongxu-microsoft authored Nov 18, 2024
1 parent 45a69a3 commit 6429cc1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 29 deletions.
12 changes: 10 additions & 2 deletions eng/automation/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ def sdk_automation_autorest(config: dict) -> List[dict]:
"apiViewArtifact": next(iter(glob.glob("{0}/target/*-sources.jar".format(output_folder))), None),
"language": "Java",
"result": "succeeded" if succeeded else "failed",
"changelog": {"content": changelog, "hasBreakingChange": breaking, "breakingChangeItems": breaking_change_items},
"changelog": {
"content": changelog,
"hasBreakingChange": breaking,
"breakingChangeItems": breaking_change_items,
},
}
)

Expand Down Expand Up @@ -294,7 +298,11 @@ def sdk_automation_typespec_project(tsp_project: str, config: dict) -> dict:
"apiViewArtifact": next(iter(glob.glob("{0}/target/*-sources.jar".format(sdk_folder))), None),
"language": "Java",
"result": result,
"changelog": {"content": changelog, "hasBreakingChange": breaking, "breakingChangeItems": breaking_change_items},
"changelog": {
"content": changelog,
"hasBreakingChange": breaking,
"breakingChangeItems": breaking_change_items,
},
}
else:
# no info about package, abort with result=failed
Expand Down
12 changes: 10 additions & 2 deletions eng/automation/generate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ def sdk_automation_typespec_project(tsp_project: str, config: dict) -> dict:
"apiViewArtifact": next(iter(glob.glob("{0}/target/*-sources.jar".format(sdk_folder))), None),
"language": "Java",
"result": result,
"changelog": {"content": changelog, "hasBreakingChange": breaking, "breakingChangeItems": breaking_change_items},
"changelog": {
"content": changelog,
"hasBreakingChange": breaking,
"breakingChangeItems": breaking_change_items,
},
}
else:
# no info about package, abort with result=failed
Expand Down Expand Up @@ -286,7 +290,11 @@ def sdk_automation_readme(readme_file_abspath: str, packages: List[dict], sdk_ro
"apiViewArtifact": next(iter(glob.glob("{0}/target/*-sources.jar".format(generated_folder))), None),
"language": "Java",
"result": result,
"changelog": {"content": changelog, "hasBreakingChange": breaking, "breakingChangeItems": breaking_change_items},
"changelog": {
"content": changelog,
"hasBreakingChange": breaking,
"breakingChangeItems": breaking_change_items,
},
}
)

Expand Down
2 changes: 1 addition & 1 deletion eng/automation/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

SDK_ROOT = "../../" # related to file dir
AUTOREST_CORE_VERSION = "3.9.7"
AUTOREST_JAVA = "@autorest/java@4.1.40"
AUTOREST_JAVA = "@autorest/java@4.1.41"
DEFAULT_VERSION = "1.0.0-beta.1"
GROUP_ID = "com.azure.resourcemanager"
API_SPECS_FILE = "api-specs.yaml"
Expand Down
24 changes: 0 additions & 24 deletions eng/automation/typespec_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import re
import sys
import yaml
import logging

Expand All @@ -23,7 +22,6 @@ def validate_tspconfig(tsp_dir: str) -> bool:

service_dir_pattern = r"sdk/\w+"
package_dir_pattern = r"azure(-\w+)+"
namespace_pattern = r"com\.azure(\.\w+)+"

# SDK automation would make sure these properties exists
service_dir: str = yaml_json["parameters"]["service-dir"]["default"]
Expand All @@ -35,10 +33,8 @@ def validate_tspconfig(tsp_dir: str) -> bool:
'E.g. "com.azure.ai.openai".'
)
return False
namespace: str = yaml_json["options"]["@azure-tools/typespec-java"]["namespace"]

# validate service-dir
service_dir_segments = service_dir.split("/")
if not re.fullmatch(service_dir_pattern, service_dir):
valid = False
logging.error(
Expand All @@ -58,24 +54,4 @@ def validate_tspconfig(tsp_dir: str) -> bool:
f"Current value: {package_dir}"
)

# validate namespace
if not re.fullmatch(namespace_pattern, namespace):
valid = False
logging.error(
"[VALIDATE][tspconfig.yaml] "
'options.@azure-tools/typespec-java.namespace SHOULD start with "com.azure.". '
'E.g. "com.azure.ai.openai". '
f"Current value: {namespace}"
)

# validate package_dir matches namespace
if valid:
expected_package_dir = namespace[4:].replace(".", "-")
if expected_package_dir != package_dir:
valid = False
logging.error(
"[VALIDATE][tspconfig.yaml] package_dir does not match namespace. "
f'Expected package_dir from namespace "{namespace}" is: {expected_package_dir}'
)

return valid

0 comments on commit 6429cc1

Please sign in to comment.