pr-gate-steps.yml 5.1 KB

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