From a673bfd741df5728a5b50eb6b20e6bd70941e6cc Mon Sep 17 00:00:00 2001 From: Nate McMaster <nate.mcmaster@microsoft.com> Date: Mon, 15 Oct 2018 10:03:59 -0700 Subject: [PATCH] Add build script and CI config for the DataProtection folder --- .azure/pipelines/fast-pr-validation.yml | 11 +++++++++++ run.ps1 | 15 +++++++++------ run.sh | 17 ++++++++++++----- src/DataProtection/build.cmd | 3 +++ src/DataProtection/build.sh | 7 +++++++ 5 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 src/DataProtection/build.cmd create mode 100755 src/DataProtection/build.sh diff --git a/.azure/pipelines/fast-pr-validation.yml b/.azure/pipelines/fast-pr-validation.yml index 426b7a79a83..e91c970c6b8 100644 --- a/.azure/pipelines/fast-pr-validation.yml +++ b/.azure/pipelines/fast-pr-validation.yml @@ -15,3 +15,14 @@ phases: - template: .vsts-pipelines/templates/project-ci.yml@buildtools parameters: buildArgs: "/t:CheckUniverse" +- phase: DataProtection + queue: Hosted VS2017 + steps: + - script: src/DataProtection/build.cmd -ci + displayName: Run src/DataProtection/build.cmd + - task: PublishTestResults@2 + displayName: Publish test results + condition: always() + inputs: + testRunner: vstest + testResultsFiles: 'src/DataProtection/artifacts/logs/**/*.trx' diff --git a/run.ps1 b/run.ps1 index 60e533097c1..6b7e36c6cf1 100644 --- a/run.ps1 +++ b/run.ps1 @@ -14,6 +14,9 @@ The KoreBuild command to run. .PARAMETER Path The folder to build. Defaults to the folder containing this script. +.PARAMETER LockFile +The path to the korebuild-lock.txt file. Defaults to $Path/korebuild-lock.txt + .PARAMETER Channel The channel of KoreBuild to download. Overrides the value from the config file. @@ -75,6 +78,7 @@ param( [Parameter(Mandatory=$true, Position = 0)] [string]$Command, [string]$Path = $PSScriptRoot, + [string]$LockFile, [Alias('c')] [string]$Channel, [Alias('d')] @@ -104,15 +108,13 @@ $ErrorActionPreference = 'Stop' function Get-KoreBuild { - $lockFile = Join-Path $Path 'korebuild-lock.txt' - - if (!(Test-Path $lockFile) -or $Update) { - Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile + if (!(Test-Path $LockFile) -or $Update) { + Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $LockFile } - $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 + $version = Get-Content $LockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 if (!$version) { - Write-Error "Failed to parse version from $lockFile. Expected a line that begins with 'version:'" + Write-Error "Failed to parse version from $LockFile. Expected a line that begins with 'version:'" } $version = $version.TrimStart('version:').Trim() $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) @@ -207,6 +209,7 @@ if (!$DotNetHome) { else { Join-Path $PSScriptRoot '.dotnet'} } +if (!$LockFile) { $LockFile = Join-Path $Path 'korebuild-lock.txt' } if (!$Channel) { $Channel = 'master' } if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } diff --git a/run.sh b/run.sh index beaca3094fb..cfc0a36904f 100755 --- a/run.sh +++ b/run.sh @@ -15,6 +15,7 @@ verbose=false update=false reinstall=false repo_path="$DIR" +lockfile_path='' channel='' tools_source='' ci=false @@ -41,6 +42,7 @@ __usage() { echo " --config-file <FILE> The path to the configuration file that stores values. Defaults to korebuild.json." echo " -d|--dotnet-home <DIR> The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." echo " --path <PATH> The directory to build. Defaults to the directory containing the script." + echo " --lockfile <PATH> The path to the korebuild-lock.txt file. Defaults to \$repo_path/korebuild-lock.txt" echo " -s|--tools-source|-ToolsSource <URL> The base url where build tools can be downloaded. Overrides the value from the config file." echo " --package-version-props-url <URL> The url of the package versions props path containing dependency versions." echo " --access-token <Token> The query string to append to any blob store access for PackageVersionPropsUrl, if any." @@ -61,13 +63,12 @@ __usage() { get_korebuild() { local version - local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" + if [ ! -f "$lockfile_path" ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lockfile_path" fi - version="$(grep 'version:*' -m 1 "$lock_file")" + version="$(grep 'version:*' -m 1 "$lockfile_path")" if [[ "$version" == '' ]]; then - __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" + __error "Failed to parse version from $lockfile_path. Expected a line that begins with 'version:'" return 1 fi version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" @@ -176,6 +177,11 @@ while [[ $# -gt 0 ]]; do repo_path="${1:-}" [ -z "$repo_path" ] && __error "Missing value for parameter --path" && __usage ;; + --[Ll]ock[Ff]ile) + shift + lockfile_path="${1:-}" + [ -z "$lockfile_path" ] && __error "Missing value for parameter --lockfile" && __usage + ;; -s|--tools-source|-ToolsSource) shift tools_source="${1:-}" @@ -296,6 +302,7 @@ if [ ! -z "$product_build_id" ]; then msbuild_args[${#msbuild_args[*]}]="-p:DotNetProductBuildId=$product_build_id" fi +[ -z "$lockfile_path" ] && lockfile_path="$repo_path/korebuild-lock.txt" [ -z "$channel" ] && channel='master' [ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' diff --git a/src/DataProtection/build.cmd b/src/DataProtection/build.cmd new file mode 100644 index 00000000000..f4169ea5e41 --- /dev/null +++ b/src/DataProtection/build.cmd @@ -0,0 +1,3 @@ +@ECHO OFF +SET RepoRoot="%~dp0..\.." +%RepoRoot%\build.cmd -LockFile %RepoRoot%\korebuild-lock.txt -Path %~dp0 %* diff --git a/src/DataProtection/build.sh b/src/DataProtection/build.sh new file mode 100755 index 00000000000..d5bb0cf6312 --- /dev/null +++ b/src/DataProtection/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euo pipefail + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +repo_root="$DIR/../.." +"$repo_root/build.sh" --path "$DIR" --lockfile "$repo_root/korebuild-lock.txt" "$@" -- GitLab