From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-SN1-obe.outbound.protection.outlook.com (NAM04-SN1-obe.outbound.protection.outlook.com [40.92.11.75]) by mx.groups.io with SMTP id smtpd.web11.967.1586369640379429862 for ; Wed, 08 Apr 2020 11:14:00 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=P9qtQThu; spf=pass (domain: outlook.com, ip: 40.92.11.75, mailfrom: michael.kubacki@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YIS8JeqluMWd5KTjnpXhhbM8otmB/+tvoZXnGx2eE3KwrwB2hcnZAjScURF+Qbgm57NjTg8HB0mOZo7JT+sjYWsquw2imcgWAFVNI9+gQLXVBlUk1WfVePHS/7ZvQRbTCEsdV19zsrsKE97Hd24kNyS/0U+NEqG/Hha+VUNU7VAD4N6p3Zl8h54n1ej/2BQqaQdGyuhpuRO6J1KEq8LSjhLYlG6pfRERiv2iIXtb/Gll1ukWM6t01vmHnK+ggsv8uJmvZLcQegoogZ76fOxXxK3ACaBk0I9f96KxAy2TQ99XirV2uFDV34l3U3lKKzSyVJhIcO4u/VxHXImkcwhJcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OnitguHtjclyhL/BDIJU5uzKTiW1XuVGuAy40fRzuXY=; b=kK5pTrJ+vLAsjxe6u6aVEwUvYjJepLNHOwA6MP/Wgn56Vpjsdf0gSHyPPoUlqKcjDKzajKScxyEudaHLL0vn9E9UKy6yaIGE2uYOFqz1UWO1eDFsWZuD6fxEVh5KMXcFn/6cJTBUi3on8wSUqd2U7vudLLo1Al5zWRhZ8fBBg0GqPH3Sanq06avjG1CHtp0cljZhuOQaLBNzmf1VknfOmvQCa9faLqVCW8+v4BlY6wkki0yLTpZx9R75KFSk/3UUbIwZtCNOOn0hot0cGovb6AusWKh/sfQA45slHVaGHh3+TLz378cTnJDrgEOtuvqqBWZGr/w5vR4O99sHDqL9Jw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=outlook.com; dmarc=pass action=none header.from=outlook.com; dkim=pass header.d=outlook.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OnitguHtjclyhL/BDIJU5uzKTiW1XuVGuAy40fRzuXY=; b=P9qtQThu0p8L0NFgm7bga/yaBQRe2hhqaODPw55CKrp+QpF5BOzZlCF8fbxEAAdse1EiASgbdBN/EIVUd18E0nK3BEtF+FWCKmO58H+3+s5+hIDBdD1WYjT1s2dg1cCE7cwblisJmU5GyStCtvGClqBJDr6jDVfgNw9I2WQ67eYOQLnASvId8eiebKCyBHJM0RpZFt6b7oo1pH9RDyRIonHqWF7aoFlssy5C2cTPpXthUMMLRetD6Jzi39lOGCgc7c5REYaeIOMhgaGwxBg9a/+PP3+ZRRFCsBapxnP0GHUU26bB7YIGhQ4xT+J2W9ohbnBj8c/ANNHULwUQwiepTA== Received: from CO1NAM04FT025.eop-NAM04.prod.protection.outlook.com (10.152.90.52) by CO1NAM04HT161.eop-NAM04.prod.protection.outlook.com (10.152.91.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.19; Wed, 8 Apr 2020 18:13:59 +0000 Received: from MWHPR07MB3440.namprd07.prod.outlook.com (2a01:111:e400:7e4d::42) by CO1NAM04FT025.mail.protection.outlook.com (2a01:111:e400:7e4d::160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.19 via Frontend Transport; Wed, 8 Apr 2020 18:13:59 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:FA582DD030726678907BC777E33A11B053E4E6813853A37BAB6159CFB11C30F5;UpperCasedChecksum:B79A384179F175E448287418111F60E502D8ABD343928C446D803D144230304A;SizeAsReceived:7817;Count:49 Received: from MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::f5a7:e51b:e22a:959f]) by MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::f5a7:e51b:e22a:959f%7]) with mapi id 15.20.2878.022; Wed, 8 Apr 2020 18:13:59 +0000 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Sean Brogan , Bret Barkelew , Michael D Kinney , Liming Gao Subject: [PATCH v1 1/6] .azurepipelines: Add Platform CI template Date: Wed, 8 Apr 2020 11:13:22 -0700 Message-ID: X-Mailer: git-send-email 2.16.3.windows.1 In-Reply-To: <20200408181327.4324-1-michael.kubacki@outlook.com> References: <20200408181327.4324-1-michael.kubacki@outlook.com> X-ClientProxiedBy: MWHPR10CA0054.namprd10.prod.outlook.com (2603:10b6:300:2c::16) To MWHPR07MB3440.namprd07.prod.outlook.com (2603:10b6:301:69::28) Return-Path: michael.kubacki@outlook.com X-Microsoft-Original-Message-ID: <20200408181327.4324-2-michael.kubacki@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2001:4898:80e8:2:c970:b9b:c52f:94cf) by MWHPR10CA0054.namprd10.prod.outlook.com (2603:10b6:300:2c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.15 via Frontend Transport; Wed, 8 Apr 2020 18:13:58 +0000 X-Mailer: git-send-email 2.16.3.windows.1 X-Microsoft-Original-Message-ID: <20200408181327.4324-2-michael.kubacki@outlook.com> X-TMN: [pmQw+mq8PH5NrmsoLe80UJxhkT4QsvP8tyZSy1i3noMhUFvdDwQAeay6Vzpp5c1Z] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 368ddcc8-7f5a-4f16-52b8-08d7dbe89bc5 X-MS-TrafficTypeDiagnostic: CO1NAM04HT161: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tn5+8Ku3XoodUV1UQNjMXglvMyrW2b5X8kZIRRM/K5grgXr1g1tQoHJIUIN8fCFdmt62CkWysn2ie+qY6Cs2PdmOeJr+oLtewvMxVpjgngkApWpRgY96rVqVxF97JpS2V8entPQ+gSrW3ajBw87Z7LPfvWhy813t7FZGTxOsN2m7AtVFnNCTVfIZSToHseNCttUrYrzqzyh1L2w3l3Bu9yQv2rdy4NW/KU9sYxYU/bc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR07MB3440.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; X-MS-Exchange-AntiSpam-MessageData: mvPvo8l9IwSXsCxollTShCwBXH90WPwl3AWKG6oTX7GWV73bU3cli32fer9jKeXunV4bRNYg90Xrs7B1gGQEpX+7UVcj1+6QXFSzFfQSxG6Gxgq81cC4v1lGFYK+PmSE4/Sp4cUkfoz49o/yfztAFDVVXF7HzhnxKRy9oVO6jTV6isIInu8Aalv1rp+FTplDaCt4OyGGKC4Hw22qmMTK5w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 368ddcc8-7f5a-4f16-52b8-08d7dbe89bc5 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2020 18:13:59.0711 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1NAM04HT161 Content-Type: text/plain From: Sean Brogan 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 Cc: Bret Barkelew Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Sean Brogan --- .azurepipelines/ReadMe.md | 50 ++++++++ .azurepipelines/templates/ReadMe.md | 59 +++++++++ .azurepipelines/templates/platform-build-run-steps.yml | 134 ++++++++++++++++++++ 3 files changed, 243 insertions(+) diff --git a/.azurepipelines/ReadMe.md b/.azurepipelines/ReadMe.md new file mode 100644 index 000000000000..cf57d282c197 --- /dev/null +++ b/.azurepipelines/ReadMe.md @@ -0,0 +1,50 @@ +# Azure DevOps Pipelines + +These yml files are used to provide CI builds using the Azure DevOps Pipeline Service. +Most of the CI leverages edk2-pytools to support cross platform building and execution. + +## Core CI + +Focused on building and testing all packages in Edk2 without an actual target platform. + +See `.pytools/ReadMe.py` for more details + +## Platform CI + +Focused on building a single target platform and confirming functionality on that platform. + +## Conventions + +* Files extension should be *.yml. *.yaml is also supported but in Edk2 we use those for our package configuration. +* Platform CI files should be in the `/.azurepipelines` folder. +* Core CI files are in the root folder. +* Shared templates are in the `templates` folder. +* Top level CI files should be named `-.yml` + +## Links + +* Basic Azure Landing Site - https://docs.microsoft.com/en-us/azure/devops/pipelines/?view=azure-devops +* Pipeline jobs - https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml +* Pipeline yml scheme - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema%2Cparameter-schema +* Pipeline expression - https://docs.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops +* PyTools - https://github.com/tianocore/edk2-pytool-extensions and https://github.com/tianocore/edk2-pytool-library + +## Lessons Learned + +### Templates and parameters + +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. + +### File matching patterns + +On Linux this can hang if there are too many files in the search list. + +### Templates and file splitting + +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. + +### Conditional steps + +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. + +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. diff --git a/.azurepipelines/templates/ReadMe.md b/.azurepipelines/templates/ReadMe.md new file mode 100644 index 000000000000..fa433e3ef597 --- /dev/null +++ b/.azurepipelines/templates/ReadMe.md @@ -0,0 +1,59 @@ +# CI Templates + +This folder contains azure pipeline yml templates for "Core" and "Platform" Continuous Integration and PR validation. + +## Common CI templates + +### basetools-build-steps.yml + +This template compiles the Edk2 basetools from source. The steps in this template are +conditional and will only run if variable `pkg_count` is greater than 0. + +It also has two conditional steps only used when the toolchain contains GCC. These two steps +use `apt` to update the system packages and add those necessary for Edk2 builds. + +## Core CI templates + +### pr-gate-build-job.yml + +This templates contains the jobs and most importantly the matrix of which packages and +targets to run for Core CI. + +### pr-gate-steps.yml + +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 +the `pkg_count` variable using the `stuart_pr_eval` tool when the +build type is "pull request" + +### spell-check-prereq-steps.yml + +This template installs the node based tools used by the spell checker plugin. The steps +in this template are conditional and will only run if variable `pkg_count` is greater than 0. + +## Platform CI templates + +### platform-build-run-steps.yml + +This template makes heavy use of pytools to build and run a platform in the Edk2 repo + +Also uses basetools-build-steps.yml to compile basetools + +#### Special Notes + +* For a build type of pull request it will conditionally build if the patches change files that impact the platform. + * uses `stuart_pr_eval` to determine impact +* For manual builds or CI builds it will always build the platform +* It compiles basetools from source +* Will use `stuart_build --FlashOnly` to attempt to run the built image if the `Run` parameter is set. +* See the parameters block for expected configuration options +* 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. + + ``` yaml + steps: + - template: ../../.azurepipelines/templates/build-run-steps.yml + parameters: + extra_install_step: + - powershell: choco install qemu; Write-Host "##vso[task.prependpath]c:\Program Files\qemu" + displayName: Install QEMU and Set QEMU on path # friendly name displayed in the UI + condition: and(gt(variables.pkg_count, 0), succeeded()) + ``` diff --git a/.azurepipelines/templates/platform-build-run-steps.yml b/.azurepipelines/templates/platform-build-run-steps.yml new file mode 100644 index 000000000000..ebf674bfc7d8 --- /dev/null +++ b/.azurepipelines/templates/platform-build-run-steps.yml @@ -0,0 +1,134 @@ + +## @file +# File steps.yml +# +# template file containing the steps to build +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +parameters: +- name: tool_chain_tag + type: string + default: '' +- name: build_pkg + type: string + default: '' +- name: build_target + type: string + default: '' +- name: build_arch + type: string + default: '' +- name: build_file + type: string + default: '' +- name: build_flags + type: string + default: '' +- name: run_flags + type: string + default: '' + +- name: extra_install_step + type: stepList + default: [] + +steps: +- checkout: self + clean: true + fetchDepth: 1 + +- task: UsePythonVersion@0 + inputs: + versionSpec: "3.8.x" + architecture: "x64" + +- script: pip install -r pip-requirements.txt --upgrade + displayName: 'Install/Upgrade pip modules' + +# Set default +- bash: echo "##vso[task.setvariable variable=pkg_count]${{ 1 }}" + +# trim the package list if this is a PR +- task: CmdLine@1 + displayName: Check if ${{ parameters.build_pkg }} need testing + inputs: + filename: stuart_pr_eval + 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}" + condition: eq(variables['Build.Reason'], 'PullRequest') + + # Setup repo +- task: CmdLine@1 + displayName: Setup + inputs: + filename: stuart_setup + arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} -t ${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}} + condition: and(gt(variables.pkg_count, 0), succeeded()) + +# Stuart Update +- task: CmdLine@1 + displayName: Update + inputs: + filename: stuart_update + arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} -t ${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}} + condition: and(gt(variables.pkg_count, 0), succeeded()) + +# build basetools +# do this after setup and update so that code base dependencies +# are all resolved. +- template: basetools-build-steps.yml + parameters: + tool_chain_tag: ${{ parameters.tool_chain_tag }} + +# Potential Extra steps +- ${{ parameters.extra_install_step }} + +# Build +- task: CmdLine@1 + displayName: Build + inputs: + filename: stuart_build + arguments: -c ${{ parameters.build_file }} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} TARGET=${{ parameters.build_target}} -a ${{ parameters.build_arch}} ${{ parameters.build_flags}} + condition: and(gt(variables.pkg_count, 0), succeeded()) + +# Run +- task: CmdLine@1 + displayName: Run to shell + inputs: + filename: stuart_build + 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 + condition: and(and(gt(variables.pkg_count, 0), succeeded()), eq(variables['Run'], true)) + timeoutInMinutes: 1 + +# Copy the build logs to the artifact staging directory +- task: CopyFiles@2 + displayName: "Copy build logs" + inputs: + targetFolder: "$(Build.ArtifactStagingDirectory)" + SourceFolder: "Build" + contents: | + BUILDLOG_*.txt + BUILDLOG_*.md + CI_*.txt + CI_*.md + CISETUP.txt + SETUPLOG.txt + UPDATE_LOG.txt + PREVALLOG.txt + TestSuites.xml + **/BUILD_TOOLS_REPORT.html + **/OVERRIDELOG.TXT + BASETOOLS_BUILD*.* + flattenFolders: true + condition: succeededOrFailed() + +# Publish build artifacts to Azure Artifacts/TFS or a file share +- task: PublishBuildArtifacts@1 + continueOnError: true + displayName: "Publish build logs" + inputs: + pathtoPublish: "$(Build.ArtifactStagingDirectory)" + artifactName: "Build Logs $(System.JobName)" + condition: succeededOrFailed() -- 2.16.3.windows.1