pr-gate-steps.yml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. ## @file
  2. # File templates/pr-gate-steps.yml
  3. #
  4. # template file containing the steps to build
  5. #
  6. # Copyright (c) Microsoft Corporation.
  7. # SPDX-License-Identifier: BSD-2-Clause-Patent
  8. ##
  9. parameters:
  10. tool_chain_tag: ''
  11. build_pkgs: ''
  12. build_targets: ''
  13. build_archs: ''
  14. usePythonVersion: ''
  15. extra_install_step: []
  16. steps:
  17. - bash: |
  18. echo "##vso[task.prependpath]${HOME}/.local/bin"
  19. echo "new PATH=${PATH}"
  20. displayName: Set PATH
  21. condition: eq('${{ parameters.tool_chain_tag }}', 'GCC5')
  22. - checkout: self
  23. clean: true
  24. fetchDepth: 1
  25. - task: UsePythonVersion@0
  26. inputs:
  27. versionSpec: ${{ parameters.usePythonVersion }}
  28. architecture: "x64"
  29. condition: ne('${{ parameters.usePythonVersion }}', '')
  30. - script: pip install -r pip-requirements.txt --upgrade
  31. displayName: 'Install/Upgrade pip modules'
  32. # Set default
  33. - bash: |
  34. echo "##vso[task.setvariable variable=pkgs_to_build]${{ parameters.build_pkgs }}"
  35. echo "##vso[task.setvariable variable=pkg_count]${{ 1 }}"
  36. # Fetch the target branch so that pr_eval can diff them.
  37. # Seems like azure pipelines/github changed checkout process in nov 2020.
  38. - script: git fetch origin $(System.PullRequest.targetBranch)
  39. displayName: fetch target branch
  40. condition: eq(variables['Build.Reason'], 'PullRequest')
  41. - ${{ parameters.extra_install_step }}
  42. # trim the package list if this is a PR
  43. - task: CmdLine@1
  44. displayName: Check if ${{ parameters.build_pkgs }} need testing
  45. inputs:
  46. filename: stuart_pr_eval
  47. arguments: -c .pytool/CISettings.py -p ${{ parameters.build_pkgs }} --pr-target origin/$(System.PullRequest.targetBranch) --output-csv-format-string "##vso[task.setvariable variable=pkgs_to_build;isOutpout=true]{pkgcsv}" --output-count-format-string "##vso[task.setvariable variable=pkg_count;isOutpout=true]{pkgcount}"
  48. condition: eq(variables['Build.Reason'], 'PullRequest')
  49. # install spell check prereqs
  50. - template: spell-check-prereq-steps.yml
  51. # Build repo
  52. - task: CmdLine@1
  53. displayName: Setup ${{ parameters.build_pkgs }} ${{ parameters.build_archs}}
  54. inputs:
  55. filename: stuart_setup
  56. arguments: -c .pytool/CISettings.py -p $(pkgs_to_build) -t ${{ parameters.build_targets}} -a ${{ parameters.build_archs}} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}}
  57. condition: and(gt(variables.pkg_count, 0), succeeded())
  58. - task: CmdLine@1
  59. displayName: Update ${{ parameters.build_pkgs }} ${{ parameters.build_archs}}
  60. inputs:
  61. filename: stuart_update
  62. arguments: -c .pytool/CISettings.py -p $(pkgs_to_build) -t ${{ parameters.build_targets}} -a ${{ parameters.build_archs}} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}}
  63. condition: and(gt(variables.pkg_count, 0), succeeded())
  64. # build basetools
  65. # do this after setup and update so that code base dependencies
  66. # are all resolved.
  67. - template: basetools-build-steps.yml
  68. parameters:
  69. tool_chain_tag: ${{ parameters.tool_chain_tag }}
  70. - task: CmdLine@1
  71. displayName: Build and Test ${{ parameters.build_pkgs }} ${{ parameters.build_archs}}
  72. inputs:
  73. filename: stuart_ci_build
  74. arguments: -c .pytool/CISettings.py -p $(pkgs_to_build) -t ${{ parameters.build_targets}} -a ${{ parameters.build_archs}} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}}
  75. condition: and(gt(variables.pkg_count, 0), succeeded())
  76. # Publish Test Results to Azure Pipelines/TFS
  77. - task: PublishTestResults@2
  78. displayName: 'Publish junit test results'
  79. continueOnError: true
  80. condition: and( succeededOrFailed(),gt(variables.pkg_count, 0))
  81. inputs:
  82. testResultsFormat: 'JUnit' # Options: JUnit, NUnit, VSTest, xUnit
  83. testResultsFiles: 'Build/TestSuites.xml'
  84. #searchFolder: '$(System.DefaultWorkingDirectory)' # Optional
  85. mergeTestResults: true # Optional
  86. testRunTitle: $(System.JobName) # Optional
  87. #buildPlatform: # Optional
  88. #buildConfiguration: # Optional
  89. publishRunAttachments: true # Optional
  90. # Publish Test Results to Azure Pipelines/TFS
  91. - task: PublishTestResults@2
  92. displayName: 'Publish host based test results for $(System.JobName)'
  93. continueOnError: true
  94. condition: and( succeededOrFailed(), gt(variables.pkg_count, 0))
  95. inputs:
  96. testResultsFormat: 'JUnit' # Options: JUnit, NUnit, VSTest, xUnit
  97. testResultsFiles: 'Build/**/*.result.xml'
  98. #searchFolder: '$(System.DefaultWorkingDirectory)' # Optional
  99. mergeTestResults: false # Optional
  100. testRunTitle: ${{ parameters.build_pkgs }} # Optional
  101. #buildPlatform: # Optional
  102. #buildConfiguration: # Optional
  103. publishRunAttachments: true # Optional
  104. # Copy the build logs to the artifact staging directory
  105. - task: CopyFiles@2
  106. displayName: "Copy build logs"
  107. inputs:
  108. targetFolder: '$(Build.ArtifactStagingDirectory)'
  109. SourceFolder: 'Build'
  110. contents: |
  111. BUILDLOG_*.txt
  112. BUILDLOG_*.md
  113. CI_*.txt
  114. CI_*.md
  115. CISETUP.txt
  116. SETUPLOG.txt
  117. UPDATE_LOG.txt
  118. PREVALLOG.txt
  119. TestSuites.xml
  120. **/BUILD_TOOLS_REPORT.html
  121. **/OVERRIDELOG.TXT
  122. coverage.xml
  123. flattenFolders: true
  124. condition: succeededOrFailed()
  125. # Publish build artifacts to Azure Artifacts/TFS or a file share
  126. - task: PublishBuildArtifacts@1
  127. continueOnError: true
  128. displayName: "Publish build logs"
  129. inputs:
  130. pathtoPublish: '$(Build.ArtifactStagingDirectory)'
  131. artifactName: 'Build Logs $(System.JobName)'
  132. condition: succeededOrFailed()