From 2851884c8bb96752ebf5057cf124dbe582eb31f4 Mon Sep 17 00:00:00 2001 From: Shilong Liu Date: Fri, 17 Jun 2022 15:39:41 +0800 Subject: [PATCH] [ci] Support to skip vstest using include/exclude config file. (#11086) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit example: ├── folderA │ ├── fileA (skip vstest) │ ├── fileB │ └── fileC If we want to skip vstest when changing /folderA/fileA, and not skip vstest when changing fileB or fileC. vstest-include: ^folderA/fileA vstest-exclude: ^folderA --- .azure-pipelines/azure-pipelines-build.yml | 1 + .azure-pipelines/template-skipvstest.yml | 12 ++++++++++++ .azure-pipelines/vstest-exclude | 3 +++ .azure-pipelines/vstest-include | 2 ++ azure-pipelines.yml | 1 + 5 files changed, 19 insertions(+) create mode 100644 .azure-pipelines/template-skipvstest.yml create mode 100644 .azure-pipelines/vstest-exclude create mode 100644 .azure-pipelines/vstest-include diff --git a/.azure-pipelines/azure-pipelines-build.yml b/.azure-pipelines/azure-pipelines-build.yml index c84c914418..f7eeb8c95d 100644 --- a/.azure-pipelines/azure-pipelines-build.yml +++ b/.azure-pipelines/azure-pipelines-build.yml @@ -98,6 +98,7 @@ jobs: platform_rpc: nephos buildSteps: + - template: template-skipvstest.yml - bash: | set -ex if [ $(GROUP_NAME) == vs ]; then diff --git a/.azure-pipelines/template-skipvstest.yml b/.azure-pipelines/template-skipvstest.yml new file mode 100644 index 0000000000..b47f17ce6e --- /dev/null +++ b/.azure-pipelines/template-skipvstest.yml @@ -0,0 +1,12 @@ +steps: +- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: + - script: | + set -ex + tar_branch=origin/$(System.PullRequest.TargetBranch) + git diff $tar_branch..HEAD --name-only | grep -v -f .azure-pipelines/vstest-exclude && exit 0 + git diff $tar_branch..HEAD --name-only | grep -f .azure-pipelines/vstest-include && exit 0 + set +x + echo "Skip vstest jobs" + echo "##vso[task.setvariable variable=SKIP_VSTEST;isOutput=true]YES" + name: SetVar + displayName: "Check if vstest is needed." diff --git a/.azure-pipelines/vstest-exclude b/.azure-pipelines/vstest-exclude new file mode 100644 index 0000000000..7161670470 --- /dev/null +++ b/.azure-pipelines/vstest-exclude @@ -0,0 +1,3 @@ +^platform +^.azure-pipelines +^files/build/versions diff --git a/.azure-pipelines/vstest-include b/.azure-pipelines/vstest-include new file mode 100644 index 0000000000..86fb3a9d88 --- /dev/null +++ b/.azure-pipelines/vstest-include @@ -0,0 +1,2 @@ +^platform/vs +^.azure-pipelines/run-test-template.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a0b1cf5425..345fb9b57a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -77,6 +77,7 @@ stages: - stage: Test dependsOn: BuildVS + condition: and(ne(stageDependencies.BuildVS.outputs['vs.SetVar.SKIP_VSTEST'], 'YES'), succeeded()) variables: - name: inventory value: veos_vtb