Add build script and CI config for the DataProtection folder

This commit is contained in:
Nate McMaster 2018-10-15 10:03:59 -07:00
parent 4dfd351c84
commit a673bfd741
No known key found for this signature in database
GPG Key ID: A778D9601BD78810
5 changed files with 42 additions and 11 deletions

View File

@ -15,3 +15,14 @@ phases:
- template: .vsts-pipelines/templates/project-ci.yml@buildtools - template: .vsts-pipelines/templates/project-ci.yml@buildtools
parameters: parameters:
buildArgs: "/t:CheckUniverse" 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'

15
run.ps1
View File

@ -14,6 +14,9 @@ The KoreBuild command to run.
.PARAMETER Path .PARAMETER Path
The folder to build. Defaults to the folder containing this script. 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 .PARAMETER Channel
The channel of KoreBuild to download. Overrides the value from the config file. The channel of KoreBuild to download. Overrides the value from the config file.
@ -75,6 +78,7 @@ param(
[Parameter(Mandatory=$true, Position = 0)] [Parameter(Mandatory=$true, Position = 0)]
[string]$Command, [string]$Command,
[string]$Path = $PSScriptRoot, [string]$Path = $PSScriptRoot,
[string]$LockFile,
[Alias('c')] [Alias('c')]
[string]$Channel, [string]$Channel,
[Alias('d')] [Alias('d')]
@ -104,15 +108,13 @@ $ErrorActionPreference = 'Stop'
function Get-KoreBuild { 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) { 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() $version = $version.TrimStart('version:').Trim()
$korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version)
@ -207,6 +209,7 @@ if (!$DotNetHome) {
else { Join-Path $PSScriptRoot '.dotnet'} else { Join-Path $PSScriptRoot '.dotnet'}
} }
if (!$LockFile) { $LockFile = Join-Path $Path 'korebuild-lock.txt' }
if (!$Channel) { $Channel = 'master' } if (!$Channel) { $Channel = 'master' }
if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' }

17
run.sh
View File

@ -15,6 +15,7 @@ verbose=false
update=false update=false
reinstall=false reinstall=false
repo_path="$DIR" repo_path="$DIR"
lockfile_path=''
channel='' channel=''
tools_source='' tools_source=''
ci=false 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 " --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 " -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 " --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 " -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 " --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." 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() { get_korebuild() {
local version local version
local lock_file="$repo_path/korebuild-lock.txt" if [ ! -f "$lockfile_path" ] || [ "$update" = true ]; then
if [ ! -f "$lock_file" ] || [ "$update" = true ]; then __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lockfile_path"
__get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file"
fi fi
version="$(grep 'version:*' -m 1 "$lock_file")" version="$(grep 'version:*' -m 1 "$lockfile_path")"
if [[ "$version" == '' ]]; then 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 return 1
fi fi
version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
@ -176,6 +177,11 @@ while [[ $# -gt 0 ]]; do
repo_path="${1:-}" repo_path="${1:-}"
[ -z "$repo_path" ] && __error "Missing value for parameter --path" && __usage [ -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) -s|--tools-source|-ToolsSource)
shift shift
tools_source="${1:-}" tools_source="${1:-}"
@ -296,6 +302,7 @@ if [ ! -z "$product_build_id" ]; then
msbuild_args[${#msbuild_args[*]}]="-p:DotNetProductBuildId=$product_build_id" msbuild_args[${#msbuild_args[*]}]="-p:DotNetProductBuildId=$product_build_id"
fi fi
[ -z "$lockfile_path" ] && lockfile_path="$repo_path/korebuild-lock.txt"
[ -z "$channel" ] && channel='master' [ -z "$channel" ] && channel='master'
[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' [ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools'

View File

@ -0,0 +1,3 @@
@ECHO OFF
SET RepoRoot="%~dp0..\.."
%RepoRoot%\build.cmd -LockFile %RepoRoot%\korebuild-lock.txt -Path %~dp0 %*

7
src/DataProtection/build.sh Executable file
View File

@ -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" "$@"