Skip to content

Commit

Permalink
Adding test pipeline for common-tests (#5040)
Browse files Browse the repository at this point in the history
Our powershell scripts currently missed test coverage. The goal is trying to add test coverage as many as possible. The PR is to add test pipeline to cover all tests under `common-tests`

Testing pipeline: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=2088942&view=logs&j=c7677f77-9c7a-5d06-5685-83acb5683895&t=358adba7-a1e6-5484-d654-f81d8812d6aa
  • Loading branch information
sima-zhu authored Jan 9, 2023
1 parent 61a1d76 commit 617ea82
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 37 deletions.
2 changes: 1 addition & 1 deletion doc/development/powershell.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions eng/common-tests/ci.yml
Original file line number Diff line number Diff line change
@@ -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'
32 changes: 0 additions & 32 deletions eng/common-tests/doc-automation/service-readme-generation/ci.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion tools/asset-sync/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit 617ea82

Please sign in to comment.