pr-gate-steps.yml 5.0 KB

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