From e7d06b9c208d9db2a7afdc1c924683952bb26a03 Mon Sep 17 00:00:00 2001 From: "Xiaofei Cao (from Dev Box)" Date: Tue, 22 Sep 2026 11:02:29 +0800 Subject: [PATCH 1/4] Fix first-release CI path initialization Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/automation/test_generate.py | 114 +++++++++++++++++- eng/automation/utils.py | 39 ++++++ eng/scripts/helpers/Metadata-Helpers.ps1 | 58 ++++++++- .../Automation-Sdk-UpdateMetadata.tests.ps1 | 69 ++++++++++- 4 files changed, 272 insertions(+), 8 deletions(-) diff --git a/eng/automation/test_generate.py b/eng/automation/test_generate.py index b73aaad3c2c8c..da802070e967b 100644 --- a/eng/automation/test_generate.py +++ b/eng/automation/test_generate.py @@ -1,10 +1,12 @@ import os +import shutil import tempfile import unittest +import yaml from generate import update_revapi_skip from generate_utils import should_remove_generated_source_code -from utils import is_first_release +from utils import is_first_release, update_ci_path_filters, update_service_files_for_new_lib POM_WITH_REVAPI_TRUE = """\ @@ -144,5 +146,115 @@ def test_other_module_cleanup_is_enabled(self): self.assertTrue(should_remove_generated_source_code("azure-resourcemanager-compute")) +class TestUpdateCiPathFilters(unittest.TestCase): + + SERVICE = "network" + MODULE = "azure-resourcemanager-network-extra" + INCLUDE_PATH = "sdk/network/azure-resourcemanager-network-extra/" + EXCLUDE_PATH = "sdk/network/azure-resourcemanager-network-extra/pom.xml" + + def setUp(self): + self.ci_yml = { + "trigger": { + "paths": { + "include": ["sdk/network/existing/"], + "exclude": ["sdk/network/existing/pom.xml"], + } + }, + "pr": { + "paths": { + "include": ["sdk/network/existing/"], + "exclude": ["sdk/network/existing/pom.xml"], + } + }, + } + + def test_adds_package_filters_and_preserves_existing_entries(self): + self.assertTrue(update_ci_path_filters(self.ci_yml, self.SERVICE, self.MODULE)) + + for trigger_type in ("trigger", "pr"): + paths = self.ci_yml[trigger_type]["paths"] + self.assertEqual(paths["include"], ["sdk/network/existing/", self.INCLUDE_PATH]) + self.assertEqual(paths["exclude"], ["sdk/network/existing/pom.xml", self.EXCLUDE_PATH]) + + def test_is_idempotent(self): + update_ci_path_filters(self.ci_yml, self.SERVICE, self.MODULE) + + self.assertFalse(update_ci_path_filters(self.ci_yml, self.SERVICE, self.MODULE)) + for trigger_type in ("trigger", "pr"): + paths = self.ci_yml[trigger_type]["paths"] + self.assertEqual(paths["include"].count(self.INCLUDE_PATH), 1) + self.assertEqual(paths["exclude"].count(self.EXCLUDE_PATH), 1) + + def test_rejects_malformed_path_filters(self): + self.ci_yml["pr"]["paths"]["exclude"] = "sdk/network/pom.xml" + + with self.assertRaisesRegex(ValueError, r"pr\.paths\.exclude.*not a list"): + update_ci_path_filters(self.ci_yml, self.SERVICE, self.MODULE) + + +class TestUpdateServiceFilesForNewLib(unittest.TestCase): + + def setUp(self): + self.sdk_root = tempfile.mkdtemp() + self.service = "network" + self.module = "azure-resourcemanager-network-extra" + self.service_dir = os.path.join(self.sdk_root, "sdk", self.service) + self.module_dir = os.path.join(self.service_dir, self.module) + os.makedirs(self.module_dir) + + with open(os.path.join(self.service_dir, "pom.xml"), "w") as f: + f.write("existing") + + self.ci_file = os.path.join(self.service_dir, "ci.yml") + with open(self.ci_file, "w") as f: + yaml.safe_dump( + { + "trigger": { + "paths": { + "include": ["sdk/network/existing/"], + "exclude": ["sdk/network/existing/pom.xml"], + } + }, + "pr": { + "paths": { + "include": ["sdk/network/existing/"], + "exclude": ["sdk/network/existing/pom.xml"], + } + }, + "extends": { + "parameters": { + "Artifacts": [ + { + "name": self.module, + "groupId": "com.azure.resourcemanager", + "safeName": "azureresourcemanagernetworkextra", + } + ] + } + }, + }, + f, + sort_keys=False, + ) + + def tearDown(self): + shutil.rmtree(self.sdk_root) + + def test_updates_filters_when_artifact_already_exists(self): + update_service_files_for_new_lib( + self.sdk_root, self.service, "com.azure.resourcemanager", self.module + ) + + with open(self.ci_file, "r") as f: + ci_yml = yaml.safe_load(f) + for trigger_type in ("trigger", "pr"): + paths = ci_yml[trigger_type]["paths"] + self.assertIn("sdk/network/azure-resourcemanager-network-extra/", paths["include"]) + self.assertIn( + "sdk/network/azure-resourcemanager-network-extra/pom.xml", paths["exclude"] + ) + + if __name__ == "__main__": unittest.main() diff --git a/eng/automation/utils.py b/eng/automation/utils.py index f1ae73ba42bfd..e5f45abc5bfc6 100644 --- a/eng/automation/utils.py +++ b/eng/automation/utils.py @@ -96,6 +96,40 @@ def update_root_pom(sdk_root: str, service: str): logging.info("[POM][Success] Write to root pom") +def update_ci_path_filters(ci_yml: dict, service: str, module: str) -> bool: + """ + Add the package paths to the CI and PR path filters. + + Returns True when at least one filter was added. + """ + include_path = "sdk/{0}/{1}/".format(service, module) + exclude_path = "sdk/{0}/{1}/pom.xml".format(service, module) + updated = False + + for trigger_type in ("trigger", "pr"): + trigger = ci_yml.get(trigger_type) + if type(trigger) != dict: + raise ValueError("[CI] Unexpected ci.yml format: '{0}' is not a mapping".format(trigger_type)) + + paths = trigger.get("paths") + if type(paths) != dict: + raise ValueError("[CI] Unexpected ci.yml format: '{0}.paths' is not a mapping".format(trigger_type)) + + for filter_type, package_path in (("include", include_path), ("exclude", exclude_path)): + filters = paths.get(filter_type) + if type(filters) != list: + raise ValueError( + "[CI] Unexpected ci.yml format: '{0}.paths.{1}' is not a list".format( + trigger_type, filter_type + ) + ) + if package_path not in filters: + filters.append(package_path) + updated = True + + return updated + + def update_service_files_for_new_lib(sdk_root: str, service: str, group: str, module: str): """ For new lib, update ci.yml, pom.xml and changelog.md accordingly. @@ -117,6 +151,8 @@ def update_service_files_for_new_lib(sdk_root: str, service: str, group: str, mo else: ci_yml = yaml.safe_load(CI_FORMAT.format(service, module)) + path_filters_updated = update_ci_path_filters(ci_yml, service, module) + artifact_added = False if not ( type(ci_yml.get("extends")) == dict and type(ci_yml["extends"].get("parameters")) == dict @@ -164,6 +200,9 @@ def update_service_files_for_new_lib(sdk_root: str, service: str, group: str, mo } ) + artifact_added = True + + if artifact_added or path_filters_updated: ci_yml_str = yaml.dump(ci_yml, width=sys.maxsize, sort_keys=False, Dumper=ListIndentDumper) ci_yml_str = re.sub(r"(\n\S)", r"\n\1", ci_yml_str) diff --git a/eng/scripts/helpers/Metadata-Helpers.ps1 b/eng/scripts/helpers/Metadata-Helpers.ps1 index 8aa5b0c1bd939..2ab45b199b15f 100644 --- a/eng/scripts/helpers/Metadata-Helpers.ps1 +++ b/eng/scripts/helpers/Metadata-Helpers.ps1 @@ -570,6 +570,59 @@ function Add-ArtifactToCiYml { return $true } +function Update-CiPathFilters { + <# + .SYNOPSIS + Adds package-specific include and POM exclude paths to CI and PR triggers. + + .OUTPUTS + Boolean indicating whether any path filter was added. + #> + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + $CiYml, + + [Parameter(Mandatory = $true)] + [string]$Service, + + [Parameter(Mandatory = $true)] + [string]$Module + ) + + $includePath = "sdk/$Service/$Module/" + $excludePath = "sdk/$Service/$Module/pom.xml" + $updated = $false + + foreach ($triggerType in @("trigger", "pr")) { + $trigger = $CiYml[$triggerType] + if (-not ($trigger -is [System.Collections.IDictionary])) { + throw "[CI] Unexpected ci.yml format: '$triggerType' is not a mapping" + } + + $paths = $trigger["paths"] + if (-not ($paths -is [System.Collections.IDictionary])) { + throw "[CI] Unexpected ci.yml format: '$triggerType.paths' is not a mapping" + } + + foreach ($filter in @( + @{ Type = "include"; Path = $includePath }, + @{ Type = "exclude"; Path = $excludePath } + )) { + $entries = $paths[$filter.Type] + if (-not ($entries -is [System.Collections.IList])) { + throw "[CI] Unexpected ci.yml format: '$triggerType.paths.$($filter.Type)' is not a list" + } + if (-not $entries.Contains($filter.Path)) { + $entries.Add($filter.Path) + $updated = $true + } + } + } + + return $updated +} + function ConvertTo-CiYmlString { <# .SYNOPSIS @@ -672,8 +725,9 @@ function Update-CiYml { $ciYml = ConvertFrom-Yaml $ciYmlContent -Ordered } - $added = Add-ArtifactToCiYml -CiYml $ciYml -Module $Module -GroupId $GroupId - if ($added) { + $pathFiltersUpdated = Update-CiPathFilters -CiYml $ciYml -Service $Service -Module $Module + $artifactAdded = Add-ArtifactToCiYml -CiYml $ciYml -Module $Module -GroupId $GroupId + if ($artifactAdded -or $pathFiltersUpdated) { $outputStr = ConvertTo-CiYmlString -CiYml $ciYml $ciDir = Split-Path $ciYmlFile -Parent if (-not (Test-Path $ciDir)) { diff --git a/eng/scripts/tests/Automation-Sdk-UpdateMetadata.tests.ps1 b/eng/scripts/tests/Automation-Sdk-UpdateMetadata.tests.ps1 index 96f410a3dce9d..b34341772b770 100644 --- a/eng/scripts/tests/Automation-Sdk-UpdateMetadata.tests.ps1 +++ b/eng/scripts/tests/Automation-Sdk-UpdateMetadata.tests.ps1 @@ -598,6 +598,7 @@ Describe "Script Integration" { Get-Command Update-ServicePom -ErrorAction SilentlyContinue | Should -Not -BeNullOrEmpty Get-Command New-CiYmlContent -ErrorAction SilentlyContinue | Should -Not -BeNullOrEmpty Get-Command Add-ArtifactToCiYml -ErrorAction SilentlyContinue | Should -Not -BeNullOrEmpty + Get-Command Update-CiPathFilters -ErrorAction SilentlyContinue | Should -Not -BeNullOrEmpty Get-Command ConvertTo-CiYmlString -ErrorAction SilentlyContinue | Should -Not -BeNullOrEmpty Get-Command Update-CiYml -ErrorAction SilentlyContinue | Should -Not -BeNullOrEmpty } @@ -831,6 +832,48 @@ Describe "Add-ArtifactToCiYml" { } } +# ============================================================================ +# Update-CiPathFilters tests +# ============================================================================ +Describe "Update-CiPathFilters" { + It "Should preserve existing filters and add package filters to trigger and PR paths" { + $ciYml = ConvertFrom-Yaml $script:SampleCiYmlWithParams -Ordered + + $result = Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" + + $result | Should -Be $true + foreach ($triggerType in @("trigger", "pr")) { + $paths = $ciYml[$triggerType]["paths"] + $paths["include"] | Should -Contain "sdk/network/" + $paths["include"] | Should -Contain "sdk/network/azure-resourcemanager-network-extra/" + $paths["exclude"] | Should -Contain "sdk/network/pom.xml" + $paths["exclude"] | Should -Contain "sdk/network/azure-resourcemanager-network-extra/pom.xml" + } + } + + It "Should not duplicate filters when run twice" { + $ciYml = ConvertFrom-Yaml $script:SampleCiYmlWithParams -Ordered + + Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" + $result = Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" + + $result | Should -Be $false + foreach ($triggerType in @("trigger", "pr")) { + $paths = $ciYml[$triggerType]["paths"] + @($paths["include"] | Where-Object { $_ -eq "sdk/network/azure-resourcemanager-network-extra/" }).Count | Should -Be 1 + @($paths["exclude"] | Where-Object { $_ -eq "sdk/network/azure-resourcemanager-network-extra/pom.xml" }).Count | Should -Be 1 + } + } + + It "Should throw for malformed path filters" { + $ciYml = ConvertFrom-Yaml $script:SampleCiYmlWithParams -Ordered + $ciYml["pr"]["paths"]["exclude"] = "sdk/network/pom.xml" + + { Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" } | + Should -Throw "*pr.paths.exclude*not a list*" + } +} + # ============================================================================ # Update-CiYml tests # ============================================================================ @@ -883,19 +926,29 @@ Describe "Update-CiYml" { $content = Get-Content (Join-Path $svcDir "ci.yml") -Raw $content | Should -Match "azure-resourcemanager-network-extra" $content | Should -Match "release_azureresourcemanagernetworkextra" + + $ciYml = ConvertFrom-Yaml $content -Ordered + foreach ($triggerType in @("trigger", "pr")) { + $ciYml[$triggerType]["paths"]["include"] | Should -Contain "sdk/network/" + $ciYml[$triggerType]["paths"]["include"] | Should -Contain "sdk/network/azure-resourcemanager-network-extra/" + $ciYml[$triggerType]["paths"]["exclude"] | Should -Contain "sdk/network/pom.xml" + $ciYml[$triggerType]["paths"]["exclude"] | Should -Contain "sdk/network/azure-resourcemanager-network-extra/pom.xml" + } } - It "Should skip when module already exists in ci.yml" { + It "Should add missing path filters when module already exists in ci.yml" { $svcDir = Join-Path $script:CiTestRoot "sdk" "network" New-Item -ItemType Directory -Path $svcDir -Force | Out-Null Set-Content -Path (Join-Path $svcDir "ci.yml") -Value $script:SampleCiYmlWithParams - $before = Get-Content (Join-Path $svcDir "ci.yml") -Raw - Update-CiYml -SdkRepoPath $script:CiTestRoot -Service "network" -Module "azure-resourcemanager-network" -GroupId "com.azure.resourcemanager" - $after = Get-Content (Join-Path $svcDir "ci.yml") -Raw - $after | Should -Be $before + $ciYml = Get-Content (Join-Path $svcDir "ci.yml") -Raw | ConvertFrom-Yaml -Ordered + $ciYml["extends"]["parameters"]["Artifacts"].Count | Should -Be 1 + foreach ($triggerType in @("trigger", "pr")) { + $ciYml[$triggerType]["paths"]["include"] | Should -Contain "sdk/network/azure-resourcemanager-network/" + @($ciYml[$triggerType]["paths"]["exclude"] | Where-Object { $_ -eq "sdk/network/azure-resourcemanager-network/pom.xml" }).Count | Should -Be 1 + } } It "Should rename ci.yml to ci.data.yml when SDKType=data and create new ci.yml" { @@ -926,6 +979,12 @@ Describe "Update-CiYml" { $content2 = Get-Content (Join-Path $svcDir "ci.yml") -Raw $content2 | Should -Be $content1 + + $ciYml = ConvertFrom-Yaml $content2 -Ordered + foreach ($triggerType in @("trigger", "pr")) { + @($ciYml[$triggerType]["paths"]["include"] | Where-Object { $_ -eq "sdk/network/azure-resourcemanager-network-extra/" }).Count | Should -Be 1 + @($ciYml[$triggerType]["paths"]["exclude"] | Where-Object { $_ -eq "sdk/network/azure-resourcemanager-network-extra/pom.xml" }).Count | Should -Be 1 + } } } From c650651d00b38e46efaadbea5ceb0d85468f6de8 Mon Sep 17 00:00:00 2001 From: "Xiaofei Cao (from Dev Box)" Date: Tue, 22 Sep 2026 11:39:03 +0800 Subject: [PATCH 2/4] Remove released Network RevApi suppressions Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/lintingconfigs/revapi/track2/revapi.json | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/eng/lintingconfigs/revapi/track2/revapi.json b/eng/lintingconfigs/revapi/track2/revapi.json index ee45f1976fbe9..647adbef2748a 100644 --- a/eng/lintingconfigs/revapi/track2/revapi.json +++ b/eng/lintingconfigs/revapi/track2/revapi.json @@ -171,17 +171,6 @@ "match": "method void com\\.azure\\.resourcemanager\\..*\\.models.*::validate\\(\\)" }, "justification": "Do not include client-side validation for SDK generated from TypeSpec." - }, - { - "code": "java.class.removed", - "old": "class com.azure.resourcemanager.network.models.EnableOnlyIpv6PeeringState", - "justification": "The Network RP wire contract uses a boolean for enableOnlyIPv6Peering; the string enum was removed as an approved spec bug fix." - }, - { - "code": "java.method.returnTypeTypeParametersChanged", - "old": "method java.util.List com.azure.resourcemanager.network.models.ManagedRuleSetRuleGroup::rules()", - "new": "method java.util.List com.azure.resourcemanager.network.models.ManagedRuleSetRuleGroup::rules()", - "justification": "The Network RP has always serialized these read-only WAF rule IDs as integers; the string type was corrected as an approved spec bug fix." } ] } From 4e084d97c4cf54aaf8b981ab18c78cbf4b3312e4 Mon Sep 17 00:00:00 2001 From: "Xiaofei Cao (from Dev Box)" Date: Tue, 22 Sep 2026 15:14:03 +0800 Subject: [PATCH 3/4] Support disabled CI triggers and omitted path filters Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/automation/test_generate.py | 76 +++++++++- eng/automation/utils.py | 6 +- eng/scripts/helpers/Metadata-Helpers.ps1 | 8 +- .../Automation-Sdk-UpdateMetadata.tests.ps1 | 137 +++++++++++++++++- 4 files changed, 216 insertions(+), 11 deletions(-) diff --git a/eng/automation/test_generate.py b/eng/automation/test_generate.py index da802070e967b..f78d7a2168b70 100644 --- a/eng/automation/test_generate.py +++ b/eng/automation/test_generate.py @@ -1,3 +1,4 @@ +import copy import os import shutil import tempfile @@ -186,11 +187,76 @@ def test_is_idempotent(self): self.assertEqual(paths["include"].count(self.INCLUDE_PATH), 1) self.assertEqual(paths["exclude"].count(self.EXCLUDE_PATH), 1) - def test_rejects_malformed_path_filters(self): - self.ci_yml["pr"]["paths"]["exclude"] = "sdk/network/pom.xml" - - with self.assertRaisesRegex(ValueError, r"pr\.paths\.exclude.*not a list"): - update_ci_path_filters(self.ci_yml, self.SERVICE, self.MODULE) + def test_initializes_missing_filter_lists_for_each_trigger_type(self): + expected_paths = {"include": self.INCLUDE_PATH, "exclude": self.EXCLUDE_PATH} + for trigger_type in ("trigger", "pr"): + for filter_type, expected_path in expected_paths.items(): + with self.subTest(trigger_type=trigger_type, filter_type=filter_type): + ci_yml = copy.deepcopy(self.ci_yml) + del ci_yml[trigger_type]["paths"][filter_type] + + self.assertTrue( + update_ci_path_filters(ci_yml, self.SERVICE, self.MODULE) + ) + self.assertEqual( + ci_yml[trigger_type]["paths"][filter_type], [expected_path] + ) + + def test_preserves_each_disabled_trigger_and_updates_the_other(self): + for disabled_trigger in ("trigger", "pr"): + with self.subTest(disabled_trigger=disabled_trigger): + ci_yml = copy.deepcopy(self.ci_yml) + ci_yml[disabled_trigger] = "none" + + self.assertTrue(update_ci_path_filters(ci_yml, self.SERVICE, self.MODULE)) + self.assertEqual(ci_yml[disabled_trigger], "none") + + enabled_trigger = "pr" if disabled_trigger == "trigger" else "trigger" + self.assertIn( + self.INCLUDE_PATH, ci_yml[enabled_trigger]["paths"]["include"] + ) + self.assertIn( + self.EXCLUDE_PATH, ci_yml[enabled_trigger]["paths"]["exclude"] + ) + + def test_preserves_both_disabled_triggers(self): + ci_yml = {"trigger": "none", "pr": "none"} + + self.assertFalse(update_ci_path_filters(ci_yml, self.SERVICE, self.MODULE)) + self.assertEqual(ci_yml, {"trigger": "none", "pr": "none"}) + + def test_is_idempotent_with_initialized_filters_and_disabled_trigger(self): + ci_yml = copy.deepcopy(self.ci_yml) + ci_yml["trigger"] = "none" + del ci_yml["pr"]["paths"]["include"] + del ci_yml["pr"]["paths"]["exclude"] + + self.assertTrue(update_ci_path_filters(ci_yml, self.SERVICE, self.MODULE)) + self.assertFalse(update_ci_path_filters(ci_yml, self.SERVICE, self.MODULE)) + self.assertEqual(ci_yml["trigger"], "none") + self.assertEqual(ci_yml["pr"]["paths"]["include"], [self.INCLUDE_PATH]) + self.assertEqual(ci_yml["pr"]["paths"]["exclude"], [self.EXCLUDE_PATH]) + + def test_rejects_present_non_list_path_filters(self): + for malformed_value in (None, "sdk/network/pom.xml", {}): + with self.subTest(malformed_value=malformed_value): + ci_yml = copy.deepcopy(self.ci_yml) + ci_yml["pr"]["paths"]["exclude"] = malformed_value + + with self.assertRaisesRegex(ValueError, r"pr\.paths\.exclude.*not a list"): + update_ci_path_filters(ci_yml, self.SERVICE, self.MODULE) + + def test_rejects_missing_or_non_none_scalar_trigger(self): + for malformed_value in (None, "None", "disabled"): + with self.subTest(malformed_value=malformed_value): + ci_yml = copy.deepcopy(self.ci_yml) + if malformed_value is None: + del ci_yml["trigger"] + else: + ci_yml["trigger"] = malformed_value + + with self.assertRaisesRegex(ValueError, r"'trigger' is not a mapping"): + update_ci_path_filters(ci_yml, self.SERVICE, self.MODULE) class TestUpdateServiceFilesForNewLib(unittest.TestCase): diff --git a/eng/automation/utils.py b/eng/automation/utils.py index e5f45abc5bfc6..a0a41d1524510 100644 --- a/eng/automation/utils.py +++ b/eng/automation/utils.py @@ -108,6 +108,8 @@ def update_ci_path_filters(ci_yml: dict, service: str, module: str) -> bool: for trigger_type in ("trigger", "pr"): trigger = ci_yml.get(trigger_type) + if type(trigger) == str and trigger == "none": + continue if type(trigger) != dict: raise ValueError("[CI] Unexpected ci.yml format: '{0}' is not a mapping".format(trigger_type)) @@ -116,7 +118,9 @@ def update_ci_path_filters(ci_yml: dict, service: str, module: str) -> bool: raise ValueError("[CI] Unexpected ci.yml format: '{0}.paths' is not a mapping".format(trigger_type)) for filter_type, package_path in (("include", include_path), ("exclude", exclude_path)): - filters = paths.get(filter_type) + if filter_type not in paths: + paths[filter_type] = [] + filters = paths[filter_type] if type(filters) != list: raise ValueError( "[CI] Unexpected ci.yml format: '{0}.paths.{1}' is not a list".format( diff --git a/eng/scripts/helpers/Metadata-Helpers.ps1 b/eng/scripts/helpers/Metadata-Helpers.ps1 index 2ab45b199b15f..bdf4af36f5b8e 100644 --- a/eng/scripts/helpers/Metadata-Helpers.ps1 +++ b/eng/scripts/helpers/Metadata-Helpers.ps1 @@ -596,6 +596,9 @@ function Update-CiPathFilters { foreach ($triggerType in @("trigger", "pr")) { $trigger = $CiYml[$triggerType] + if ($trigger -is [string] -and $trigger -ceq "none") { + continue + } if (-not ($trigger -is [System.Collections.IDictionary])) { throw "[CI] Unexpected ci.yml format: '$triggerType' is not a mapping" } @@ -609,12 +612,15 @@ function Update-CiPathFilters { @{ Type = "include"; Path = $includePath }, @{ Type = "exclude"; Path = $excludePath } )) { + if (-not $paths.Contains($filter.Type)) { + $paths[$filter.Type] = [System.Collections.ArrayList]::new() + } $entries = $paths[$filter.Type] if (-not ($entries -is [System.Collections.IList])) { throw "[CI] Unexpected ci.yml format: '$triggerType.paths.$($filter.Type)' is not a list" } if (-not $entries.Contains($filter.Path)) { - $entries.Add($filter.Path) + $null = $entries.Add($filter.Path) $updated = $true } } diff --git a/eng/scripts/tests/Automation-Sdk-UpdateMetadata.tests.ps1 b/eng/scripts/tests/Automation-Sdk-UpdateMetadata.tests.ps1 index b34341772b770..51e31871478c9 100644 --- a/eng/scripts/tests/Automation-Sdk-UpdateMetadata.tests.ps1 +++ b/eng/scripts/tests/Automation-Sdk-UpdateMetadata.tests.ps1 @@ -865,12 +865,89 @@ Describe "Update-CiPathFilters" { } } - It "Should throw for malformed path filters" { + It "Should initialize missing include and exclude lists for both trigger types" { + foreach ($triggerType in @("trigger", "pr")) { + foreach ($filterType in @("include", "exclude")) { + $ciYml = ConvertFrom-Yaml $script:SampleCiYmlWithParams -Ordered + $ciYml[$triggerType]["paths"].Remove($filterType) + + $result = Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" + + $result | Should -Be $true + ($ciYml[$triggerType]["paths"][$filterType] -is [System.Collections.IList]) | Should -Be $true + if ($filterType -eq "include") { + $ciYml[$triggerType]["paths"][$filterType] | Should -Contain "sdk/network/azure-resourcemanager-network-extra/" + } + else { + $ciYml[$triggerType]["paths"][$filterType] | Should -Contain "sdk/network/azure-resourcemanager-network-extra/pom.xml" + } + } + } + } + + It "Should preserve either disabled trigger and update the other trigger" { + foreach ($disabledTrigger in @("trigger", "pr")) { + $ciYml = ConvertFrom-Yaml $script:SampleCiYmlWithParams -Ordered + $ciYml[$disabledTrigger] = "none" + + $result = Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" + + $result | Should -Be $true + $ciYml[$disabledTrigger] | Should -BeExactly "none" + $enabledTrigger = if ($disabledTrigger -eq "trigger") { "pr" } else { "trigger" } + $ciYml[$enabledTrigger]["paths"]["include"] | Should -Contain "sdk/network/azure-resourcemanager-network-extra/" + $ciYml[$enabledTrigger]["paths"]["exclude"] | Should -Contain "sdk/network/azure-resourcemanager-network-extra/pom.xml" + } + } + + It "Should preserve both disabled triggers without reporting a path-filter change" { + $ciYml = [ordered]@{ trigger = "none"; pr = "none" } + + $result = Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" + + $result | Should -Be $false + $ciYml["trigger"] | Should -BeExactly "none" + $ciYml["pr"] | Should -BeExactly "none" + } + + It "Should remain idempotent after initializing missing lists beside a disabled trigger" { $ciYml = ConvertFrom-Yaml $script:SampleCiYmlWithParams -Ordered - $ciYml["pr"]["paths"]["exclude"] = "sdk/network/pom.xml" + $ciYml["trigger"] = "none" + $ciYml["pr"]["paths"].Remove("include") + $ciYml["pr"]["paths"].Remove("exclude") - { Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" } | - Should -Throw "*pr.paths.exclude*not a list*" + Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" + $result = Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" + + $result | Should -Be $false + $ciYml["trigger"] | Should -BeExactly "none" + @($ciYml["pr"]["paths"]["include"]).Count | Should -Be 1 + @($ciYml["pr"]["paths"]["exclude"]).Count | Should -Be 1 + } + + It "Should throw for present null and scalar path filters" { + foreach ($malformedValue in @($null, "sdk/network/pom.xml")) { + $ciYml = ConvertFrom-Yaml $script:SampleCiYmlWithParams -Ordered + $ciYml["pr"]["paths"]["exclude"] = $malformedValue + + { Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" } | + Should -Throw "*pr.paths.exclude*not a list*" + } + } + + It "Should throw for missing or non-none scalar triggers" { + foreach ($malformedValue in @($null, "None", "disabled")) { + $ciYml = ConvertFrom-Yaml $script:SampleCiYmlWithParams -Ordered + if ($null -eq $malformedValue) { + $ciYml.Remove("trigger") + } + else { + $ciYml["trigger"] = $malformedValue + } + + { Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" } | + Should -Throw "*'trigger' is not a mapping*" + } } } @@ -951,6 +1028,58 @@ Describe "Update-CiYml" { } } + It "Should preserve a disabled trigger and serialize initialized filter lists" { + $svcDir = Join-Path $script:CiTestRoot "sdk" "network" + New-Item -ItemType Directory -Path $svcDir -Force | Out-Null + $ciContent = @" +trigger: none +pr: + paths: {} +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: network + Artifacts: + - name: azure-resourcemanager-network + groupId: com.azure.resourcemanager + safeName: azureresourcemanagernetwork +"@ + Set-Content -Path (Join-Path $svcDir "ci.yml") -Value $ciContent + + Update-CiYml -SdkRepoPath $script:CiTestRoot -Service "network" -Module "azure-resourcemanager-network" -GroupId "com.azure.resourcemanager" + + $ciYml = Get-Content (Join-Path $svcDir "ci.yml") -Raw | ConvertFrom-Yaml -Ordered + $ciYml["trigger"] | Should -BeExactly "none" + @($ciYml["pr"]["paths"]["include"]) | Should -Be @("sdk/network/azure-resourcemanager-network/") + @($ciYml["pr"]["paths"]["exclude"]) | Should -Be @("sdk/network/azure-resourcemanager-network/pom.xml") + } + + It "Should preserve both disabled triggers while serializing artifact updates" { + $svcDir = Join-Path $script:CiTestRoot "sdk" "network" + New-Item -ItemType Directory -Path $svcDir -Force | Out-Null + $ciContent = @" +trigger: none +pr: none +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: network + Artifacts: + - name: azure-resourcemanager-network + groupId: com.azure.resourcemanager + safeName: azureresourcemanagernetwork +"@ + Set-Content -Path (Join-Path $svcDir "ci.yml") -Value $ciContent + + Update-CiYml -SdkRepoPath $script:CiTestRoot -Service "network" -Module "azure-resourcemanager-network-extra" -GroupId "com.azure.resourcemanager" + + $ciYml = Get-Content (Join-Path $svcDir "ci.yml") -Raw | ConvertFrom-Yaml -Ordered + $ciYml["trigger"] | Should -BeExactly "none" + $ciYml["pr"] | Should -BeExactly "none" + @($ciYml["extends"]["parameters"]["Artifacts"] | ForEach-Object { $_["name"] }) | + Should -Contain "azure-resourcemanager-network-extra" + } + It "Should rename ci.yml to ci.data.yml when SDKType=data and create new ci.yml" { $svcDir = Join-Path $script:CiTestRoot "sdk" "myservice" New-Item -ItemType Directory -Path $svcDir -Force | Out-Null From 41cb1264b9d0dd33ae791388daeaa386e1452150 Mon Sep 17 00:00:00 2001 From: "Xiaofei Cao (from Dev Box)" Date: Tue, 22 Sep 2026 17:07:05 +0800 Subject: [PATCH 4/4] Make CI path enrichment non-fatal Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/automation/test_generate.py | 72 +++++++++++- eng/automation/utils.py | 19 +-- eng/scripts/helpers/Metadata-Helpers.ps1 | 15 ++- .../Automation-Sdk-UpdateMetadata.tests.ps1 | 108 ++++++++++++++++-- 4 files changed, 187 insertions(+), 27 deletions(-) diff --git a/eng/automation/test_generate.py b/eng/automation/test_generate.py index f78d7a2168b70..29ba47407b290 100644 --- a/eng/automation/test_generate.py +++ b/eng/automation/test_generate.py @@ -202,6 +202,15 @@ def test_initializes_missing_filter_lists_for_each_trigger_type(self): ci_yml[trigger_type]["paths"][filter_type], [expected_path] ) + def test_initializes_absent_paths_mapping(self): + del self.ci_yml["trigger"]["paths"] + + self.assertTrue(update_ci_path_filters(self.ci_yml, self.SERVICE, self.MODULE)) + self.assertEqual( + self.ci_yml["trigger"]["paths"], + {"include": [self.INCLUDE_PATH], "exclude": [self.EXCLUDE_PATH]}, + ) + def test_preserves_each_disabled_trigger_and_updates_the_other(self): for disabled_trigger in ("trigger", "pr"): with self.subTest(disabled_trigger=disabled_trigger): @@ -237,17 +246,23 @@ def test_is_idempotent_with_initialized_filters_and_disabled_trigger(self): self.assertEqual(ci_yml["pr"]["paths"]["include"], [self.INCLUDE_PATH]) self.assertEqual(ci_yml["pr"]["paths"]["exclude"], [self.EXCLUDE_PATH]) - def test_rejects_present_non_list_path_filters(self): + def test_skips_present_non_list_filter_and_updates_sibling(self): for malformed_value in (None, "sdk/network/pom.xml", {}): with self.subTest(malformed_value=malformed_value): ci_yml = copy.deepcopy(self.ci_yml) ci_yml["pr"]["paths"]["exclude"] = malformed_value - with self.assertRaisesRegex(ValueError, r"pr\.paths\.exclude.*not a list"): + with self.assertLogs(level="WARNING") as logs: update_ci_path_filters(ci_yml, self.SERVICE, self.MODULE) + self.assertIs(ci_yml["pr"]["paths"]["exclude"], malformed_value) + self.assertIn(self.INCLUDE_PATH, ci_yml["pr"]["paths"]["include"]) + self.assertIn(self.INCLUDE_PATH, ci_yml["trigger"]["paths"]["include"]) + self.assertTrue( + any("pr.paths.exclude" in message for message in logs.output) + ) - def test_rejects_missing_or_non_none_scalar_trigger(self): - for malformed_value in (None, "None", "disabled"): + def test_skips_omitted_and_non_mapping_triggers(self): + for malformed_value in (None, "None", "disabled", ["main"]): with self.subTest(malformed_value=malformed_value): ci_yml = copy.deepcopy(self.ci_yml) if malformed_value is None: @@ -255,8 +270,28 @@ def test_rejects_missing_or_non_none_scalar_trigger(self): else: ci_yml["trigger"] = malformed_value - with self.assertRaisesRegex(ValueError, r"'trigger' is not a mapping"): - update_ci_path_filters(ci_yml, self.SERVICE, self.MODULE) + self.assertTrue(update_ci_path_filters(ci_yml, self.SERVICE, self.MODULE)) + if malformed_value is None: + self.assertNotIn("trigger", ci_yml) + else: + self.assertIs(ci_yml["trigger"], malformed_value) + self.assertIn(self.INCLUDE_PATH, ci_yml["pr"]["paths"]["include"]) + + def test_skips_present_non_mapping_paths_and_updates_other_trigger(self): + for malformed_value in (None, "sdk/network/", []): + with self.subTest(malformed_value=malformed_value): + ci_yml = copy.deepcopy(self.ci_yml) + ci_yml["trigger"]["paths"] = malformed_value + + with self.assertLogs(level="WARNING") as logs: + self.assertTrue( + update_ci_path_filters(ci_yml, self.SERVICE, self.MODULE) + ) + self.assertIs(ci_yml["trigger"]["paths"], malformed_value) + self.assertIn(self.INCLUDE_PATH, ci_yml["pr"]["paths"]["include"]) + self.assertTrue( + any("trigger.paths" in message for message in logs.output) + ) class TestUpdateServiceFilesForNewLib(unittest.TestCase): @@ -321,6 +356,31 @@ def test_updates_filters_when_artifact_already_exists(self): "sdk/network/azure-resourcemanager-network-extra/pom.xml", paths["exclude"] ) + def test_malformed_filters_do_not_block_artifact_update(self): + with open(self.ci_file, "r") as f: + ci_yml = yaml.safe_load(f) + ci_yml["trigger"]["paths"] = None + ci_yml["pr"]["paths"]["exclude"] = None + ci_yml["extends"]["parameters"]["Artifacts"] = [] + with open(self.ci_file, "w") as f: + yaml.safe_dump(ci_yml, f, sort_keys=False) + + update_service_files_for_new_lib( + self.sdk_root, self.service, "com.azure.resourcemanager", self.module + ) + + with open(self.ci_file, "r") as f: + updated_ci_yml = yaml.safe_load(f) + self.assertIsNone(updated_ci_yml["trigger"]["paths"]) + self.assertIsNone(updated_ci_yml["pr"]["paths"]["exclude"]) + self.assertIn( + "sdk/network/azure-resourcemanager-network-extra/", + updated_ci_yml["pr"]["paths"]["include"], + ) + self.assertEqual( + updated_ci_yml["extends"]["parameters"]["Artifacts"][0]["name"], self.module + ) + if __name__ == "__main__": unittest.main() diff --git a/eng/automation/utils.py b/eng/automation/utils.py index a0a41d1524510..964bce20ce555 100644 --- a/eng/automation/utils.py +++ b/eng/automation/utils.py @@ -107,26 +107,31 @@ def update_ci_path_filters(ci_yml: dict, service: str, module: str) -> bool: updated = False for trigger_type in ("trigger", "pr"): + if trigger_type not in ci_yml: + continue trigger = ci_yml.get(trigger_type) if type(trigger) == str and trigger == "none": continue if type(trigger) != dict: - raise ValueError("[CI] Unexpected ci.yml format: '{0}' is not a mapping".format(trigger_type)) + logging.warning("[CI][Skip] '{0}' is not a mapping".format(trigger_type)) + continue - paths = trigger.get("paths") + if "paths" not in trigger: + trigger["paths"] = {} + paths = trigger["paths"] if type(paths) != dict: - raise ValueError("[CI] Unexpected ci.yml format: '{0}.paths' is not a mapping".format(trigger_type)) + logging.warning("[CI][Skip] '{0}.paths' is not a mapping".format(trigger_type)) + continue for filter_type, package_path in (("include", include_path), ("exclude", exclude_path)): if filter_type not in paths: paths[filter_type] = [] filters = paths[filter_type] if type(filters) != list: - raise ValueError( - "[CI] Unexpected ci.yml format: '{0}.paths.{1}' is not a list".format( - trigger_type, filter_type - ) + logging.warning( + "[CI][Skip] '{0}.paths.{1}' is not a list".format(trigger_type, filter_type) ) + continue if package_path not in filters: filters.append(package_path) updated = True diff --git a/eng/scripts/helpers/Metadata-Helpers.ps1 b/eng/scripts/helpers/Metadata-Helpers.ps1 index bdf4af36f5b8e..014597e30e69a 100644 --- a/eng/scripts/helpers/Metadata-Helpers.ps1 +++ b/eng/scripts/helpers/Metadata-Helpers.ps1 @@ -595,17 +595,25 @@ function Update-CiPathFilters { $updated = $false foreach ($triggerType in @("trigger", "pr")) { + if (-not $CiYml.Contains($triggerType)) { + continue + } $trigger = $CiYml[$triggerType] if ($trigger -is [string] -and $trigger -ceq "none") { continue } if (-not ($trigger -is [System.Collections.IDictionary])) { - throw "[CI] Unexpected ci.yml format: '$triggerType' is not a mapping" + Write-Warning "[CI][Skip] '$triggerType' is not a mapping" + continue } + if (-not $trigger.Contains("paths")) { + $trigger["paths"] = [ordered]@{} + } $paths = $trigger["paths"] if (-not ($paths -is [System.Collections.IDictionary])) { - throw "[CI] Unexpected ci.yml format: '$triggerType.paths' is not a mapping" + Write-Warning "[CI][Skip] '$triggerType.paths' is not a mapping" + continue } foreach ($filter in @( @@ -617,7 +625,8 @@ function Update-CiPathFilters { } $entries = $paths[$filter.Type] if (-not ($entries -is [System.Collections.IList])) { - throw "[CI] Unexpected ci.yml format: '$triggerType.paths.$($filter.Type)' is not a list" + Write-Warning "[CI][Skip] '$triggerType.paths.$($filter.Type)' is not a list" + continue } if (-not $entries.Contains($filter.Path)) { $null = $entries.Add($filter.Path) diff --git a/eng/scripts/tests/Automation-Sdk-UpdateMetadata.tests.ps1 b/eng/scripts/tests/Automation-Sdk-UpdateMetadata.tests.ps1 index 51e31871478c9..fd479cc57a186 100644 --- a/eng/scripts/tests/Automation-Sdk-UpdateMetadata.tests.ps1 +++ b/eng/scripts/tests/Automation-Sdk-UpdateMetadata.tests.ps1 @@ -885,6 +885,17 @@ Describe "Update-CiPathFilters" { } } + It "Should initialize an absent paths mapping" { + $ciYml = ConvertFrom-Yaml $script:SampleCiYmlWithParams -Ordered + $ciYml["trigger"].Remove("paths") + + $result = Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" + + $result | Should -Be $true + $ciYml["trigger"]["paths"]["include"] | Should -Contain "sdk/network/azure-resourcemanager-network-extra/" + $ciYml["trigger"]["paths"]["exclude"] | Should -Contain "sdk/network/azure-resourcemanager-network-extra/pom.xml" + } + It "Should preserve either disabled trigger and update the other trigger" { foreach ($disabledTrigger in @("trigger", "pr")) { $ciYml = ConvertFrom-Yaml $script:SampleCiYmlWithParams -Ordered @@ -925,28 +936,71 @@ Describe "Update-CiPathFilters" { @($ciYml["pr"]["paths"]["exclude"]).Count | Should -Be 1 } - It "Should throw for present null and scalar path filters" { - foreach ($malformedValue in @($null, "sdk/network/pom.xml")) { + It "Should skip present null and scalar filters while updating sibling filters" { + $testCases = @( + @{ Value = $null }, + @{ Value = "sdk/network/pom.xml" }, + @{ Value = [ordered]@{} } + ) + foreach ($testCase in $testCases) { $ciYml = ConvertFrom-Yaml $script:SampleCiYmlWithParams -Ordered - $ciYml["pr"]["paths"]["exclude"] = $malformedValue + $ciYml["pr"]["paths"]["exclude"] = $testCase.Value - { Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" } | - Should -Throw "*pr.paths.exclude*not a list*" + $result = Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" -WarningVariable warnings + + $result | Should -Be $true + $ciYml["pr"]["paths"]["exclude"] | Should -Be $testCase.Value + $ciYml["pr"]["paths"]["include"] | Should -Contain "sdk/network/azure-resourcemanager-network-extra/" + $ciYml["trigger"]["paths"]["include"] | Should -Contain "sdk/network/azure-resourcemanager-network-extra/" + $warnings.Message | Should -Contain "[CI][Skip] 'pr.paths.exclude' is not a list" } } - It "Should throw for missing or non-none scalar triggers" { - foreach ($malformedValue in @($null, "None", "disabled")) { + It "Should preserve omitted and non-mapping triggers while updating the other trigger" { + $testCases = @( + @{ Missing = $true }, + @{ Value = "None" }, + @{ Value = "disabled" }, + @{ Value = [System.Collections.ArrayList]@("main") } + ) + foreach ($testCase in $testCases) { $ciYml = ConvertFrom-Yaml $script:SampleCiYmlWithParams -Ordered - if ($null -eq $malformedValue) { + if ($testCase.Missing) { $ciYml.Remove("trigger") } else { - $ciYml["trigger"] = $malformedValue + $ciYml["trigger"] = $testCase.Value } - { Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" } | - Should -Throw "*'trigger' is not a mapping*" + $result = Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" + + $result | Should -Be $true + if ($testCase.Missing) { + $ciYml.Contains("trigger") | Should -Be $false + } + else { + $ciYml["trigger"] | Should -Be $testCase.Value + } + $ciYml["pr"]["paths"]["include"] | Should -Contain "sdk/network/azure-resourcemanager-network-extra/" + } + } + + It "Should skip present non-mapping paths while updating the other trigger" { + $testCases = @( + @{ Value = $null }, + @{ Value = "sdk/network/" }, + @{ Value = [System.Collections.ArrayList]::new() } + ) + foreach ($testCase in $testCases) { + $ciYml = ConvertFrom-Yaml $script:SampleCiYmlWithParams -Ordered + $ciYml["trigger"]["paths"] = $testCase.Value + + $result = Update-CiPathFilters -CiYml $ciYml -Service "network" -Module "azure-resourcemanager-network-extra" -WarningVariable warnings + + $result | Should -Be $true + $ciYml["trigger"]["paths"] | Should -Be $testCase.Value + $ciYml["pr"]["paths"]["include"] | Should -Contain "sdk/network/azure-resourcemanager-network-extra/" + $warnings.Message | Should -Contain "[CI][Skip] 'trigger.paths' is not a mapping" } } } @@ -1080,6 +1134,38 @@ extends: Should -Contain "azure-resourcemanager-network-extra" } + It "Should preserve malformed filters while serializing valid siblings and artifact updates" { + $svcDir = Join-Path $script:CiTestRoot "sdk" "network" + New-Item -ItemType Directory -Path $svcDir -Force | Out-Null + $ciContent = @" +trigger: + paths: +pr: + paths: + include: + - sdk/network/ + exclude: +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: network + Artifacts: + - name: azure-resourcemanager-network + groupId: com.azure.resourcemanager + safeName: azureresourcemanagernetwork +"@ + Set-Content -Path (Join-Path $svcDir "ci.yml") -Value $ciContent + + Update-CiYml -SdkRepoPath $script:CiTestRoot -Service "network" -Module "azure-resourcemanager-network-extra" -GroupId "com.azure.resourcemanager" + + $ciYml = Get-Content (Join-Path $svcDir "ci.yml") -Raw | ConvertFrom-Yaml -Ordered + $ciYml["trigger"]["paths"] | Should -BeNullOrEmpty + $ciYml["pr"]["paths"]["exclude"] | Should -BeNullOrEmpty + $ciYml["pr"]["paths"]["include"] | Should -Contain "sdk/network/azure-resourcemanager-network-extra/" + @($ciYml["extends"]["parameters"]["Artifacts"] | ForEach-Object { $_["name"] }) | + Should -Contain "azure-resourcemanager-network-extra" + } + It "Should rename ci.yml to ci.data.yml when SDKType=data and create new ci.yml" { $svcDir = Join-Path $script:CiTestRoot "sdk" "myservice" New-Item -ItemType Directory -Path $svcDir -Force | Out-Null