Skip to content

Commit 1e2fa47

Browse files
Enhance appveyor.yml and build scripts
This commit makes a temporary change to the Build.ps1 script which needs to be reverted once the build is successful.
1 parent ab8dd8a commit 1e2fa47

6 files changed

+55
-21
lines changed

Build.ps1

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ CheckLastExitCode
9999
dotnet build -c Release
100100
CheckLastExitCode
101101

102-
.\start-cosmos-db-emulator.ps1
103-
getcontent .\nohup.out
104-
CheckLastExitCode
105-
106102
# RunInspectCode
107103
# RunCleanupCode
108104

appveyor.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ for:
3535
- image: Visual Studio 2019
3636
services:
3737
- postgresql13
38+
- docker
3839
# REF: https://github.com/docascode/docfx-seed/blob/master/appveyor.yml
3940
before_build:
4041
- pwsh: |
@@ -48,6 +49,34 @@ for:
4849
if ($lastexitcode -ne 0) {
4950
throw "docfx install failed with exit code $lastexitcode."
5051
}
52+
- sh: |
53+
# Pull Azure Cosmos Emulator Docker image
54+
echo "Pulling Azure Cosmos Emulator Docker image for Linux ..."
55+
./pull-docker-azure-cosmos-emulator-linux.sh
56+
57+
# Start Azure Cosmos Emulator container
58+
echo "Running Azure Cosmos Emulator Docker container ..."
59+
nohup ./run-docker-azure-cosmos-emulator-linux.sh &
60+
61+
# Wait for Docker container being started in the background
62+
echo "Waiting 60 seconds before trying to download Azure Cosmos Emulator SSL certificate ..."
63+
sleep 60
64+
65+
# Print the background process output to see whether there are any errors
66+
if [ -f "./nohup.out" ]; then
67+
echo "--- BEGIN CONTENTS OF NOHUP.OUT ---"
68+
cat ./nohup.out
69+
echo "--- END CONTENTS OF NOHUP.OUT ---"
70+
fi
71+
72+
# Install SSL certificate to be able to access the emulator
73+
echo "Installing Azure Cosmos Emulator SSL certificate ..."
74+
sudo ./install-azure-cosmos-emulator-linux-certificates.sh
75+
- pwsh: |
76+
# Start Azure Cosmos Emulator on Windows
77+
if ($isWindows) {
78+
.\start-cosmos-db-emulator.ps1
79+
}
5180
after_build:
5281
- pwsh: |
5382
CD ./docs

install-azure-cosmos-emulator-linux-certificates.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ then
2727
sudo update-ca-certificates
2828
else
2929
echo "Could not download CA certificate!"
30+
false
3031
fi
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Pull the azure-cosmos-emulator Docker image for Linux from the registry.
4+
docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator

run-docker-azure-cosmos-emulator-linux.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
# This step is required when Direct mode setting is configured using Cosmos DB SDKs.
55
ipaddr="`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}' | head -n 1`"
66

7-
# Pull the azure-cosmos-emulator Docker image for Linux from the registry.
8-
docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
9-
107
# Run the image, creating a container called "azure-cosmos-emulator-linux".
118
docker run \
129
-p 8081:8081 \

start-cosmos-db-emulator.ps1

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,38 @@
22

33
function StartCosmosDbEmulator {
44
if ($PSVersionTable.Platform -eq "Unix") {
5-
StartCosmosDbEmulatorDockerContainer
5+
StartCosmosDbEmulatorOnLinux
66
}
77
else {
8-
StartCosmosDbEmulatorForWindows
8+
StartCosmosDbEmulatorOnWindows
99
}
1010
}
1111

12-
function StartCosmosDbEmulatorDockerContainer {
13-
Write-Host "Starting Cosmos DB Emulator Docker container ..."
14-
Start-Process nohup 'bash ./run-docker-azure-cosmos-emulator-linux.sh'
12+
function StartCosmosDbEmulatorOnLinux {
13+
Remove-Item .\nohup.*
1514

16-
Write-Host "Waiting for Cosmos DB Emulator Docker container to start up ..."
17-
Start-Sleep -Seconds 30
18-
WaitUntilCosmosSqlApiEndpointIsReady
15+
Write-Host "Running Azure Cosmos Emulator Docker container ..."
16+
Start-Process nohup './run-docker-azure-cosmos-emulator-linux.sh'
17+
Start-Sleep -Seconds 1
18+
19+
Write-Host "Waiting 60 seconds before trying to download Azure Cosmos Emulator SSL certificate ..."
20+
Start-Sleep -Seconds 60
21+
22+
Write-Host "--- BEGIN CONTENTS OF NOHUP.OUT ---"
23+
Get-Content .\nohup.out
24+
Write-Host "--- END CONTENTS OF NOHUP.OUT ---"
1925

20-
Write-Host "Installing Cosmos DB Emulator certificates ..."
21-
Start-Sleep -Seconds 30
22-
Start-Process nohup 'bash ./install-azure-cosmos-emulator-linux-certificates.sh'
26+
Write-Host "Installing Azure Cosmos Emulator SSL certificate ..."
27+
Start-Process bash './install-azure-cosmos-emulator-linux-certificates.sh' -Wait
28+
Write-Host "Installed Azure Cosmos Emulator SSL certificate."
2329
}
2430

25-
function StartCosmosDbEmulatorForWindows {
31+
function StartCosmosDbEmulatorOnWindows {
2632
Write-Host "Starting Cosmos DB Emulator for Windows ..."
2733
Start-Process -FilePath "C:\Program Files\Azure Cosmos DB Emulator\Microsoft.Azure.Cosmos.Emulator.exe" -ArgumentList "/DisableRateLimiting /NoUI /NoExplorer"
2834

29-
Write-Host "Waiting for Cosmos DB Emulator for Windows to start up ..."
30-
Start-Sleep -Seconds 10
35+
Write-Host "Waiting for Azure Cosmos Emulator for Windows to start up ..."
36+
Start-Sleep -Seconds 20
3137
WaitUntilCosmosSqlApiEndpointIsReady
3238
}
3339

@@ -45,6 +51,7 @@ function WaitUntilCosmosSqlApiEndpointIsReady {
4551
catch {
4652
$client.Close()
4753
if($attempt -eq $max) {
54+
Write-Host "Cosmos SQL API endpoint is not listening. Aborting connection."
4855
throw "Cosmos SQL API endpoint is not listening. Aborting connection."
4956
} else {
5057
[int]$sleepTime = 5 * (++$attempt)

0 commit comments

Comments
 (0)