-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[vcpkg ci] add macos scripts to vcpkg repo #12172
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -334,3 +334,4 @@ __pycache__/ | |
| archives | ||
| .DS_Store | ||
| prefab/ | ||
| *.swp | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| #!pwsh | ||
| #Requires -Version 6.0 | ||
|
|
||
| <# | ||
| .SYNOPSIS | ||
| Installs the set of prerequisites for the macOS CI hosts. | ||
|
|
||
| .DESCRIPTION | ||
| Install-Prerequisites.ps1 installs all of the necessary prerequisites | ||
| to run the vcpkg macOS CI in a vagrant virtual machine, | ||
| skipping all prerequisites that are already installed. | ||
|
|
||
| .PARAMETER Force | ||
| Don't skip the prerequisites that are already installed. | ||
|
|
||
| .INPUTS | ||
| None | ||
|
|
||
| .OUTPUTS | ||
| None | ||
| #> | ||
| [CmdletBinding()] | ||
| Param( | ||
| [Parameter()] | ||
| [Switch]$Force | ||
| ) | ||
|
|
||
| Set-StrictMode -Version 2 | ||
|
|
||
| if (-not $IsMacOS) { | ||
| Write-Error 'This script should only be run on a macOS host' | ||
| throw | ||
strega-nil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| Import-Module "$PSScriptRoot/Utilities.psm1" | ||
|
|
||
| $Installables = Get-Content "$PSScriptRoot/configuration/installables.json" | ConvertFrom-Json | ||
|
|
||
| $Installables.Applications | ForEach-Object { | ||
| if (-not (Get-CommandExists $_.TestCommand)) { | ||
| Write-Host "$($_.Name) not installed; installing now" | ||
| } elseif ($Force) { | ||
| Write-Host "$($_.Name) found; attempting to upgrade or re-install" | ||
| } else { | ||
| Write-Host "$($_.Name) already installed" | ||
| return | ||
| } | ||
|
|
||
| $pathToDmg = "~/Downloads/$($_.Name).dmg" | ||
| Get-RemoteFile -OutFile $pathToDmg -Uri $_.DmgUrl -Sha256 $_.Sha256 | ||
|
|
||
| hdiutil attach $pathToDmg -mountpoint /Volumes/setup-installer | ||
| sudo installer -pkg "/Volumes/setup-installer/$($_.InstallerPath)" -target / | ||
| hdiutil detach /Volumes/setup-installer | ||
| } | ||
|
|
||
| # Install plugins | ||
| $installedExtensionPacks = Get-InstalledVirtualBoxExtensionPacks | ||
|
|
||
| $Installables.VBoxExtensions | ForEach-Object { | ||
| $extension = $_ | ||
| $installedExts = $installedExtensionPacks | Where-Object { $_.Pack -eq $extension.FullName -and $_.Usable -eq 'true' } | ||
|
|
||
| if ($null -eq $installedExts) { | ||
| Write-Host "VBox extension: $($extension.Name) not installed; installing now" | ||
| } elseif ($Force) { | ||
| Write-Host "VBox extension: $($extension.Name) found; attempting to upgrade or re-install" | ||
| } else { | ||
| Write-Host "VBox extension: $($extension.Name) already installed" | ||
| return | ||
| } | ||
|
|
||
| $pathToExt = "~/Downloads/$($extension.FullName -replace ' ','_').vbox-extpack" | ||
|
|
||
| Get-RemoteFile -OutFile $pathToExt -Uri $extension.Url -Sha256 $extension.Sha256 | Out-Null | ||
|
|
||
| Write-Host 'Attempting to install extension with sudo; you may need to enter your password' | ||
| sudo VBoxManage extpack install --replace $pathToExt | ||
| sudo VBoxManage extpack cleanup | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # `vcpkg-eg-mac` VMs | ||
|
|
||
| ## Table of Contents | ||
|
|
||
| - [`vcpkg-eg-mac` VMs](#vcpkg-eg-mac-vms) | ||
| - [Table of Contents](#table-of-contents) | ||
| - [Basic Usage](#basic-usage) | ||
| - [Setting up a new macOS machine](#setting-up-a-new-macos-machine) | ||
|
|
||
| ## Basic Usage | ||
|
|
||
| The simplest usage, and one which should be used for when spinning up | ||
| new VMs, and when restarting old ones, is a simple: | ||
|
|
||
| ``` | ||
| $ cd ~/vagrant/vcpkg-eg-mac | ||
| $ vagrant up | ||
| ``` | ||
|
|
||
| Any modifications to the machines should be made in `configuration/VagrantFile` | ||
| and `Setup-VagrantMachines.ps1`, and make sure to push any changes! | ||
|
|
||
| ## Setting up a new macOS machine | ||
|
|
||
| Before anything else, one must download `brew` and `powershell`. | ||
|
|
||
| ```sh | ||
| $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | ||
| $ brew cask install powershell | ||
| ``` | ||
|
|
||
| Then, we need to download the `vcpkg` repository: | ||
|
|
||
| ```sh | ||
| $ git clone https://github.com/microsoft/vcpkg | ||
| ``` | ||
|
|
||
| And now all we need to do is set it up! Replace `XX` with the number of | ||
| the virtual machine. Generally, that should be the same as the number | ||
| for the physical machine; i.e., vcpkgmm-04 will have vcpkg-eg-mac-04. | ||
|
|
||
| ```sh | ||
| $ cd vcpkg/scripts/azure-pipelines/osx | ||
| $ ./Install-Prerequisites.ps1 -Force | ||
| # NOTE: you may get an error about CoreCLR; see the following paragraph if you do | ||
| $ ./Setup-VagrantMachines.ps1 XX \ | ||
| -Pat '<get this from azure>' \ | ||
| -ArchivesUsername '<get this from the archives share>' \ | ||
| -ArchivesAccessKey '<get this from the archives share>' \ | ||
| -ArchivesUrn '<something>.file.core.windows.net' \ | ||
| -ArchivesShare 'archives' | ||
| $ cd ~/vagrant/vcpkg-eg-mac | ||
| $ vagrant up | ||
| ``` | ||
|
|
||
| If you see the following error: | ||
|
|
||
| ``` | ||
| Failed to initialize CoreCLR, HRESULT: 0x8007001F | ||
| ``` | ||
|
|
||
| You have to reboot the machine; run | ||
|
|
||
| ```sh | ||
| $ sudo shutdown -r now | ||
| ``` | ||
|
|
||
| and wait for the machine to start back up. Then, start again from | ||
| `Install-Prerequisites.ps1`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| #!pwsh | ||
| #Requires -Version 6.0 | ||
|
|
||
| <# | ||
| .SYNOPSIS | ||
| Sets up the configuration for the vagrant virtual machines. | ||
|
|
||
| .DESCRIPTION | ||
| Setup-VagrantMachines.ps1 sets up the virtual machines for | ||
| vcpkg's macOS CI. It puts the VagrantFile and necessary | ||
| configuration JSON file into ~/vagrant/vcpkg-eg-mac. | ||
|
|
||
| .PARAMETER Pat | ||
| The personal access token which has Read & Manage permissions on the ADO pool. | ||
|
|
||
| .PARAMETER ArchivesUsername | ||
| The username for the archives share. | ||
|
|
||
| .PARAMETER ArchivesAccessKey | ||
| The access key for the archives share. | ||
|
|
||
| .PARAMETER ArchivesUri | ||
| The URN of the archives share; looks like `foo.windows.core.net`. | ||
|
|
||
| .PARAMETER ArchivesShare | ||
| The archives share name. | ||
|
|
||
| .PARAMETER BaseName | ||
| The base name for the vagrant VM; the machine name is $BaseName-$MachineIdentifiers. | ||
| Defaults to 'vcpkg-eg-mac'. | ||
|
|
||
| .PARAMETER Force | ||
| Delete any existing vagrant/vcpkg-eg-mac directory. | ||
|
|
||
| .PARAMETER DiskSize | ||
| The size to make the temporary disks in gigabytes. Defaults to 425. | ||
|
|
||
| .PARAMETER MachineIdentifiers | ||
| The numbers to give the machines; should match [0-9]{2}. | ||
|
|
||
| .INPUTS | ||
| None | ||
|
|
||
| .OUTPUTS | ||
| None | ||
| #> | ||
| [CmdletBinding(PositionalBinding=$False)] | ||
| Param( | ||
| [Parameter(Mandatory=$True)] | ||
| [String]$Pat, | ||
|
|
||
| [Parameter(Mandatory=$True)] | ||
| [String]$ArchivesUsername, | ||
|
|
||
| [Parameter(Mandatory=$True)] | ||
| [String]$ArchivesAccessKey, | ||
|
|
||
| [Parameter(Mandatory=$True)] | ||
| [String]$ArchivesUrn, | ||
|
|
||
| [Parameter(Mandatory=$True)] | ||
| [String]$ArchivesShare, | ||
|
|
||
| [Parameter()] | ||
| [String]$BaseName = 'vcpkg-eg-mac', | ||
strega-nil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| [Parameter()] | ||
| [Switch]$Force, | ||
|
|
||
| [Parameter()] | ||
| [Int]$DiskSize = 425, | ||
|
|
||
| [Parameter(Mandatory=$True, ValueFromRemainingArguments)] | ||
| [String[]]$MachineIdentifiers | ||
| ) | ||
|
|
||
| Set-StrictMode -Version 2 | ||
|
|
||
| if (-not $IsMacOS) { | ||
| throw 'This script should only be run on a macOS host' | ||
| } | ||
|
|
||
| if (Test-Path '~/vagrant') { | ||
| if ($Force) { | ||
| Write-Host 'Deleting existing directories' | ||
| Remove-Item -Recurse -Force -Path '~/vagrant' | Out-Null | ||
| } else { | ||
| throw '~/vagrant already exists; try re-running with -Force' | ||
| } | ||
| } | ||
|
|
||
| Write-Host 'Creating new directories' | ||
| New-Item -ItemType 'Directory' -Path '~/vagrant' | Out-Null | ||
| New-Item -ItemType 'Directory' -Path '~/vagrant/vcpkg-eg-mac' | Out-Null | ||
|
|
||
| Copy-Item ` | ||
| -Path "$PSScriptRoot/configuration/VagrantFile" ` | ||
| -Destination '~/vagrant/vcpkg-eg-mac/VagrantFile' | ||
|
|
||
| $configuration = @{ | ||
| pat = $Pat; | ||
| base_name = $BaseName; | ||
| machine_identifiers = $MachineIdentifiers; | ||
| disk_size = $DiskSize; | ||
| archives = @{ | ||
| username = $ArchivesUsername; | ||
| access_key = $ArchivesAccessKey; | ||
| url = $ArchivesUri; | ||
| share = $ArchivesShare; | ||
| }; | ||
| } | ||
| ConvertTo-Json -InputObject $configuration -Depth 5 ` | ||
| | Set-Content -Path '~/vagrant/vcpkg-eg-mac/vagrant-configuration.json' | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.