]> git.proxmox.com Git - mirror_edk2.git/commitdiff
.azurepipelines: Add Platform CI template
authorSean Brogan <sean.brogan@microsoft.com>
Wed, 8 Apr 2020 04:35:30 +0000 (21:35 -0700)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 28 Apr 2020 18:07:59 +0000 (18:07 +0000)
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2570

Add template for Platform CI steps for a Pytools based build.
Add README to describe the template and how to use it.
Add helpful information for working with azurepipelines, templates, and
lessons learned.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Shenglei Zhang <shenglei.zhang@intel.com>
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
.azurepipelines/ReadMe.md [new file with mode: 0644]
.azurepipelines/templates/ReadMe.md [new file with mode: 0644]
.azurepipelines/templates/platform-build-run-steps.yml [new file with mode: 0644]

diff --git a/.azurepipelines/ReadMe.md b/.azurepipelines/ReadMe.md
new file mode 100644 (file)
index 0000000..cf57d28
--- /dev/null
@@ -0,0 +1,50 @@
+# Azure DevOps Pipelines\r
+\r
+These yml files are used to provide CI builds using the Azure DevOps Pipeline Service.\r
+Most of the CI leverages edk2-pytools to support cross platform building and execution.\r
+\r
+## Core CI\r
+\r
+Focused on building and testing all packages in Edk2 without an actual target platform.\r
+\r
+See `.pytools/ReadMe.py` for more details\r
+\r
+## Platform CI\r
+\r
+Focused on building a single target platform and confirming functionality on that platform.\r
+\r
+## Conventions\r
+\r
+* Files extension should be *.yml.  *.yaml is also supported but in Edk2 we use those for our package configuration.\r
+* Platform CI files should be in the `<PlatformPkg>/.azurepipelines` folder.\r
+* Core CI files are in the root folder.\r
+* Shared templates are in the `templates` folder.\r
+* Top level CI files should be named `<host os>-<tool_chain_tag>.yml`\r
+\r
+## Links\r
+\r
+* Basic Azure Landing Site - https://docs.microsoft.com/en-us/azure/devops/pipelines/?view=azure-devops\r
+* Pipeline jobs - https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml\r
+* Pipeline yml scheme - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema%2Cparameter-schema\r
+* Pipeline expression - https://docs.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops\r
+* PyTools - https://github.com/tianocore/edk2-pytool-extensions and https://github.com/tianocore/edk2-pytool-library\r
+\r
+## Lessons Learned\r
+\r
+### Templates and parameters\r
+\r
+They are great but evil.  If they are used as part of determining the steps of a build they must resolve before the build starts.  They can not use variables set in a yml or determined as part of a matrix.  If they are used in a step then they can be bound late.\r
+\r
+### File matching patterns\r
+\r
+On Linux this can hang if there are too many files in the search list.\r
+\r
+### Templates and file splitting\r
+\r
+Suggestion is to do one big yaml file that does what you want for one of your targets.  Then do the second one and find the deltas.  From that you can start to figure out the right split of files, steps, jobs.\r
+\r
+### Conditional steps\r
+\r
+If you want the step to show up in the log but not run, use a step conditional. This is great when a platform doesn't currently support a feature but you want the builders to know that the features exists and maybe someday it will.\r
+\r
+If you want the step to not show up use a template step conditional wrapper.  Beware this will be evaluated early (at build start).  This can hide things not needed on a given OS for example.\r
diff --git a/.azurepipelines/templates/ReadMe.md b/.azurepipelines/templates/ReadMe.md
new file mode 100644 (file)
index 0000000..fa433e3
--- /dev/null
@@ -0,0 +1,59 @@
+# CI Templates\r
+\r
+This folder contains azure pipeline yml templates for "Core" and "Platform" Continuous Integration and PR validation.\r
+\r
+## Common CI templates\r
+\r
+### basetools-build-steps.yml\r
+\r
+This template compiles the Edk2 basetools from source.  The steps in this template are\r
+conditional and will only run if variable `pkg_count` is greater than 0.\r
+\r
+It also has two conditional steps only used when the toolchain contains GCC. These two steps\r
+use `apt` to update the system packages and add those necessary for Edk2 builds.\r
+\r
+## Core CI templates\r
+\r
+### pr-gate-build-job.yml\r
+\r
+This templates contains the jobs and most importantly the matrix of which packages and\r
+targets to run for Core CI.\r
+\r
+### pr-gate-steps.yml\r
+\r
+This template is the main Core CI template.  It controls all the steps run and is responsible for most functionality of the Core CI process.  This template sets\r
+the `pkg_count` variable using the `stuart_pr_eval` tool when the\r
+build type is "pull request"\r
+\r
+### spell-check-prereq-steps.yml\r
+\r
+This template installs the node based tools used by the spell checker plugin. The steps\r
+in this template are conditional and will only run if variable `pkg_count` is greater than 0.\r
+\r
+## Platform CI templates\r
+\r
+### platform-build-run-steps.yml\r
+\r
+This template makes heavy use of pytools to build and run a platform in the Edk2 repo\r
+\r
+Also uses basetools-build-steps.yml to compile basetools\r
+\r
+#### Special Notes\r
+\r
+* For a build type of pull request it will conditionally build if the patches change files that impact the platform.\r
+  * uses `stuart_pr_eval` to determine impact\r
+* For manual builds or CI builds it will always build the platform\r
+* It compiles basetools from source\r
+* Will use `stuart_build --FlashOnly` to attempt to run the built image if the `Run` parameter is set.\r
+* See the parameters block for expected configuration options\r
+* Parameter `extra_install_step` allows the caller to insert extra steps.  This is useful if additional dependencies, tools, or other things need to be installed.  Here is an example of installing qemu on Windows.\r
+\r
+    ``` yaml\r
+    steps:\r
+    - template: ../../.azurepipelines/templates/build-run-steps.yml\r
+      parameters:\r
+        extra_install_step:\r
+        - powershell: choco install qemu; Write-Host "##vso[task.prependpath]c:\Program Files\qemu"\r
+          displayName: Install QEMU and Set QEMU on path # friendly name displayed in the UI\r
+          condition: and(gt(variables.pkg_count, 0), succeeded())\r
+    ```\r
diff --git a/.azurepipelines/templates/platform-build-run-steps.yml b/.azurepipelines/templates/platform-build-run-steps.yml
new file mode 100644 (file)
index 0000000..ebf674b
--- /dev/null
@@ -0,0 +1,134 @@
+\r
+## @file\r
+# File steps.yml\r
+#\r
+# template file containing the steps to build\r
+#\r
+# Copyright (c) Microsoft Corporation.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+##\r
+\r
+parameters:\r
+- name: tool_chain_tag\r
+  type: string\r
+  default: ''\r
+- name: build_pkg\r
+  type: string\r
+  default: ''\r
+- name: build_target\r
+  type: string\r
+  default: ''\r
+- name: build_arch\r
+  type: string\r
+  default: ''\r
+- name: build_file\r
+  type: string\r
+  default: ''\r
+- name: build_flags\r
+  type: string\r
+  default: ''\r
+- name: run_flags\r
+  type: string\r
+  default: ''\r
+\r
+- name: extra_install_step\r
+  type: stepList\r
+  default: []\r
+\r
+steps:\r
+- checkout: self\r
+  clean: true\r
+  fetchDepth: 1\r
+\r
+- task: UsePythonVersion@0\r
+  inputs:\r
+    versionSpec: "3.8.x"\r
+    architecture: "x64"\r
+\r
+- script: pip install -r pip-requirements.txt --upgrade\r
+  displayName: 'Install/Upgrade pip modules'\r
+\r
+# Set default\r
+- bash: echo "##vso[task.setvariable variable=pkg_count]${{ 1 }}"\r
+\r
+# trim the package list if this is a PR\r
+- task: CmdLine@1\r
+  displayName: Check if ${{ parameters.build_pkg }} need testing\r
+  inputs:\r
+    filename: stuart_pr_eval\r
+    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}"\r
+  condition: eq(variables['Build.Reason'], 'PullRequest')\r
+\r
+ # Setup repo\r
+- task: CmdLine@1\r
+  displayName: Setup\r
+  inputs:\r
+    filename: stuart_setup\r
+    arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} -t ${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}}\r
+  condition: and(gt(variables.pkg_count, 0), succeeded())\r
+\r
+# Stuart Update\r
+- task: CmdLine@1\r
+  displayName: Update\r
+  inputs:\r
+    filename: stuart_update\r
+    arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} -t ${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}}\r
+  condition: and(gt(variables.pkg_count, 0), succeeded())\r
+\r
+# build basetools\r
+#   do this after setup and update so that code base dependencies\r
+#   are all resolved.\r
+- template: basetools-build-steps.yml\r
+  parameters:\r
+    tool_chain_tag: ${{ parameters.tool_chain_tag }}\r
+\r
+# Potential Extra steps\r
+- ${{ parameters.extra_install_step }}\r
+\r
+# Build\r
+- task: CmdLine@1\r
+  displayName: Build\r
+  inputs:\r
+    filename: stuart_build\r
+    arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} TARGET=${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}}\r
+  condition: and(gt(variables.pkg_count, 0), succeeded())\r
+\r
+# Run\r
+- task: CmdLine@1\r
+  displayName: Run to shell\r
+  inputs:\r
+    filename: stuart_build\r
+    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\r
+  condition: and(and(gt(variables.pkg_count, 0), succeeded()), eq(variables['Run'], true))\r
+  timeoutInMinutes: 1\r
+\r
+# Copy the build logs to the artifact staging directory\r
+- task: CopyFiles@2\r
+  displayName: "Copy build logs"\r
+  inputs:\r
+    targetFolder: "$(Build.ArtifactStagingDirectory)"\r
+    SourceFolder: "Build"\r
+    contents: |\r
+      BUILDLOG_*.txt\r
+      BUILDLOG_*.md\r
+      CI_*.txt\r
+      CI_*.md\r
+      CISETUP.txt\r
+      SETUPLOG.txt\r
+      UPDATE_LOG.txt\r
+      PREVALLOG.txt\r
+      TestSuites.xml\r
+      **/BUILD_TOOLS_REPORT.html\r
+      **/OVERRIDELOG.TXT\r
+      BASETOOLS_BUILD*.*\r
+    flattenFolders: true\r
+  condition: succeededOrFailed()\r
+\r
+# Publish build artifacts to Azure Artifacts/TFS or a file share\r
+- task: PublishBuildArtifacts@1\r
+  continueOnError: true\r
+  displayName: "Publish build logs"\r
+  inputs:\r
+    pathtoPublish: "$(Build.ArtifactStagingDirectory)"\r
+    artifactName: "Build Logs $(System.JobName)"\r
+  condition: succeededOrFailed()\r