-
Notifications
You must be signed in to change notification settings - Fork 321
Stabilize macOS agent setup #3928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
94d62ca
8db5ec3
ca1fa8b
58cb1bb
cfd34b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,11 @@ parameters: | |
|
|
||
| - name: operatingSystem | ||
| type: string | ||
| default: '' | ||
| values: | ||
| - Linux | ||
| - Mac | ||
| - Windows | ||
| default: Windows | ||
|
|
||
| - name: buildConfiguration | ||
| type: string | ||
|
|
@@ -134,22 +138,6 @@ jobs: | |
| - ${{ if ne(parameters.prebuildSteps, '') }}: | ||
| - ${{ parameters.prebuildSteps }} # extra steps to run before the build like downloading sni and the required configuration | ||
|
|
||
| - powershell: | | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We dont' need to generate a GUID and use it as a password. Our Library already has a |
||
| $guid = [guid]::NewGuid().ToString() | ||
| Write-Host "##vso[task.setvariable variable=password;issecret=true]$guid" | ||
| displayName: 'Generate Password' | ||
|
|
||
| - powershell: | | ||
| Write-Host "Password: $(password)" # prints *** to logs when set | ||
|
|
||
| $variableValue = "$(password)" | ||
| if (-not [string]::IsNullOrEmpty($variableValue)) { | ||
| Write-Output "The password exists with a value." | ||
| } else { | ||
| Write-Output "The password does not exist or is empty." | ||
| } | ||
| displayName: 'Verify Password' | ||
|
|
||
| - ${{ if eq(parameters.referenceType, 'Project') }}: | ||
| - template: ../steps/ci-project-build-step.yml@self | ||
| parameters: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,26 +4,31 @@ | |
| # See the LICENSE file in the project root for more information. # | ||
| ################################################################################# | ||
|
|
||
| # This step installs the latest SQL Server 2022 onto the macOS host and | ||
| # configures it for use. | ||
| # This step installs the latest SQL Server 2022 onto the macOS host and configures it for use. | ||
| # | ||
| # The SA password is set to the value of the $(Password) variable defined in the ADO Library "ADO | ||
| # Test Configuration properties", brought in by common/templates/libraries/ci-build-variables.yml. | ||
|
|
||
| parameters: | ||
| - name: password | ||
| type: string | ||
| default: $(password) | ||
|
|
||
| - name: condition | ||
| type: string | ||
| default: and(succeeded(), eq(variables['Agent.OS'], 'Darwin')) | ||
|
|
||
| steps: | ||
| # macOS only steps | ||
| - bash: | | ||
| # The "user" pipeline variable conflicts with homebrew, causing errors during install. Set it back to the pipeline user. | ||
| # The "user" pipeline variable conflicts with homebrew, causing errors during install. Set it | ||
| # back to the pipeline user. | ||
| USER=`whoami` | ||
|
|
||
| SQLCMD_ERRORS=$(Agent.TempDirectory)/sqlcmd_err.log | ||
| echo $SQLCMD_ERRORS | ||
| echo "Errors will be written to: $SQLCMD_ERRORS" | ||
|
|
||
| # Configure the prompt to show the current timestamp so we can see how long each command takes. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Diagnostic to see how long each command takes. Azure DevOps refuses to consistently show timestamps. |
||
| export PS4='+ [$(date "+%Y-%m-%d %H:%M:%S")] ' | ||
| set -x | ||
|
|
||
| # Install Docker and SQLCMD tools. | ||
| brew install colima | ||
| brew install --cask docker | ||
| brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release | ||
|
|
@@ -32,12 +37,12 @@ steps: | |
| colima start --arch x86_64 | ||
| docker --version | ||
| docker pull mcr.microsoft.com/mssql/server:2022-latest | ||
|
|
||
| # Password for the SA user (required) | ||
| MSSQL_SA_PW=${{ parameters.password }} | ||
| MSSQL_SA_PW=$(Password) | ||
|
|
||
| docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=$MSSQL_SA_PW" -p 1433:1433 -p 1434:1434 --name sql1 --hostname sql1 -d mcr.microsoft.com/mssql/server:2022-latest | ||
|
|
||
| sleep 5 | ||
|
|
||
| docker ps -a | ||
|
|
@@ -50,10 +55,10 @@ steps: | |
|
|
||
| # Wait 3 seconds between attempts. | ||
| delay=3 | ||
|
|
||
| # Try up to 40 times (2 minutes) to connect. | ||
| maxAttempts=40 | ||
|
|
||
| # Attempt counter. | ||
| attempt=1 | ||
|
|
||
|
|
@@ -64,18 +69,18 @@ steps: | |
| do | ||
|
|
||
| echo "Waiting for SQL Server to start (attempt #$attempt of $maxAttempts)..." | ||
|
|
||
| sqlcmd -S 127.0.0.1 -No -U sa -P $MSSQL_SA_PW -Q "SELECT @@VERSION" >> $SQLCMD_ERRORS 2>&1 | ||
|
|
||
| # If the command was successful, then the SQL Server is ready. | ||
| if [ $? -eq 0 ]; then | ||
| ready=1 | ||
| break | ||
| fi | ||
|
|
||
| # Increment the attempt counter. | ||
| ((attempt++)) | ||
|
|
||
| # Wait before trying again. | ||
| sleep $delay | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ensured we're defining this parameter as an enum everywhere since we're doing string comparisons to make decisions based on it.