diff --git a/azure-devops/build-and-test.yml b/azure-devops/build-and-test.yml index 2c75e5e06c..6798be4d1b 100644 --- a/azure-devops/build-and-test.yml +++ b/azure-devops/build-and-test.yml @@ -34,10 +34,21 @@ jobs: timeoutInMinutes: 30 steps: - template: checkout-self.yml - - template: checkout-submodules.yml + - template: checkout-submodule.yml parameters: - buildBenchmarks: ${{ parameters.buildBenchmarks }} - skipTesting: ${{ parameters.skipTesting }} + enabled: ${{ not(parameters.skipTesting) }} + path: 'llvm-project' + url: 'https://github.com/llvm/llvm-project.git' + - template: checkout-submodule.yml + parameters: + enabled: true + path: 'boost-math' + url: 'https://github.com/boostorg/math.git' + - template: checkout-submodule.yml + parameters: + enabled: ${{ parameters.buildBenchmarks }} + path: 'benchmarks/google-benchmark' + url: 'https://github.com/google/benchmark.git' - template: cmake-configure-build.yml parameters: hostArch: ${{ parameters.hostArch }} diff --git a/azure-devops/checkout-submodule.yml b/azure-devops/checkout-submodule.yml new file mode 100644 index 0000000000..3822543e9d --- /dev/null +++ b/azure-devops/checkout-submodule.yml @@ -0,0 +1,31 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +parameters: +- name: enabled + type: boolean +- name: path + type: string +- name: url + type: string +steps: +- task: PowerShell@2 + displayName: 'Checkout ${{ parameters.path }} Submodule' + condition: and(succeeded(), ${{ parameters.enabled }}) + inputs: + targetType: inline + script: | + $submodule = '${{ parameters.path }}' + $rawStatus = git submodule status --cached $submodule + $sha = $rawStatus -replace '^[ \-+]([0-9a-f]+) .*$', '$1' + cd $submodule + git init + if ((git remote) -eq $null) { + git remote add submodule-upstream ${{ parameters.url }} + } + git fetch --filter=tree:0 --depth=1 submodule-upstream $sha + if ($submodule -eq 'llvm-project') { + git sparse-checkout set --sparse-index libcxx/test libcxx/utils/libcxx llvm/utils/lit + } + git reset --quiet --hard FETCH_HEAD + git clean --quiet -x -d -f -f diff --git a/azure-devops/checkout-submodules.yml b/azure-devops/checkout-submodules.yml deleted file mode 100644 index e25ffc9c5e..0000000000 --- a/azure-devops/checkout-submodules.yml +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -parameters: -- name: buildBenchmarks - type: boolean -- name: skipTesting - type: boolean -steps: -- task: PowerShell@2 - displayName: 'Get submodule SHAs' - timeoutInMinutes: 1 - inputs: - targetType: inline - script: | - $submoduleVarNames = [ordered]@{ - 'llvm-project' = 'llvmSHAVar'; - 'boost-math' = 'boostMathSHAVar'; - 'benchmarks/google-benchmark' = 'googleBenchmarkSHAVar'; - } - foreach ($submodule in $submoduleVarNames.Keys) { - $varName = $submoduleVarNames[$submodule] - $rawStatus = git submodule status --cached $submodule - $sha = $rawStatus -replace '^[ \-+]([0-9a-f]+) .*$', '$1' - Write-Host "##vso[task.setvariable variable=$varName]$sha" - } -- script: | - if not exist "llvm-project" ( - mkdir llvm-project - ) - cd llvm-project - - if not exist ".git" ( - del /S /Q * - git init - ) - - git remote get-url llvm - if errorlevel 1 ( - git remote add llvm https://github.com/llvm/llvm-project.git - ) - - git fetch --filter=tree:0 --depth=1 llvm $(llvmSHAVar) - git sparse-checkout set --sparse-index libcxx/test libcxx/utils/libcxx llvm/utils/lit - git reset --quiet --hard FETCH_HEAD - git clean --quiet -x -d -f -f - displayName: "Checkout LLVM source" - condition: and(succeeded(), not(${{ parameters.skipTesting }})) -- script: | - if not exist "boost-math" ( - mkdir boost-math - ) - cd boost-math - - if not exist ".git" ( - del /S /Q * - git init - ) - - git remote get-url boostorg - if errorlevel 1 ( - git remote add boostorg https://github.com/boostorg/math.git - ) - - git fetch --filter=tree:0 --depth=1 boostorg $(boostMathSHAVar) - git reset --quiet --hard FETCH_HEAD - git clean --quiet -x -d -f -f - displayName: "Checkout boost-math source" -- script: | - cd benchmarks - if not exist "google-benchmark" ( - mkdir google-benchmark - ) - cd google-benchmark - - if not exist ".git" ( - del /S /Q * - git init - ) - - git remote get-url googlebenchmark - if errorlevel 1 ( - git remote add googlebenchmark https://github.com/google/benchmark.git - ) - - git fetch --filter=tree:0 --depth=1 googlebenchmark $(googleBenchmarkSHAVar) - git reset --quiet --hard FETCH_HEAD - git clean --quiet -x -d -f -f - displayName: "Checkout google benchmark source" - condition: and(succeeded(), ${{ parameters.buildBenchmarks }})