Skip to content

Commit 14f9893

Browse files
committed
Use shared "ci-local" template for osx/win
1 parent 8020b34 commit 14f9893

File tree

9 files changed

+113
-54
lines changed

9 files changed

+113
-54
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
jobs:
2+
- template: matrix.yml
3+
parameters:
4+
windowsPoolName: dotnet-internal-temp

.vsts.pipelines/builds/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
jobs:
2+
- template: matrix.yml

.vsts.pipelines/jobs/ci-linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- template: ../steps/docker-cleanup-linux.yml
41-
- template: ../steps/calculate-config-flags-linux.yml
41+
- template: ../steps/calculate-config-flags.yml
4242

4343
# Create working directory and copy source into it.
4444
- script: |
@@ -50,7 +50,7 @@ jobs:
5050
cp -r . /root/sb/source-build'
5151
displayName: Clean sb directory and copy source from cloned directory
5252
53-
- template: ../steps/init-submodules-sh.yml
53+
- template: ../steps/init-submodules.yml
5454
parameters:
5555
commandPrefix: $(docker.run) $(docker.src.map) $(docker.src.work) $(imageName)
5656

.vsts.pipelines/jobs/ci-local.yml

Lines changed: 43 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
parameters:
2-
job: osx
2+
job: null
33
matrix:
44
Production: {}
5-
pool:
6-
name: Hosted macOS
5+
pool: null
6+
buildScript: null
7+
setupMac: false
8+
setupWindows: false
9+
skipSmokeTest: false
10+
failOnPrebuiltBaselineError: true
711

812
jobs:
913
- job: ${{ parameters.job }}
@@ -12,8 +16,18 @@ jobs:
1216
pool: ${{ parameters.pool }}
1317
timeoutInMinutes: 240
1418
variables:
19+
args.build: >
20+
/p:Configuration=$(sb.configuration)
21+
/p:PortableBuild=$(sb.portable)
22+
/p:FailOnPrebuiltBaselineError=$(failOnPrebuiltBaselineError)
23+
/p:ProdConBlobFeedUrlPrefix=$(prodConBlobFeedUrlPrefix)
24+
args.smokeTest: >
25+
/t:RunSmokeTest
26+
/p:Configuration=$(sb.configuration)
27+
/p:ProdConBlobFeedUrlPrefix=$(prodConBlobFeedUrlPrefix)
1528
# Prefix to distinguish artifacts from different legs.
1629
artifactName: ${{ format('{0} $(type)', parameters.job) }}
30+
failOnPrebuiltBaselineError: ${{ parameters.failOnPrebuiltBaselineError }}
1731
logsDirectory: $(Build.ArtifactStagingDirectory)/logs
1832
SOURCE_BUILD_SKIP_SUBMODULE_CHECK: true
1933
# Default type, can be overridden by matrix legs.
@@ -23,63 +37,43 @@ jobs:
2337
- checkout: self
2438
clean: true
2539

26-
- script: |
27-
./clean.sh -a
28-
# Make sure submodules from other branches are removed: pass extra f.
29-
git clean -xdff
30-
displayName: Clean
40+
# Make sure submodules from other branches are removed: pass extra f.
41+
- script: git clean -xdff
42+
displayName: Clean leftover submodules
3143

32-
- template: ../steps/calculate-config-flags-linux.yml
44+
- template: ../steps/check-space-powershell.yml
3345

34-
- script: |
35-
( set -o posix; set )
36-
displayName: Print all variables in environment
46+
- ${{ if eq(parameters.setupMac, true) }}:
47+
- template: ../steps/setup-macos-native.yml
48+
- ${{ if eq(parameters.setupWindows, true) }}:
49+
- template: ../steps/setup-windows-bash.yml
3750

38-
# Install native dependencies not present in hosted pool.
39-
- script: |
40-
setvariable() {
41-
(
42-
set +x
43-
echo "Setting '$1' to '$2'"
44-
echo "##vso[task.setvariable variable=$1;]$2"
45-
)
46-
}
47-
set -x
48-
# Based on https://github.com/sbomer/coreclr/blob/dc2fa1b96415f87d694e5b6e751e38ca6fbd09a1/unix-pipeline.yml#L36-L39
49-
brew install icu4c openssl
50-
brew link --force icu4c
51-
# Follow https://github.com/dotnet/corefx/blob/master/Documentation/building/unix-instructions.md#user-content-macos
52-
brew install cmake pkgconfig openssl
53-
brew_openssl_paths=$(brew info openssl | cut -d ' ' -f 1 | grep '^/.*/openssl/')
54-
# Use 'for' to get last/latest openssl install dir.
55-
for openssl_path in $brew_openssl_paths; do :; done
56-
setvariable OPENSSL_ROOT_DIR "$openssl_path"
57-
displayName: Install native dependencies
51+
- template: ../steps/calculate-config-flags.yml
52+
53+
- template: ../steps/init-submodules.yml
5854

59-
- template: ../steps/init-submodules-sh.yml
55+
- template: ../steps/check-space-powershell.yml
6056

6157
# Build source-build.
62-
- script: |
63-
set -x
64-
./build.sh \
65-
/p:Configuration=$(sb.configuration) \
66-
/p:PortableBuild=$(sb.portable) \
67-
/p:FailOnPrebuiltBaselineError=true \
68-
/p:ProdConBlobFeedUrlPrefix=$(prodConBlobFeedUrlPrefix)
58+
- script: ${{ format('{0} $(args.build)', parameters.buildScript) }}
6959
displayName: Build source-build
7060
timeoutInMinutes: 150
7161

