FeaturizersLibrary/CI/BuildAndTest.template.yaml

124 строки
6.0 KiB
YAML

parameters:
agent_pool: ''
operating_system: '' # Windows|Linux
configuration: ''
# This is a parameter not because it will be configued by the caller, but rather because arrays can be
# defined here and not in variables.
test_types:
'UnitTests': ' /code_coverage'
'FunctionalTests': ''
'IntegrationTests': ''
'SystemTests': ''
'LocalEndToEndTests': ''
# 'EndToEndTests': ''
# 'BuildVerificationTests': ''
# 'PerformanceTests: ''
stages:
- stage: BuildAndTest_${{ parameters.operating_system }}_${{ parameters.configuration}}_Stage
displayName: "${{ parameters.operating_system }} - ${{ parameters.configuration }}: "
dependsOn: [] # No dependencies
jobs:
- job: BuildAndTest_${{ parameters.operating_system }}_${{ parameters.configuration}}_Job
# In the UX, this display name contains redundant info (the OS and config appear twice). However, it
# needs to be here to ensure that the information appears in the status email messages.
displayName: "Build and Test (${{ parameters.operating_system }} - ${{ parameters.configuration }})"
pool:
vmImage: "${{ parameters.agent_pool }}"
workspace:
clean: all
steps:
# These steps are an ugly hack to set Azure DevOps variables conditionally. It really seems like there should be a better way to do this.
- ${{ if eq(parameters.operating_system, 'Windows') }}:
- script: |-
set _AZURE_ACTIVATE_SCRIPT=Activate.cmd
echo ##vso[task.setvariable variable=azure_activate_script]%_AZURE_ACTIVATE_SCRIPT%
set _AZURE_SCRIPT_EXTENSION=.cmd
echo ##vso[task.setvariable variable=azure_script_extension]%_AZURE_SCRIPT_EXTENSION%
set _AZURE_DISPLAY_ALL_ENVIRONMENT_VARS=set
echo ##vso[task.setvariable variable=azure_display_all_environment_vars]%_AZURE_DISPLAY_ALL_ENVIRONMENT_VARS%
set _AZURE_BOOTSTRAP_COMMAND=bootstrap.cmd
echo ##vso[task.setvariable variable=azure_bootstrap_command]%_AZURE_BOOTSTRAP_COMMAND%
echo ##vso[task.setvariable variable=azure_agent_temp_directory]%AGENT_TEMPDIRECTORY%
echo ##vso[task.setvariable variable=azure_artifacts_directory]%BUILD_ARTIFACTSTAGINGDIRECTORY%
displayName: "[IMPL] Environment-Specific Variables"
- ${{ if eq(parameters.operating_system, 'Linux') }}:
- script: |-
export _AZURE_ACTIVATE_SCRIPT=". ./Activate.sh"
echo "##vso[task.setvariable variable=azure_activate_script]${_AZURE_ACTIVATE_SCRIPT}"
export _AZURE_SCRIPT_EXTENSION=.sh
echo "##vso[task.setvariable variable=azure_script_extension]${_AZURE_SCRIPT_EXTENSION}"
export _AZURE_DISPLAY_ALL_ENVIRONMENT_VARS=export
echo "##vso[task.setvariable variable=azure_display_all_environment_vars]${_AZURE_DISPLAY_ALL_ENVIRONMENT_VARS}"
export _AZURE_BOOTSTRAP_COMMAND="sudo ./bootstrap.sh"
echo "##vso[task.setvariable variable=azure_bootstrap_command]${_AZURE_BOOTSTRAP_COMMAND}"
echo "##vso[task.setvariable variable=azure_agent_temp_directory]${AGENT_TEMPDIRECTORY}"
echo "##vso[task.setvariable variable=azure_artifacts_directory]${BUILD_ARTIFACTSTAGINGDIRECTORY}"
displayName: "[IMPL] Environment-Specific Variables"
# Continue with standard processing
- script: |-
echo "operating_system - ${{ parameters.operating_system }}"
echo "configuration - ${{ parameters.configuration }}"
echo "activate_script - $(azure_activate_script)"
echo "script_extension - $(azure_script_extension)"
echo "display_all_environment_vars - $(azure_display_all_environment_vars)"
echo "bootstrap_command - $(azure_bootstrap_command)"
echo "agent_temp_directory - $(azure_agent_temp_directory)"
displayName: "[DEBUG] Configuration Values"
- script: |-
$(azure_display_all_environment_vars)
displayName: "[DEBUG] Environment Variables"
- script: |-
$(azure_bootstrap_command) $(azure_agent_temp_directory) /verbose
displayName: "<Bootstrap>"
timeoutInMinutes: 180
# TODO: Code formatting
- script: |-
$(azure_activate_script) ${{ parameters.configuration }} && Builder$(azure_script_extension) Execute . "$(azure_artifacts_directory)/Builder" /verbose
displayName: "<Builder>"
timeoutInMinutes: 180
- script: |-
$(azure_activate_script) ${{ parameters.configuration }} && Tester$(azure_script_extension) MatchAllTests . UnitTests /verbose
displayName: "<Tester (MatchAllTests) - UnitTests>"
timeoutInMinutes: 1800
condition: succeededOrFailed()
- ${{ each test_type in parameters.test_types }}:
- script: |-
$(azure_activate_script) ${{ parameters.configuration }} && Tester$(azure_script_extension) TestAll . "$(azure_artifacts_directory)/Tester/${{ test_type.key }}" ${{ test_type.key }} ${{ test_type.value }} /verbose
displayName: '<Tester - ${{ test_type.key }}>'
timeoutInMinutes: 180
condition: succeededOrFailed()
- task: PublishPipelineArtifact@0
displayName: 'Publish Artifacts'
inputs:
targetPath: $(azure_artifacts_directory)
artifactName: '${{ parameters.operating_system }} - ${{ parameters.configuration }}'
condition: succeededOrFailed()
timeoutInMinutes: 180