azure-sdk-for-cpp/eng/pipelines/templates/jobs/ci.tests.yml
Daniel Jurek c534a1e160
Cognitive Matrix Consolidation (#2947)
* Refactor template to use multiple builds on the same machine resetting the machine and runtime varaibles along the way

Move template expression out of default matrix parameters

Remove extra reference to ci/jobs.yml

Remove unnecessary ci.yml, change param declaration in devops-variables-set.yml

Heredoc

Fix set/reset scripts after testing with devops outputs

-ErrorAction Ignore

Smaller matrix

OsVMImage comes from machine, not parameters

Add Ubuntu 20 to matrix

Remove checkout: self, it is implied

Move machine-setup steps outside of loop

CODE_COVERAGE handling

tab

Remove creation of CODE_COVERAGE

Use AptDependencies and add apt update to dependency install step

Remove extra preparation steps

Enable code coverage check scenario

Add MacOS 11

Disable vcpkg cache

Coverage configuration

Pass parameter properly

bool -> boolean

Install coverage tools if it's possible that coverage may run

More logging on code coverage

Show contents of Makefile

One vcpkg to build them all

Verbose

SourcesDirectory

Nesting VcpkgInstall

workingDirectory for vcpkg install

AptDependencies

complete the conditional

Enable all matrix entries

sudo

Remove extra chatter

More scrubbing post-build to help with Windows scenarios

sudo echo

Get-ChildItem

ErrorAction

sudo sh -c

More ErrorAction

output sourceListFile

Disable additional sources.list

Install coverage tools when used for coverage

COndition

Do not build testing for Windows arm64

Correct path for coverage tools

ne -> eq

Add more scenarios to the matrix

Remove libxml2

Add MacOS 10.15 to matrix

Revert "Remove libxml2"

This reverts commit 178af8b89abb21ee84dbcd25b4d54bd90ec1d44c.

Add libxml2 to MacOS 10.15 matrix entry

Display name decorator, refine the matrix

Remove OsVmImage variable

Add commentary to tests about matrix

Rebalance matrix, nest EnvVars, DisplayNameDecorator

Correct parameter access

AptDependencies

Ensure building for WindowsStore in UWP builds, Only build tests for debug builds in altered matrix entires, Linux build type specified as environment variable

Rebalance matrix for better timing

Remove all instances of libxml2 in vcpkg dependencies

Move common devops tasks to eng/common

Set eng/common paths in pipelines

Revert "Remove all instances of libxml2 in vcpkg dependencies"

This reverts commit 35ffbc7aac87f400fdf3351076346750c1c750ed.

https://github.com/Azure/azure-sdk-for-cpp/issues/2946

Permit words like iname in more pipeline .yml files

Remove libxml2 from vcpkg dependencies for Windows

Perf test matrix maxParallel: 10

Validate

apt install first

apt install first

maxParallel: 12

-j 8

-j 10

Use matrix generator

Add expected parameters

Move parameters to appropriate file, fix cloud spec

Specify correct platform matrix location

DependsOn

Platform matrix

Remove DisplayNameDecorator, try more clang information

Rapid iteration matrix

clang --version

install clang-11

Use correct pool

Use full matrix, revert additional logic in jobs/ci.yml

* Review feedback: newline

* Review feedback: Test in release, too

* Remove DisplayNameDecorator (it was useful when we were putting multiple builds into a single job, now it is redundant)

* Remove displayNames

* Matrix review feedback

* Conditions

* Rename ci.yml -> ci.tests.yml
2021-10-22 13:49:10 -07:00

139 lines
5.2 KiB
YAML

parameters:
- name: Artifacts
type: object
default: []
- name: ServiceDirectory
type: string
default: not-specified
- name: TestPipeline
type: boolean
default: false
- name: CtestRegex
type: string
default: .*
- name: CoverageReportPath
type: string
default: 'sdk/*/*/*cov_xml.xml'
- name: CoverageEnabled
type: boolean
default: true
- name: Matrix
type: string
# Supplied by archetype-sdk-tests-generate.yml dynamic matrix generator
- name: CloudConfig
type: object
default: {}
# Supplied by archetype-sdk-tests-generate.yml dynamic matrix generator.
# Must be wired up to ensure population of parameters.Matrix
- name: DependsOn
type: string
default: ''
# Supplied by archetype-sdk-tests-generate.yml dynamic matrix generator
- name: UsePlatformContainer
type: boolean
default: false
jobs:
- job:
displayName: "Validate"
dependsOn: ${{ parameters.DependsOn }}
condition: and(succeededOrFailed(), ne(variables['Skip.Test'], 'true'), ne(${{ parameters.Matrix }}, '{}'))
strategy:
matrix: $[ ${{ parameters.Matrix }} ]
maxParallel: 12
pool:
vmImage: $(OSVmImage)
name: $(Pool)
variables:
- name: CMOCKA_XML_FILE
value: "%g-test-results.xml"
- name: CMOCKA_MESSAGE_OUTPUT
value: "xml"
- name: BuildArgs
value: ""
- name: CmakeEnvArg
value: ""
- name: CmakeArgs
value: ""
- name: AZURE_TEST_MODE
value: "PLAYBACK"
steps:
- template: /eng/common/pipelines/templates/steps/verify-agent-os.yml
parameters:
AgentImage: $(OsVmImage)
- pwsh: sudo apt update && sudo apt install -y $(AptDependencies)
condition: and(succeeded(), ne(variables['AptDependencies'], ''))
displayName: Install dependencies from apt
- template: /eng/pipelines/templates/steps/vcpkg.yml
parameters:
DependenciesVariableName: VcpkgInstall
# Validate all the files are formatted correctly according to the
# .clang-format file. This step runs on linux only only and assumes that
# clang-format-11 is installed.
- bash: |
# Run clang-format recursively on each source and header file within the repo sdk folder.
echo "Check clang-formatting"
clang-format --version
find ./sdk \( -iname '*.hpp' -o -iname '*.cpp' \) ! -iname 'json.hpp' -exec clang-format -i {} \;
if [[ `git status | grep modified | awk '{print $2}'` ]]; then
echo Some files were not formatted correctly according to the .clang-format file.
echo Please run clang-format version 10 or greater to fix the issue by using this bash command at the root of the repo:
echo "find ./sdk \( -iname '*.hpp' -o -iname '*.cpp' \) ! -iname 'json.hpp' -exec clang-format -i {} \;"
echo ""
echo "List of files not formatted correctly:"
git status | grep modified | awk '{print $2}'
exit 1
fi
echo Success, all files are formatted correctly according to the .clang-format file.
exit 0
displayName: Validate Clang Format
condition: and(succeededOrFailed(), eq(variables['CHECK_CLANG_FORMAT'], 1))
- ${{ each artifact in parameters.Artifacts }}:
- template: /eng/common/pipelines/templates/steps/set-test-pipeline-version.yml
parameters:
PackageName: ${{ artifact.Name }}
ServiceDirectory: ${{ parameters.ServiceDirectory }}
TestPipeline: ${{ parameters.TestPipeline }}
- template: /eng/pipelines/templates/steps/cmake-build.yml
parameters:
GenerateArgs: "$(CmakeArgs)"
BuildArgs: "$(BuildArgs)"
Env: "$(CmakeEnvArg)"
- script: ctest -C Debug -V --tests-regex ${{ parameters.CtestRegex }}
workingDirectory: build
- ${{ if eq(parameters.CoverageEnabled, true) }}:
- pwsh: |
$toolsDirectory = "$(Agent.TempDirectory)/coveragetools"
dotnet tool install -g dotnet-reportgenerator-globaltool
dotnet tool install dotnet-reportgenerator-globaltool --tool-path $toolsDirectory
Write-Host "##vso[task.setvariable variable=ToolsDirectory]$toolsDirectory"
displayName: Install coverage tools
condition: and(succeeded(), eq(variables['CODE_COVERAGE'], 'enabled'))
# Make coverage targets (specified in coverage_targets.txt) and assemble
# coverage report
- bash: |
make VERBOSE=1 `cat ${{ parameters.ServiceDirectory }}-targets-coverage.txt`
$(ToolsDirectory)/reportgenerator "-reports:${{ parameters.CoverageReportPath }}" "-targetdir:." "-reporttypes:Cobertura"
workingDirectory: build
displayName: Generate Code Coverage Data
condition: and(succeededOrFailed(), eq(variables['CODE_COVERAGE'], 'enabled'))
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/**/Cobertura.xml'
displayName: Publish Code Coverage to DevOps
condition: and(succeededOrFailed(), eq(variables['CODE_COVERAGE'], 'enabled'))