62+
- template: ../steps/check-space-powershell.yml
63+
7264
# Run smoke tests.
73-
- script: |
74-
set -x
75-
./build.sh \
76-
/t:RunSmokeTest \
77-
/p:Configuration=$(sb.configuration) \
78-
/p:ProdConBlobFeedUrlPrefix=$(prodConBlobFeedUrlPrefix)
79-
displayName: Run smoke-test
65+
- ${{ if ne(parameters.skipSmokeTest, true) }}:
66+
- bash: ${{ format('{0} $(args.smokeTest)', parameters.buildScript) }}
67+
displayName: Run smoke-test
8068

81-
- script: |
69+
# Gather artifacts. Uses git bash on Windows.
70+
- bash: |
8271
set -x
72+
copyWithParents="cp {} --parents"
73+
if command -v rsync; then
74+
# On Mac, "--parents" isn't supported, but we can use rsync.
75+
copyWithParents="rsync -R {}"
76+
fi
8377
# Clean up previous build's staging dir, in case VSTS didn't do it.
8478
rm -rf "$(logsDirectory)"
8579
# Copy all these files to the logs dir, preserving relative path.
@@ -89,7 +83,7 @@ jobs:
8983
-path './bin/msbuild-debug/*' -o \
9084
-iname '*.binlog' -o \
9185
-iname '*.log' \) \
92-
-exec rsync -R {} "$(logsDirectory)" \;
86+
-exec $copyWithParents "$(logsDirectory)" \;
9387
displayName: Copy logs to staging directory
9488
condition: always()
9589
continueOnError: true

.vsts.pipelines/steps/calculate-config-flags-linux.yml renamed to .vsts.pipelines/steps/calculate-config-flags.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
steps:
2-
- script: |
2+
- bash: |
33
setvariable() {
44
echo "Setting '$1' to '$2'"
55
echo "##vso[task.setvariable variable=$1;]$2"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
steps:
2+
- powershell: |
3+
$g = 1024 * 1024 * 1024;
4+
echo "Name`tAvailable (GiB)`tTotal (GiB)"
5+
[System.IO.DriveInfo]::GetDrives() |
6+
%{ echo "$($_.Name)`t$($_.AvailableFreeSpace / $g)`t$($_.TotalSize / $g)" }
7+
displayName: (Diag) Check drive fullness
8+
condition: always()
9+
continueOnError: true

.vsts.pipelines/steps/init-submodules-sh.yml renamed to .vsts.pipelines/steps/init-submodules.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ parameters:
33

44
steps:
55
# Fetch vsts commits if building internally.
6-
- script: |
6+
- bash: |
77
set -x
88
# Ignore failure for the first command. It will intentionally fail if the commit is only
99
# available in VSTS. "submodule update --init" is the simplest way to set up the submodule
@@ -17,7 +17,7 @@ steps:
1717
condition: and(succeeded(), ne(variables['user.PAT'], ''))
1818
1919
# Initialize submodules.
20-
- script: |
20+
- bash: |
2121
set -x
2222
$commandPrefix git submodule update --init --recursive
2323
displayName: Initialize submodules
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
steps:
2+
- script: |
3+
setvariable() {
4+
(
5+
set +x
6+
echo "Setting '$1' to '$2'"
7+
echo "##vso[task.setvariable variable=$1;]$2"
8+
)
9+
}
10+
set -x
11+
# Install macOS native dependencies not present in hosted pool.
12+
# Based on https://github.com/sbomer/coreclr/blob/dc2fa1b96415f87d694e5b6e751e38ca6fbd09a1/unix-pipeline.yml#L36-L39
13+
brew install icu4c openssl
14+
brew link --force icu4c
15+
# Follow https://github.com/dotnet/corefx/blob/master/Documentation/building/unix-instructions.md#user-content-macos
16+
brew install cmake pkgconfig openssl
17+
brew_openssl_paths=$(brew info openssl | cut -d ' ' -f 1 | grep '^/.*/openssl/')
18+
# Use 'for' to get last/latest openssl install dir.
19+
for openssl_path in $brew_openssl_paths; do :; done
20+
setvariable OPENSSL_ROOT_DIR "$openssl_path"
21+
displayName: Install native dependencies
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# The dotnet-*-temp pools seem to have an install of bash along with its git, but its shell
2+
# is named sh.exe which isn't found by 'bash' steps. Make a copy in the build's working directory
3+
# and copy sh.exe to bash.exe, then add the new dir to PATH to make it accessible to 'bash' tasks.
4+
steps:
5+
- powershell: |
6+
echo "Finding dir containing sh.exe based on git.exe path..."
7+
$binDir = [IO.Path]::Combine(
8+
[IO.Path]::GetDirectoryName([IO.Path]::GetDirectoryName((get-command git).Source)),
9+
"usr", "bin")
10+
11+
echo "Creating the custom bin dir to add to PATH"
12+
$bashDir = "$(Build.ArtifactStagingDirectory)\usr\bin"
13+
mkdir -f $bashDir
14+
15+
echo "Creating bash.exe from sh.exe in $bashDir..."
16+
cp -Recurse "$binDir\*" $bashDir
17+
cp "$bashDir\sh.exe" "$bashDir\bash.exe"
18+
19+
echo "Files in bash dir:"
20+
ls $bashDir
21+
22+
echo "Adding $bashDir to PATH as AzDO variable for bash.exe..."
23+
$env:PATH = "$bashDir;" + $env:PATH
24+
echo "##vso[task.setvariable variable=PATH;]$($env:PATH)"
25+
26+
echo "Creating /tmp to avoid stderr warnings later..."
27+
bash --noprofile --norc -c 'mkdir /tmp'
28+
bash --noprofile --norc -c pwd
29+
displayName: Set up Windows bash

0 commit comments

Comments
 (0)