early-access version 2853

This commit is contained in:
pineappleEA
2022-07-23 03:01:36 +02:00
parent 1f2b5081b5
commit 1f111bb69c
8955 changed files with 418777 additions and 999 deletions

View File

@@ -0,0 +1,128 @@
#!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 and of the right version.
.INPUTS
None
.OUTPUTS
None
#>
[CmdletBinding()]
Param()
Set-StrictMode -Version 2
if (-not $IsMacOS) {
Write-Error 'This script should only be run on a macOS host'
throw
}
Import-Module "$PSScriptRoot/Utilities.psm1"
$Installables = Get-Content "$PSScriptRoot/configuration/installables.json" | ConvertFrom-Json
$Installables.Applications | ForEach-Object {
$VersionCommand = $_.VersionCommand
$InstalledVersion = (& $VersionCommand[0] $VersionCommand[1..$VersionCommand.Length])
if (-not $?) {
Write-Host "$($_.Name) not installed; installing now"
} else {
$InstalledVersion = $InstalledVersion -join "`n"
if ($InstalledVersion -match $_.VersionRegex) {
if ($Matches.Count -ne 2) {
Write-Error "$($_.Name) has a malformed version regex ($($_.VersionRegex)); it should have a single capture group
(it has $($Matches.Count - 1))"
throw
}
if ($Matches[1] -eq $_.Version) {
Write-Host "$($_.Name) already installed and at the correct version ($($Matches[1]))"
return
} else {
Write-Host "$($_.Name) already installed but with the incorrect version
installed version: '$($Matches[1])'
required version : '$($_.Version)'
upgrading now."
}
} else {
Write-Warning "$($_.Name)'s version command ($($VersionCommand -join ' ')) returned a value we did not expect:
$InstalledVersion
expected a version matching the regex: $($_.VersionRegex)
Installing anyways."
}
}
if ($null -ne (Get-Member -InputObject $_ -Name 'DmgUrl')) {
$pathToDmg = "~/Downloads/$($_.Name).dmg"
Get-RemoteFile -OutFile $pathToDmg -Uri $_.DmgUrl -Sha256 $_.Sha256
hdiutil attach $pathToDmg -mountpoint /Volumes/setup-installer
if ($null -ne (Get-Member -InputObject $_ -Name 'InstallationCommands')) {
$_.InstallationCommands | % {
Write-Host "> $($_ -join ' ')"
& $_[0] $_[1..$_.Length] | Write-Host
}
} elseif ($null -ne (Get-Member -InputObject $_ -Name 'InstallerPath')) {
sudo installer -pkg "/Volumes/setup-installer/$($_.InstallerPath)" -target /
hdiutil detach /Volumes/setup-installer
} else {
Write-Error "$($_.Name) installer object has a DmgUrl, but neither an InstallerPath nor an InstallationCommands"
throw
}
} elseif ($null -ne (Get-Member -InputObject $_ -Name 'PkgUrl')) {
$pathToPkg = "~/Downloads/$($_.Name).pkg"
Get-RemoteFile -OutFile $pathToPkg -Uri $_.PkgUrl -Sha256 $_.Sha256
sudo installer -pkg $pathToPkg -target /
} else {
Write-Error "$($_.Name) does not have an installer in the configuration file."
throw
}
}
$installedVagrantPlugins = @{}
vagrant plugin list --machine-readable | ForEach-Object {
$timestamp, $target, $type, $data = $_ -split ','
switch ($type) {
# these are not important
'ui' { }
'plugin-version-constraint' { }
'plugin-name' {
$installedVagrantPlugins[$data] = $Null
}
'plugin-version' {
$version = $data -replace '%!\(VAGRANT_COMMA\)',','
if ($version -notmatch '^(.*), global') {
Write-Error "Invalid version string for plugin ${target}: $version"
throw
}
$installedVagrantPlugins[$target] = $Matches[1]
}
default {
Write-Warning "Unknown plugin list member type $type for plugin $target"
}
}
}
$Installables.VagrantPlugins | ForEach-Object {
if (-not $installedVagrantPlugins.Contains($_.Name)) {
Write-Host "$($_.Name) not installed; installing now"
} elseif ($installedVagrantPlugins[$_.Name] -ne $_.Version) {
Write-Host "$($_.Name) already installed but with the incorrect version
installed version: '$($installedVagrantPlugins[$_.Name])'
required version: '$($_.Version)'"
} else {
Write-Host "$($_.Name) already installed and at the correct version ($($_.Version))"
return
}
vagrant plugin install $_.Name --plugin-version $_.Version
}

