[Windows] Implement new directories hierarchy (#8616)

This commit is contained in:
Vasilii Polikarpov
2023-11-15 11:24:45 +01:00
committed by GitHub
parent 84a7deae24
commit d1f2c9a3be
165 changed files with 1146 additions and 1139 deletions

View File

@@ -5,7 +5,7 @@ on:
pull_request_target: pull_request_target:
types: labeled types: labeled
paths: paths:
- 'images/win/**' - 'images/windows/**'
defaults: defaults:
run: run:

View File

@@ -5,7 +5,7 @@ on:
pull_request_target: pull_request_target:
types: labeled types: labeled
paths: paths:
- 'images/win/**' - 'images/windows/**'
defaults: defaults:
run: run:

View File

@@ -34,18 +34,18 @@ Here are a few things you can do that will increase the likelihood of your pull
- For every new tool add validation scripts and update software report script to make sure that it is included to documentation - For every new tool add validation scripts and update software report script to make sure that it is included to documentation
- If the tool is available in other platforms (macOS, Windows, Linux), make sure you include it in as many as possible. - If the tool is available in other platforms (macOS, Windows, Linux), make sure you include it in as many as possible.
- If installing a few versions of the tool, consider putting the list of versions in the corresponding `toolset.json` file. It will help other customers to configure their builds flexibly. See [toolset-windows-2019.json](images/win/toolsets/toolset-2019.json) as example. - If installing a few versions of the tool, consider putting the list of versions in the corresponding `toolset.json` file. It will help other customers to configure their builds flexibly. See [toolset-windows-2019.json](images/windows/toolsets/toolset-2019.json) as example.
- Use consistent naming across all files - Use consistent naming across all files
- Validation scripts should be simple and shouldn't change image content - Validation scripts should be simple and shouldn't change image content
### Windows ### Windows
- Add a script that will install the tool and put the script in the `scripts/Installers` folder. - Add a script that will install the tool and put the script in the `scripts/build` folder.
There are a bunch of helper functions that could simplify your code: `Choco-Install`, `Install-Binary`, `Install-VsixExtension`, `Start-DownloadWithRetry`, `Test-IsWin19`, `Test-IsWin22` (find the full list of helpers in [ImageHelpers.psm1](images/win/scripts/ImageHelpers/ImageHelpers.psm1)). There are a bunch of helper functions that could simplify your code: `Choco-Install`, `Install-Binary`, `Install-VsixExtension`, `Start-DownloadWithRetry`, `Test-IsWin19`, `Test-IsWin22` (find the full list of helpers in [ImageHelpers.psm1](images/windows/scripts/helpers/ImageHelpers.psm1)).
- Add a script that will validate the tool installation and put the script in the `scripts/Tests` folder. - Add a script that will validate the tool installation and put the script in the `scripts/tests` folder.
We use [Pester v5](https://github.com/pester/pester) for validation scripts. If the tests for the tool are complex enough, create a separate `*.Tests.ps1`. Otherwise, use `Tools.Tests.ps1` for simple tests. We use [Pester v5](https://github.com/pester/pester) for validation scripts. If the tests for the tool are complex enough, create a separate `*.Tests.ps1`. Otherwise, use `Tools.Tests.ps1` for simple tests.
Add `Invoke-PesterTests -TestFile <testFileName> [-TestName <describeName>]` at the end of the installation script to make sure that your tests will be run. Add `Invoke-PesterTests -TestFile <testFileName> [-TestName <describeName>]` at the end of the installation script to make sure that your tests will be run.
- Add changes to the software report generator `images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1`. The software report generator is used to generate an image's README file, e.g. [Windows2019-Readme.md](images/win/Windows2019-Readme.md) and uses [MarkdownPS](https://github.com/Sarafian/MarkdownPS). - Add changes to the software report generator `images/windows/scripts/docs-gen/SoftwareReport.Generator.ps1`. The software report generator is used to generate an image's README file, e.g. [Windows2019-Readme.md](images/windows/Windows2019-Readme.md) and uses [MarkdownPS](https://github.com/Sarafian/MarkdownPS).
### Ubuntu ### Ubuntu

View File

@@ -36,12 +36,11 @@ To build a VM machine from this repo's source, see the [instructions](docs/creat
[ubuntu-22.04]: https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md [ubuntu-22.04]: https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md
[ubuntu-20.04]: https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2004-Readme.md [ubuntu-20.04]: https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2004-Readme.md
[windows-2022]: https://github.com/actions/runner-images/blob/main/images/win/Windows2022-Readme.md [windows-2022]: https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md
[windows-2019]: https://github.com/actions/runner-images/blob/main/images/win/Windows2019-Readme.md [windows-2019]: https://github.com/actions/runner-images/blob/main/images/windows/Windows2019-Readme.md
[macOS-11]: https://github.com/actions/runner-images/blob/main/images/macos/macos-11-Readme.md [macOS-11]: https://github.com/actions/runner-images/blob/main/images/macos/macos-11-Readme.md
[macOS-12]: https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md [macOS-12]: https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md
[macOS-13]: https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md [macOS-13]: https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md
[macOS-10.15]: https://github.com/actions/runner-images/blob/main/images/macos/macos-10.15-Readme.md
[self-hosted runners]: https://help.github.com/en/actions/hosting-your-own-runners [self-hosted runners]: https://help.github.com/en/actions/hosting-your-own-runners
## Announcements ## Announcements

View File

@@ -216,7 +216,7 @@ Where:
- `InstallPassword` - password for the user used to install software (Windows only) - `InstallPassword` - password for the user used to install software (Windows only)
- `Location` - location where resources will be created (e.g. "East US") - `Location` - location where resources will be created (e.g. "East US")
- `ImageName` and `ImageResourceGroupName` - name of the resource group where managed image will be stored - `ImageName` and `ImageResourceGroupName` - name of the resource group where managed image will be stored
- `TemplatePath` - path to the Packer template file (e.g. "images/win/windows2022.json") - `TemplatePath` - path to the Packer template file (e.g. "images/windows/templates/windows-2022.json")
### Required variables ### Required variables
@@ -269,9 +269,9 @@ Generated tool versions and details can be found in related projects:
> :warning: These scripts are intended to run on a VM deployed in Azure > :warning: These scripts are intended to run on a VM deployed in Azure
The user, created during the image generation, does not exist in the result image hence some configuration files related to the user's home directory need to be changed as well as the file permissions for some directories. Scripts for that are located in the `post-generation` folder in the repository: The user, created during the image generation, does not exist in the result image hence some configuration files related to the user's home directory need to be changed as well as the file permissions for some directories. Scripts for that are located in the `post-gen` folder in the repository:
- Windows: <https://github.com/actions/runner-images/tree/main/images/win/post-generation> - Windows: <https://github.com/actions/runner-images/tree/main/images/windows/assets/post-gen>
- Linux: <https://github.com/actions/runner-images/tree/main/images/linux/post-generation> - Linux: <https://github.com/actions/runner-images/tree/main/images/linux/post-generation>
**Note:** The default user for Linux should have `sudo privileges`. **Note:** The default user for Linux should have `sudo privileges`.

View File

@@ -18,10 +18,10 @@ Function Get-PackerTemplatePath {
switch ($ImageType) { switch ($ImageType) {
([ImageType]::Windows2019) { ([ImageType]::Windows2019) {
$relativeTemplatePath = Join-Path "win" "windows2019.json" $relativeTemplatePath = Join-Path "windows" "templates" "windows-2019.json"
} }
([ImageType]::Windows2022) { ([ImageType]::Windows2022) {
$relativeTemplatePath = Join-Path "win" "windows2022.json" $relativeTemplatePath = Join-Path "windows" "templates" "windows-2022.json"
} }
([ImageType]::Ubuntu2004) { ([ImageType]::Ubuntu2004) {
$relativeTemplatePath = Join-Path "linux" "ubuntu2004.json" $relativeTemplatePath = Join-Path "linux" "ubuntu2004.json"

View File

@@ -12,6 +12,9 @@ parameters:
- name: image_type - name: image_type
type: string type: string
- name: image_template_name
type: string
- name: image_readme_name - name: image_readme_name
type: string type: string
@@ -62,11 +65,17 @@ jobs:
targetType: 'inline' targetType: 'inline'
script: | script: |
$ImageType = "${{ parameters.image_type }}" $ImageType = "${{ parameters.image_type }}"
$TemplateDirectoryName = if ($ImageType.StartsWith("ubuntu")) { "linux" } else { "win" } $TemplateDirectoryName = if ($ImageType.StartsWith("ubuntu")) { "linux" } else { "windows/templates" }
$TemplateDirectoryPath = Join-Path "images" $TemplateDirectoryName | Resolve-Path $TemplateDirectoryPath = Join-Path "images" $TemplateDirectoryName | Resolve-Path
$TemplatePath = Join-Path $TemplateDirectoryPath "$ImageType.pkr.hcl"
if ( -not (Test-Path $TemplatePath) ) { $TemplateFileName = "${{ parameters.image_template_name }}"
$TemplatePath = Join-Path $TemplateDirectoryPath "$ImageType.json" if ($TemplateFileName) {
$TemplatePath = Join-Path $TemplateDirectoryPath $TemplateFileName
} else {
$TemplatePath = Join-Path $TemplateDirectoryPath "$ImageType.pkr.hcl"
if ( -not (Test-Path $TemplatePath) ) {
$TemplatePath = Join-Path $TemplateDirectoryPath "$ImageType.json"
}
} }
Write-Host "##vso[task.setvariable variable=TemplateDirectoryPath;]$TemplateDirectoryPath" Write-Host "##vso[task.setvariable variable=TemplateDirectoryPath;]$TemplateDirectoryPath"
Write-Host "##vso[task.setvariable variable=TemplatePath;]$TemplatePath" Write-Host "##vso[task.setvariable variable=TemplatePath;]$TemplatePath"
@@ -104,8 +113,12 @@ jobs:
inputs: inputs:
targetType: 'inline' targetType: 'inline'
script: | script: |
$readmePath = Join-Path "$(TemplateDirectoryPath)" "${{ parameters.image_readme_name }}" $ImageType = "${{ parameters.image_type }}"
$softwareReportPath = Join-Path "$(TemplateDirectoryPath)" "software-report.json" $rootDirectoryName = if ($ImageType.StartsWith("ubuntu")) { "linux" } else { "windows" }
$rootDirectoryPath = Join-Path "images" $rootDirectoryName | Resolve-Path
$readmePath = Join-Path $rootDirectoryPath "${{ parameters.image_readme_name }}"
$softwareReportPath = Join-Path $rootDirectoryPath "software-report.json"
Copy-Item -Path $readmePath -Destination "$(Build.ArtifactStagingDirectory)/" Copy-Item -Path $readmePath -Destination "$(Build.ArtifactStagingDirectory)/"
if (Test-Path $softwareReportPath) { if (Test-Path $softwareReportPath) {

View File

@@ -18,3 +18,4 @@ jobs:
parameters: parameters:
image_type: windows2019 image_type: windows2019
image_readme_name: Windows2019-Readme.md image_readme_name: Windows2019-Readme.md
image_template_name: windows-2019.json

View File

@@ -18,3 +18,4 @@ jobs:
parameters: parameters:
image_type: windows2022 image_type: windows2022
image_readme_name: Windows2022-Readme.md image_readme_name: Windows2022-Readme.md
image_template_name: windows-2022.json

View File

@@ -1 +0,0 @@
Common scripts for all Windows images regardless of Visual Studio or OS version

Some files were not shown because too many files have changed in this diff Show More