From 47c6dc8c2dc17d23d48c79c7fdcdf9692c00d283 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Thu, 5 Jan 2023 14:48:08 -0800 Subject: [PATCH] Adding test pipeline for common-tests --- doc/development/powershell.md | 2 +- eng/common-tests/ci.yml | 30 +++++++++++++++++ .../service-readme-generation/ci.yml | 32 ------------------- .../stages/archetype-sdk-tool-pwsh.yml | 5 ++- .../templates/steps/run-pester-tests.yml | 0 tools/asset-sync/ci.yml | 2 +- 6 files changed, 34 insertions(+), 37 deletions(-) create mode 100644 eng/common-tests/ci.yml delete mode 100644 eng/common-tests/doc-automation/service-readme-generation/ci.yml rename eng/{ => common}/pipelines/templates/stages/archetype-sdk-tool-pwsh.yml (90%) rename eng/{ => common}/pipelines/templates/steps/run-pester-tests.yml (100%) diff --git a/doc/development/powershell.md b/doc/development/powershell.md index fc4052bdb1b..f313dc40c5a 100644 --- a/doc/development/powershell.md +++ b/doc/development/powershell.md @@ -111,7 +111,7 @@ Unit tests should be written for all scripts, and should utilize [Pester](https: - Tests can be located alongside scripts in a directory called `tests`. - Example pester test suites: [job matrix tests](https://github.com/Azure/azure-sdk-tools/tree/main/eng/common/scripts/job-matrix/tests), [asset sync tests](https://github.com/Azure/azure-sdk-tools/blob/main/tools/asset-sync/assets.Tests.ps1) -- A CI pipeline should be defined to run scripts unit tests at the very least. See [archetype-sdk-tool-pwsh](https://github.com/Azure/azure-sdk-tools/blob/main/eng/pipelines/templates/stages/archetype-sdk-tool-pwsh.yml) for how to do this. +- A CI pipeline should be defined to run scripts unit tests at the very least. See [archetype-sdk-tool-pwsh](https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/pipelines/templates/stages/archetype-sdk-tool-pwsh.yml) for how to do this. - Script code should always be written so as much of the surface area as possible can be run via unit tests. Move code that calls out to external dependencies into modular functions, and simplify context/data structures passed to functions as much as possible to it can be easily mocked. #### Running Pester Tests diff --git a/eng/common-tests/ci.yml b/eng/common-tests/ci.yml new file mode 100644 index 00000000000..3137391791f --- /dev/null +++ b/eng/common-tests/ci.yml @@ -0,0 +1,30 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + paths: + include: + - eng/common/scripts/* + - eng/common-tests/* + +pr: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + paths: + include: + - eng/common/scripts/* + - eng/common-tests/* + +extends: + template: /eng/common/pipelines/templates/stages/archetype-sdk-tool-pwsh.yml + parameters: + TargetDirectory: eng/common-tests/ + TargetTags: 'UnitTest' diff --git a/eng/common-tests/doc-automation/service-readme-generation/ci.yml b/eng/common-tests/doc-automation/service-readme-generation/ci.yml deleted file mode 100644 index 1bae3340f81..00000000000 --- a/eng/common-tests/doc-automation/service-readme-generation/ci.yml +++ /dev/null @@ -1,32 +0,0 @@ -# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. -trigger: - branches: - include: - - main - - feature/* - - release/* - - hotfix/* - paths: - include: - - eng/common/scripts/Service-Level-Readme-Automation.ps1 - - eng/common/scripts/Service-Level-Readme-Automation-Functions.ps1 - - eng/common/scripts/Helpers/Metadata-Helpers.ps1 - -pr: - branches: - include: - - main - - feature/* - - release/* - - hotfix/* - paths: - include: - - eng/common/scripts/Service-Level-Readme-Automation.ps1 - - eng/common/scripts/Service-Level-Readme-Automation-Functions.ps1 - - eng/common/scripts/Helpers/Metadata-Helpers.ps1 - -extends: - template: /eng/pipelines/templates/stages/archetype-sdk-tool-pwsh.yml - parameters: - TargetDirectory: eng/common-tests/doc-automation/service-readme-generation - TargetTags: 'UnitTest' diff --git a/eng/pipelines/templates/stages/archetype-sdk-tool-pwsh.yml b/eng/common/pipelines/templates/stages/archetype-sdk-tool-pwsh.yml similarity index 90% rename from eng/pipelines/templates/stages/archetype-sdk-tool-pwsh.yml rename to eng/common/pipelines/templates/stages/archetype-sdk-tool-pwsh.yml index 85f08d6feb0..0b46240cc7e 100644 --- a/eng/pipelines/templates/stages/archetype-sdk-tool-pwsh.yml +++ b/eng/common/pipelines/templates/stages/archetype-sdk-tool-pwsh.yml @@ -15,10 +15,9 @@ variables: - template: /eng/pipelines/templates/variables/globals.yml stages: - - stage: 'Test' + - stage: 'eng_script_tests' jobs: - job: 'Test' - strategy: matrix: Windows: @@ -36,7 +35,7 @@ stages: vmImage: $(Image) steps: - - template: /eng/pipelines/templates/steps/run-pester-tests.yml + - template: /eng/common/pipelines/templates/steps/run-pester-tests.yml parameters: TargetDirectory: ${{ parameters.TargetDirectory }} CustomTestSteps: ${{ parameters.CustomTestSteps }} diff --git a/eng/pipelines/templates/steps/run-pester-tests.yml b/eng/common/pipelines/templates/steps/run-pester-tests.yml similarity index 100% rename from eng/pipelines/templates/steps/run-pester-tests.yml rename to eng/common/pipelines/templates/steps/run-pester-tests.yml diff --git a/tools/asset-sync/ci.yml b/tools/asset-sync/ci.yml index 6dd90a6bb2b..18d17781de9 100644 --- a/tools/asset-sync/ci.yml +++ b/tools/asset-sync/ci.yml @@ -22,7 +22,7 @@ pr: - tools/asset-sync extends: - template: /eng/pipelines/templates/stages/archetype-sdk-tool-pwsh.yml + template: /eng/common/pipelines/templates/stages/archetype-sdk-tool-pwsh.yml parameters: TargetDirectory: tools/asset-sync/ TargetTags: 'Unit'