View File

@@ -0,0 +1,258 @@
# `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)
- [Creating a new Vagrant box](#creating-a-new-vagrant-box)
- [VM Software Versions](#vm-software-versions)
- [Creating a New Azure Agent Pool](#creating-a-new-azure-agent-pool)
- [Running the VM](#running-the-vm)
- [Getting an Azure Pipelines PAT](#getting-an-azure-pipelines-pat)
- [Setting up a new macOS machine](#setting-up-a-new-macos-machine)
- [Troubleshooting](#troubleshooting)
- [(Internal) Accessing the macOS fileshare](#internal-accessing-the-macos-fileshare)
## Basic Usage
The most common operation here is to set up a new VM for Azure
pipelines; we try to make that operation as easy as possible.
It should take all of three steps, assuming the machine is
already set up (or read [these instructions] for how to set up a machine):
1. [Create a new vagrant box](#creating-a-new-vagrant-box)
2. [Create a new agent pool](#creating-a-new-azure-agent-pool)
3. [Setup and run the vagrant VM](#running-the-vm)
4. Update `azure-pipelines.yml` and `azure-pipelines-osx.yml` to point to the new macOS pool.
[these instructions]: #setting-up-a-new-macos-machine
### Creating a new Vagrant box
Whenever we want to install updated versions of the command line tools,
or of macOS, we need to create a new vagrant box.
This is pretty easy, but the results of the creation are not public,
since we're concerned about licensing.
However, if you're sure you're following Apple's licensing,
you can set up your own vagrant boxes that are the same as ours by doing the following:
You'll need some prerequisites:
- An Xcode installer - you can get this from Apple's developer website,
although you'll need to sign in first: <https://developer.apple.com/downloads>
- The software installed by `Install-Prerequisites.ps1`
If you're updating the CI pool, make sure you update macOS.
First, you'll need to create a base VM;
this is where you determine what version of macOS is installed.
Follow the Parallels process for creating a macOS VM; this involves
updating to whatever version, and then scrolling right until you find
"Install macOS from recovery partition".
Once you've done this, you can run through the installation of macOS onto a new VM.
You should set the username to `vagrant`.
Once it's finished installing, make sure to turn on the SSH server.
Open System Preferences, then go to Sharing > Remote Login,
and turn it on.
You'll then want to add the vagrant SSH keys to the VM's vagrant user.
Open the terminal application and run the following:
```sh
$ # basic stuff
$ date | sudo tee '/etc/vagrant_box_build_time'
$ printf 'vagrant\tALL=(ALL)\tNOPASSWD:\tALL\n' | sudo tee -a '/etc/sudoers.d/vagrant'
$ sudo chmod 0440 '/etc/sudoers.d/vagrant'
$ # then install vagrant keys
$ mkdir -p ~/.ssh
$ curl -fsSL 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' >~/.ssh/authorized_keys
$ chmod 0600 ~/.ssh/authorized_keys
```
Finally, you'll need to install the Parallel Tools.
From your host, in the top bar,
go to Actions > Install Parallels Tools...,
and then follow the instructions.
Now, let's package the VM into a base box.
(The following instructions are adapted from
[these official instructions][base-box-instructions]).
Run the following commands:
```sh
$ cd ~/Parallels
$ echo '{ "provider": "parallels" }' >metadata.json
$ tar zcvf <macos version>.box ./metadata.json ./<name of VM>.pvm
```
This will create a box file which contains all the necessary data.
You can delete the `metadata.json` file after.
Once you've done that, you can upload it to the fileshare,
under `share/boxes/macos-base`, add it to `share/boxes/macos-base.json`,
and finally add it to vagrant:
```sh
$ vagrant box add ~/vagrant/share/boxes/macos-base.json
```
Then, we'll create the final box,
which contains all the necessary programs for doing CI work.
Copy `configuration/Vagrantfile-box.rb` as `Vagrantfile`, and
`configuration/vagrant-box-configuration.json`
into a new directory; into that same directory,
download the Xcode command line tools dmg, and name it `clt.dmg`.
Then, run the following in that directory:
```sh
$ vagrant up
$ vagrant package
```
This will create a `package.box`, which is the box file for the base VM.
Once you've created this box, if you're making it the new box for the CI,
upload it to the fileshare, under `share/boxes/macos-ci`.
Then, add the metadata about the box (the name and version) to
`share/boxes/macos-ci.json`.
Once you've done that, add the software versions under [VM Software Versions](#vm-software-versions).
[base-box-instructions]: https://parallels.github.io/vagrant-parallels/docs/boxes/base.html
#### VM Software Versions
* 2022-02-04 (minor update to 2022-01-03)
* macOS: 12.1
* Xcode CLTs: 13.2
* 2022-01-03:
* macOS: 12.1
* Xcode CLTs: 13.2
* 2021-07-27:
* macOS: 11.5.1
* Xcode CLTs: 12.5.1
* 2021-04-16:
* macOS: 11.2.3
* Xcode CLTs: 12.4
* 2020-09-28:
* macOS: 10.15.6
* Xcode CLTs: 12
### Creating a New Azure Agent Pool
When updating the macOS machines to a new version, you'll need to create
a new agent pool for the machines to join. The standard for this is to
name it `PrOsx-YYYY-MM-DD`, with `YYYY-MM-DD` the day that the process
is started.
In order to create a new agent pool, go to the `vcpkg/public` project;
go to `Project settings`, then go to `Agent pools` under `Pipelines`.
Add a new self-hosted pool, name it as above, and make certain to check
the box for "Grant access permission to all pipelines".
Once you've done this, you are done; you can start adding new machines
to the pool!
### Running the VM
First, make sure that your software is up to date:
```sh
$ cd ~/vcpkg
$ git fetch
$ git switch -d origin/master
$ ./scripts/azure-pipelines/osx/Install-Prerequisites.ps1
```
as well as checking to make sure macOS is up to date.
Then, follow the instructions for [accessing ~/vagrant/share][access-fileshare].
And finally, [grab a PAT], update the vagrant box, set up the VM, and run it:
```sh
$ vagrant box remove -f vcpkg/macos-ci # This won't do anything if the machine never had a box before
$ vagrant box add ~/vagrant/share/boxes/macos-ci.json
$ ~/vcpkg/scripts/azure-pipelines/osx/Setup-VagrantMachines.ps1 -Date <box version YYYY-MM-DD> -DevopsPat <PAT>
$ cd ~/vagrant/vcpkg-eg-mac
$ vagrant up # if this fails, reboot through the kvm and/or log in interactively, then come back here
```
[grab a PAT]: #getting-an-azure-pipelines-pat
## Getting an Azure Pipelines PAT
Personal Access Tokens are an important part of this process,
and they are fairly easy to generate.
On ADO, under the correct project (in vcpkg's case, "vcpkg"),
click on the "User Settings" icon, then go to "Personal access tokens".
It is the icon to the left of your user icon, in the top right corner.
Then, create a new token, give it a name, make sure it expires quickly,
and give it a custom defined scope that includes the
"Agent pools: Read & manage" permission (you'll need to "Show all scopes"
to access this).
You can now copy this token and use it to allow machines to join.
## Setting up a new macOS machine
Before anything else, one must download `brew` and `powershell`.
```sh
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
$ brew cask install powershell
```
Then, we need to download the `vcpkg` repository:
```sh
$ git clone https://github.com/microsoft/vcpkg
```
Then, we need to mint an SSH key:
```sh
$ ssh-keygen
$ cat .ssh/id_rsa.pub
```
Add that SSH key to `authorized_keys` on the file share machine with the base box.
Next, install prerequisites:
```sh
$ cd vcpkg/scripts/azure-pipelines/osx
$ ./Install-Prerequisites.ps1 -Force
```
And finally, make sure you can [access ~/vagrant/share][access-fileshare].
## Troubleshooting
The following are issues that we've run into:
- (with a Parallels box) `vagrant up` doesn't work, and vagrant gives the error that the VM is `'stopped'`.
- Try logging into the GUI with the KVM, and retrying `vagrant up`.
- (when running a powershell script) The error `Failed to initialize CoreCLR, HRESULT: 0x8007001F` is printed.
- Reboot the machine; run
```sh
$ sudo shutdown -r now
```
and wait for the machine to start back up. Then, start again from where the error was emitted.
## (Internal) Accessing the macOS fileshare
The fileshare is located on `vcpkgmm-01`, under the `fileshare` user, in the `share` directory.
In order to get `sshfs` working on the physical machine,
You can run `Install-Prerequisites.ps1` to grab the right software, then either:
```sh
$ mkdir -p ~/vagrant/share
$ sshfs fileshare@vcpkgmm-01:share ~/vagrant/share
```
If you get an error, that means that gatekeeper has prevented the kernel extension from loading,
so you'll need to access the GUI of the machine, go to System Preferences,
Security & Privacy, General, unlock the settings,
and allow system extensions from the osxfuse developer to run.
Then, you'll be able to add ~/vagrant/share as an sshfs.
[access-fileshare]: #internal-accessing-the-macos-fileshare

View File

@@ -0,0 +1,126 @@
#!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 MachineId
The number to give the machine; should match [0-9]{2}.
Defaults to the numbers at the end of the machine name,
assuming that that machine name matches `VCPKGMM-[0-9]{2}`.
.PARAMETER DevopsPat
The personal access token which has Read & Manage permissions on the ADO pool.
.PARAMETER Date
The date on which this pool is being created. Sets the default values for BoxVersion and AgentPool.
.PARAMETER BoxVersion
The version of the box to use. If -Date is passed, uses that as the version.
.PARAMETER AgentPool
The agent pool to add the machine to. If -Date is passed, uses "PrOsx-$Date" as the pool.
.PARAMETER DevopsUrl
The URL of the ADO instance; defaults to vcpkg's, which is https://dev.azure.com/vcpkg.
.PARAMETER BaseName
The base name for the vagrant VM; the machine name is $BaseName-$MachineId.
Defaults to 'vcpkg-eg-mac'.
.PARAMETER BoxName
The name of the box to use. Defaults to 'vcpkg/macos-ci',
which is only available internally.
.INPUTS
None
.OUTPUTS
None
#>
[CmdletBinding(PositionalBinding=$False, DefaultParameterSetName='DefineDate')]
Param(
[Parameter(Mandatory=$False)]
[String]$MachineId,
[Parameter(Mandatory=$True)]
[String]$DevopsPat,
[Parameter(Mandatory=$True, ParameterSetName='DefineDate')]
[String]$Date,
[Parameter(Mandatory=$True, ParameterSetName='DefineVersionAndAgentPool')]
[String]$BoxVersion,
[Parameter(Mandatory=$True, ParameterSetName='DefineVersionAndAgentPool')]
[String]$AgentPool,
[Parameter(Mandatory=$False)]
[String]$DevopsUrl = 'https://dev.azure.com/vcpkg',
[Parameter()]
[String]$BaseName = 'vcpkg-eg-mac',
[Parameter()]
[String]$BoxName = 'vcpkg/macos-ci'
)
Set-StrictMode -Version 2
if (-not $IsMacOS) {
throw 'This script should only be run on a macOS host'
}
if (-not [String]::IsNullOrEmpty($Date)) {
$BoxVersion = $Date
$AgentPool = "PrOsx-$Date"
}
if ([String]::IsNullOrEmpty($MachineId)) {
$hostname = hostname -s
if ($hostname -match '^VCPKGMM-([0-9]{2})$') {
$MachineId = $matches[1]
} else {
Write-Error "Hostname ($hostname) does not match the expected format (VCPKGMM-NN). Please pass -MachineId in order to give the VM a number."
}
}
if (Test-Path '~/vagrant/vcpkg-eg-mac') {
Write-Host 'Deleting existing directories'
Push-Location '~/vagrant/vcpkg-eg-mac'
vagrant destroy -f
if (-not $?) {
throw "Failed to destroy vagrant VM."
}
Pop-Location
Remove-Item -Recurse -Force -LiteralPath '~/vagrant/vcpkg-eg-mac' | Out-Null
}
Write-Host 'Creating new directories'
if (-not (Test-Path -Path '~/vagrant')) {
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-vm.rb" `
-Destination '~/vagrant/vcpkg-eg-mac/Vagrantfile'
$configuration = @{
pat = $DevopsPat
agent_pool = $AgentPool
devops_url = $DevopsUrl
machine_name = "${BaseName}-${MachineId}"
box_name = $BoxName
box_version = $BoxVersion
}
ConvertTo-Json -InputObject $configuration -Depth 5 `
| Set-Content -Path '~/vagrant/vcpkg-eg-mac/vagrant-configuration.json'

View File

@@ -0,0 +1,90 @@
#Requires -Version 6.0
Set-StrictMode -Version 2
<#
.SYNOPSIS
Returns whether the specified command exists in the current environment.
.DESCRIPTION
Get-CommandExists takes a string as a parameter,
and returns whether it exists in the current environment;
either a function, alias, or an executable in the path.
It's somewhat equivalent to `which`.
.PARAMETER Name
Specifies the name of the command which may or may not exist.
.INPUTS
System.String
The name of the command.
.OUTPUTS
System.Boolean
Whether the command exists.
#>
function Get-CommandExists
{
[CmdletBinding()]
[OutputType([Boolean])]
Param(
[Parameter(ValueFromPipeline)]
[String]$Name
)
$null -ne (Get-Command -Name $Name -ErrorAction SilentlyContinue)
}
<#
.SYNOPSIS
Downloads a file and checks its hash.
.DESCRIPTION
Get-RemoteFile takes a URI and a hash,
downloads the file at that URI to OutFile,
and checks that the hash of the downloaded file.
It then returns a FileInfo object corresponding to the downloaded file.
.PARAMETER OutFile
Specifies the file path to download to.
.PARAMETER Uri
The URI to download from.
.PARAMETER Sha256
The expected SHA256 of the downloaded file.
.INPUTS
None
.OUTPUTS
System.IO.FileInfo
The FileInfo for the downloaded file.
#>
function Get-RemoteFile
{
[CmdletBinding(PositionalBinding=$False)]
[OutputType([System.IO.FileInfo])]
Param(
[Parameter(Mandatory=$True)]
[String]$OutFile,
[Parameter(Mandatory=$True)]
[String]$Uri,
[Parameter(Mandatory=$True)]
[String]$Sha256
)
Invoke-WebRequest -OutFile $OutFile -Uri $Uri
$actualHash = Get-FileHash -Algorithm SHA256 -Path $OutFile
if ($actualHash.Hash -ne $Sha256) {
throw @"
Invalid hash for file $OutFile;
expected: $Sha256
found: $($actualHash.Hash)
Please make sure that the hash in the powershell file is correct.
"@
}
Get-Item $OutFile
}

View File

@@ -0,0 +1,81 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
#
parameters:
- name: vcpkgToolSha
displayName: 'Custom SHA of vcpkg-tool to use rather than bootstrap'
type: string
default: 'use default'
- name: poolName
type: string
jobs:
- job: x64_osx
pool:
name: ${{ parameters.poolName }}
workspace:
clean: resources
timeoutInMinutes: 2880 # 2 days
variables:
- name: WORKING_ROOT
value: /Users/vagrant/Data
- name: VCPKG_DOWNLOADS
value: /Users/vagrant/Data/downloads
- group: vcpkg-binary-caching-credentials
- name: X_VCPKG_BINARY_SOURCE_STUB
value: "x-azblob,$(root-bin-url),$(sas-bin)" # not in eastasia due to physical location
- group: vcpkg-asset-caching-credentials
- name: X_VCPKG_ASSET_SOURCES
value: "x-azurl,$(root-url-ea),$(sas-ea),readwrite"
steps:
- bash: |
sudo mkdir ${{ variables.VCPKG_DOWNLOADS }} || 0
sudo chmod 777 ${{ variables.VCPKG_DOWNLOADS }} || 0
exit 0
displayName: 'Create ${{ variables.VCPKG_DOWNLOADS }}'
- bash: ./bootstrap-vcpkg.sh
displayName: 'Bootstrap vcpkg'
condition: eq('use default', '${{ parameters.vcpkgToolSha }}')
- bash: |
brew install cmake
./scripts/azure-pipelines/bootstrap-from-source.sh ${{ parameters.vcpkgToolSha }}
displayName: "Build vcpkg with CMake"
condition: ne('use default', '${{ parameters.vcpkgToolSha }}')
- task: PowerShell@2
displayName: '*** Test Modified Ports'
inputs:
failOnStderr: true
filePath: 'scripts/azure-pipelines/test-modified-ports.ps1'
arguments: >
-Triplet "x64-osx"
-BuildReason "$(Build.Reason)"
-BinarySourceStub "${{ variables.X_VCPKG_BINARY_SOURCE_STUB }}"
-WorkingRoot "${{ variables.WORKING_ROOT }}"
-ArtifactStagingDirectory "$(Build.ArtifactStagingDirectory)"
pwsh: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: failure logs for x64-osx'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/failure-logs'
ArtifactName: 'failure logs for x64-osx${{ variables.Postfix }}'
condition: ne(variables['FAILURE_LOGS_EMPTY'], 'True')
- bash: python3 scripts/file_script.py /Users/vagrant/Data/installed/vcpkg/info/
displayName: 'Build a file list for all packages'
condition: always()
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: file lists for x64-osx${{ variables.Postfix }}'
condition: always()
inputs:
PathtoPublish: scripts/list_files
ArtifactName: 'file lists for x64-osx${{ variables.Postfix }}'
- task: PublishTestResults@2
displayName: 'Publish Test Results'
condition: ne(variables['XML_RESULTS_FILE'], '')
inputs:
testRunTitle: x64-osx
testResultsFormat: xUnit
testResultsFiles: $(XML_RESULTS_FILE)
platform: x64-osx
configuration: static

View File

@@ -0,0 +1,35 @@
require 'json'
configuration = JSON.parse(File.read("#{__dir__}/vagrant-box-configuration.json"))
Vagrant.configure('2') do |config|
config.vm.box = 'vcpkg/macos-base'
config.vm.synced_folder '.', '/Users/vagrant/shared'
config.vm.provision 'shell',
run: 'once',
name: 'Install Xcode Command Line Tools: attach dmg file',
inline: 'hdiutil attach shared/clt.dmg -mountpoint /Volumes/setup-installer',
privileged: false
config.vm.provision 'shell',
run: 'once',
name: 'Install Xcode Command Line Tools: run installer',
inline: 'installer -pkg "/Volumes/setup-installer/Command Line Tools.pkg" -target /',
privileged: true
config.vm.provision 'shell',
run: 'once',
name: 'Install XCode Command Line Tools: detach dmg file',
inline: 'hdiutil detach /Volumes/setup-installer',
privileged: false
config.vm.provision 'shell',
run: 'once',
name: 'Install brew',
inline: '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"',
privileged: false
config.vm.provision 'shell',
run: 'once',
name: 'Install brew applications',
inline: "brew install #{configuration['brew'].join(' ')} && brew install --cask #{configuration['brew-cask'].join(' ')}",
privileged: false
end

View File

@@ -0,0 +1,67 @@
require 'json'
configuration = JSON.parse(File.read("#{__dir__}/vagrant-configuration.json"))
server = {
:machine_name => configuration['machine_name'],
:box => configuration['box_name'],
:box_version => configuration['box_version'],
:ram => 24000,
:cpu => 11
}
azure_agent_url = 'https://vstsagentpackage.azureedge.net/agent/2.198.3/vsts-agent-osx-x64-2.198.3.tar.gz'
devops_url = configuration['devops_url']
agent_pool = configuration['agent_pool']
pat = configuration['pat']
Vagrant.configure('2') do |config|
config.vm.box = server[:box]
config.vm.box_version = server[:box_version]
config.vm.synced_folder '.', '/vagrant', disabled: true
config.vm.provider 'parallels' do |prl|
prl.memory = server[:ram]
prl.cpus = server[:cpu]
end
config.vm.provision 'shell',
run: 'once',
name: 'Create the data directory',
inline: "mkdir ~/Data",
privileged: false
config.vm.provision 'shell',
run: 'once',
name: 'Download azure agent',
inline: "curl -s -o ~/Downloads/azure-agent.tar.gz #{azure_agent_url}",
privileged: false
config.vm.provision 'shell',
run: 'once',
name: 'Unpack azure agent',
inline: 'mkdir myagent; cd myagent; tar xf ~/Downloads/azure-agent.tar.gz',
privileged: false
config.vm.provision 'shell',
run: 'once',
name: 'Add VM to azure agent pool',
inline: "cd ~/myagent;\
./config.sh --unattended \
--url #{devops_url} \
--work ~/Data/work \
--auth pat --token #{pat} \
--pool #{agent_pool} \
--agent #{server[:machine_name]} \
--replace \
--acceptTeeEula",
privileged: false
# Start listening for jobs
config.vm.provision 'shell',
run: 'always',
name: 'Start running azure pipelines',
inline: 'cd /Users/vagrant/myagent;\
nohup ./run.sh&',
privileged: false
end

View File

@@ -0,0 +1,53 @@
{
"$schema": "./installables.schema.json",
"Applications": [
{
"Name": "vagrant",
"VersionCommand": [ "vagrant", "-v" ],
"VersionRegex": "Vagrant (.*)",
"Version": "2.2.19",
"DmgUrl": "https://releases.hashicorp.com/vagrant/2.2.19/vagrant_2.2.19_x86_64.dmg",
"Sha256": "6307BE217813A11C9E106448BF232803031E434A08C8B2DF8C62FDC9E8543845",
"InstallerPath": "vagrant.pkg"
},
{
"Name": "Parallels",
"VersionCommand": [ "cat", "/Applications/Parallels Desktop.app/Contents/Info.plist" ],
"VersionRegex": "<key>CFBundleShortVersionString</key>[\\n\\t ]*<string>([0-9.]+)</string>",
"Version": "17.1.1",
"DmgUrl": "https://download.parallels.com/desktop/v17/17.1.1-51537/ParallelsDesktop-17.1.1-51537.dmg",
"Sha256": "BD7BE2DF4D1B3508C127CF1D9C1EF93CDDA63384BCF3893A77FBC9F1169765A9",
"InstallationCommands": [
[ "bash", "-c", "ps x | grep 'Parallels Desktop' | grep -v 'grep' | sed -E 's/^ *([0-9]+).*(\\/Applications.*)$/\\1: \\2/'" ],
[ "bash", "-c", "ps x | grep 'Parallels Desktop' | grep -v 'grep' | sed -E 's/^ *([0-9]+).*$/\\1/' | xargs -p kill" ],
[ "sudo", "rm", "-rf", "/Applications/Parallels Desktop.app" ],
[ "sudo", "cp", "-r", "/Volumes/setup-installer/Parallels Desktop.app", "/Applications" ],
[ "sudo", "/Applications/Parallels Desktop.app/Contents/MacOS/inittool2", "init", "-b", "/Applications/Parallels Desktop.app" ]
]
},
{
"Name": "osxfuse",
"VersionCommand": [ "cat", "/Library/Filesystems/macfuse.fs/Contents/version.plist" ],
"VersionRegex": "<key>CFBundleVersion</key>[\\n\\t ]*<string>([0-9.]+)</string>",
"Version": "4.2.4",
"DmgUrl": "https://github.com/osxfuse/osxfuse/releases/download/macfuse-4.2.4/macfuse-4.2.4.dmg",
"Sha256": "82A2C30B3A7BF56AA2755C0C192FB50D9EECC3FE42505AB4E8679B50306188BD",
"InstallerPath": "Install macFUSE.pkg"
},
{
"Name": "sshfs",
"VersionCommand": [ "sshfs", "--version" ],
"VersionRegex": "SSHFS version [0-9.]* \\(OSXFUSE SSHFS (.*)\\)",
"Version": "2.5.0",
"PkgUrl": "https://github.com/osxfuse/sshfs/releases/download/osxfuse-sshfs-2.5.0/sshfs-2.5.0.pkg",
"Sha256": "F8F4F71814273EA42DBE6CD92199F7CFF418571FFD1B10C0608878D3472D2162"
}
],
"VagrantPlugins": [
{
"Name": "vagrant-parallels",
"Version": "2.2.4"
}
]
}

View File

@@ -0,0 +1,66 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"type": "object",
"definitions": {
"sha256": {
"type": "string",
"pattern": "[A-Z0-9]{64}"
}
},
"required": [
"Applications",
"VagrantPlugins"
],
"properties": {
"Applications": {
"type": "array",
"items": {
"type": "object",
"properties": {
"Name": {
"type": "string"
},
"VersionCommand": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1
},
"VersionRegex": {
"type": "string",
"format": "regex"
},
"Version": {
"type": "string"
},
"DmgUrl": {
"type": "string",
"format": "uri"
},
"Sha256": {
"$ref": "#/definitions/sha256"
},
"InstallerPath": {
"type": "string"
}
}
}
},
"VagrantPlugins": {
"type": "array",
"items": {
"type": "object",
"required": [ "Name", "Version" ],
"properties": {
"Name": {
"type": "string"
},
"Version": {
"type": "string"
}
}
}
}
}
}

View File

@@ -0,0 +1,25 @@
{
"$schema": "./vagrant-box-configuration.schema.json",
"brew": [
"autoconf-archive",
"autoconf",
"automake",
"bison",
"cmake",
"gettext",
"gfortran",
"gperf",
"gtk-doc",
"libtool",
"meson",
"mono",
"nasm",
"ninja",
"pkg-config",
"texinfo",
"yasm"
],
"brew-cask": [
"powershell"
]
}

View File

@@ -0,0 +1,18 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"type": "object",
"required": [
"brew",
"brew-cask"
],
"properties": {
"brew": {
"type": "array",
"items": { "type": "string" }
},
"brew-cask": {
"type": "array",
"items": { "type": "string" }
}
}
}

View File

@@ -0,0 +1,35 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"type": "object",
"required": [
"pat",
"agent_pool",
"devops_url",
"machine_name",
"box_name",
"box_version"
],
"properties": {
"pat": {
"type": "string"
},
"agent_pool": {
"type": "string"
},
"devops_url": {
"type": "string"
},
"machine_name": {
"type": "string"
},
"box_name": {
"type": "string"
},
"box_version": {
"type": "string"
}
}
}