platform-build-run-steps.yml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. ## @file
  2. # File 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. - name: tool_chain_tag
  11. type: string
  12. default: ''
  13. - name: build_pkg
  14. type: string
  15. default: ''
  16. - name: build_target
  17. type: string
  18. default: ''
  19. - name: build_arch
  20. type: string
  21. default: ''
  22. - name: build_file
  23. type: string
  24. default: ''
  25. - name: build_flags
  26. type: string
  27. default: ''
  28. - name: run_flags
  29. type: string
  30. default: ''
  31. - name: extra_install_step
  32. type: stepList
  33. default: []
  34. - name: usePythonVersion
  35. type: string
  36. default: ''
  37. steps:
  38. - bash: |
  39. echo "##vso[task.prependpath]${HOME}/.local/bin"
  40. echo "new PATH=${PATH}"
  41. displayName: Set PATH
  42. condition: eq('${{ parameters.tool_chain_tag }}', 'GCC5')
  43. - checkout: self
  44. clean: true
  45. fetchDepth: 1
  46. - task: UsePythonVersion@0
  47. inputs:
  48. versionSpec: ${{ parameters.usePythonVersion }}
  49. architecture: "x64"
  50. condition: ne('${{ parameters.usePythonVersion }}', '')
  51. - script: pip install -r pip-requirements.txt --upgrade
  52. displayName: 'Install/Upgrade pip modules'
  53. # Set default
  54. - bash: echo "##vso[task.setvariable variable=pkg_count]${{ 1 }}"
  55. # Fetch the target branch so that pr_eval can diff them.
  56. # Seems like azure pipelines/github changed checkout process in nov 2020.
  57. - script: git fetch origin $(System.PullRequest.targetBranch)
  58. displayName: fetch target branch
  59. condition: eq(variables['Build.Reason'], 'PullRequest')
  60. # trim the package list if this is a PR
  61. - task: CmdLine@1
  62. displayName: Check if ${{ parameters.build_pkg }} need testing
  63. inputs:
  64. filename: stuart_pr_eval
  65. arguments: -c ${{ parameters.build_file }} -t ${{ parameters.build_target}} -a ${{ parameters.build_arch}} --pr-target origin/$(System.PullRequest.targetBranch) --output-count-format-string "##vso[task.setvariable variable=pkg_count;isOutpout=true]{pkgcount}"
  66. condition: eq(variables['Build.Reason'], 'PullRequest')
  67. # Setup repo
  68. - task: CmdLine@1
  69. displayName: Setup
  70. inputs:
  71. filename: stuart_setup
  72. arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} -t ${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}}
  73. condition: and(gt(variables.pkg_count, 0), succeeded())
  74. # Stuart Update
  75. - task: CmdLine@1
  76. displayName: Update
  77. inputs:
  78. filename: stuart_update
  79. arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} -t ${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}}
  80. condition: and(gt(variables.pkg_count, 0), succeeded())
  81. # build basetools
  82. # do this after setup and update so that code base dependencies
  83. # are all resolved.
  84. - template: basetools-build-steps.yml
  85. parameters:
  86. tool_chain_tag: ${{ parameters.tool_chain_tag }}
  87. # Potential Extra steps
  88. - ${{ parameters.extra_install_step }}
  89. # Build
  90. - task: CmdLine@1
  91. displayName: Build
  92. inputs:
  93. filename: stuart_build
  94. arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} TARGET=${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}}
  95. condition: and(gt(variables.pkg_count, 0), succeeded())
  96. # Run
  97. - task: CmdLine@1
  98. displayName: Run to shell
  99. inputs:
  100. filename: stuart_build
  101. arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} TARGET=${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}} ${{ parameters.run_flags }} --FlashOnly
  102. condition: and(and(gt(variables.pkg_count, 0), succeeded()), eq(variables['Run'], true))
  103. timeoutInMinutes: 1
  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. BASETOOLS_BUILD*.*
  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()