Skip to content

[DO NOT MERGE] add windows container docker file #158

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

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 183 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
name: Test

on:
pull_request:
paths-ignore:
- 'docs/**'
- 'docker/**'
branches:
- master
- dev
workflow_dispatch:
inputs:
modules:
description: 'Comma-separated list of modules to run tests for. Leave empty to run all modules. E.g., an input could be "Azs.AzureBridge.Admin,Azs.Backup.Admin,Azs.Commerce.Admin".'
required: false

jobs:
Prepare:
runs-on: windows-2019
steps:
- name: Checkout ${{ github.repository }}.
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}

- name: Resolve modules to run.
id: resolve_modules_to_run
shell: pwsh
run: |
Import-Module -Name ([System.IO.Path]::Combine("${{ github.workspace }}", "tools", "WorkflowUtility.psm1"))
[string[]] $excludeDirectories = @("Az.BootStrapper", "Azs.Deployment.Admin", "AzureStack")
$excludeDirectoriesSet = [System.Collections.Generic.HashSet[string]]::new($excludeDirectories, [StringComparer]::InvariantCultureIgnoreCase)
$validModules = New-Object System.Collections.Generic.HashSet[string]
Get-ChildItem -Path ([System.IO.Path]::Combine("${{ github.workspace }}", "src")) -Directory `
| Where-Object {!$excludeDirectoriesSet.Contains($_.Name)} `
| Foreach-Object {$validModules.Add($_.Name) | Out-Null}
$modulesToRun = @()
Write-Host "Github event name: ${{ github.event_name }}"
if ("${{ github.event_name }}" -eq "pull_request")
{
Write-Host "Resolving modules for pull request..."
Push-Location -Path "${{ github.workspace }}"
# Get modified files.
$modifiedModules = New-Object System.Collections.Generic.HashSet[string]
git fetch origin ${{ github.event.pull_request.base.ref }}
git diff --name-only origin/${{ github.event.pull_request.base.ref }} `
| Where-Object {$_ -like "*Azs.*"} `
| ForEach-Object {($_ -split "/",3)[1]} `
| Where-Object {!$excludeDirectoriesSet.Contains($_)} `
| ForEach-Object {$modifiedModules.Add($_) | Out-Null}
Pop-Location

if ($modifiedModules.Count)
{
$modulesToRun = [String[]] $modifiedModules
}
}
elseif ("${{ github.event.inputs.modules }}")
{
# Run modules input by the user.
Write-Host "Resolving modules from user input..."
$userInputModules = "${{ github.event.inputs.modules }}" -Split ","
# Check for invalid modules. Excluded modules are also invalid.
$invalidModules = $userInputModules | Where-Object {!$validModules.Contains($_)}
if ($invalidModules)
{
throw "Error: invalid modules in input. Note that some modules are excluded from running. Invalid modules:`n$($invalidModules | Out-Host)"
}
$modulesToRun = $userInputModules
}
elseif ("${{ github.event_name }}" -eq "workflow_dispatch")
{
# If workflow_dispatch is kicked off but input is empty, default is to run all valid modules.
Write-Host "Running all valid modules in the src directory..."
$modulesToRun = [String[]] $validModules
}

if(!$modulesToRun -or !$modulesToRun.Count)
{
Write-Host "No modules to run, testing will be skipped!"
}
else
{
Write-Host "Running the following modules:"
$modulesToRun | Out-Host
}

$modulesToRun = Convert-FromArrayToJsonArrayString -ArrayOfStrings $modulesToRun
echo "::set-output name=MODULES_TO_RUN::${modulesToRun}"

outputs:
MODULES_TO_RUN: ${{ steps.resolve_modules_to_run.outputs.MODULES_TO_RUN }}

Test:
runs-on: windows-2019
needs: Prepare
if: ${{ needs.Prepare.outputs.MODULES_TO_RUN != '[]' && needs.Prepare.outputs.MODULES_TO_RUN != '' }}
strategy:
fail-fast: false
matrix:
MODULES_TO_RUN: ${{ fromJson(needs.Prepare.outputs.MODULES_TO_RUN) }}
steps:
- name: Checkout ${{ github.repository }}.
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}

- name: Run Azure Stack PowerShell tests.
id: run_tests
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
Write-Host "Node JS version: $(node --version)"
Write-Host "Starting autorest tests..."
Write-Host "Installing autorest..."
#INSTALL AUTOREST (requires Node JS for npm command)
npm install -g autorest@latest

$modulePath = [System.IO.Path]::Combine("${{ github.workspace }}", "src", "${{ matrix.MODULES_TO_RUN }}")
Push-Location -Path $modulePath

#GENERATE
$env:NODE_OPTIONS="--max-old-space-size=16684"
Write-Host "Running autorest..."
autorest

#BUILD
dotnet add package PowerShellStandard.Library --version 5.1.0
$azAccountsVersion = "2.2.8"
Write-Host "Installing Az.Accounts ${azAccountsVersion}..."
Install-Module -Name Az.Accounts -Repository PSGallery -RequiredVersion $azAccountsVersion -Force -Scope CurrentUser
Import-Module -Name Az.Accounts -RequiredVersion $azAccountsVersion
Write-Host "Running build-module.ps1..."
./build-module.ps1
if ($LASTEXITCODE)
{
throw "Error while running build-module.ps1."
}

#TEST
Remove-Module Pester -Force -ErrorAction SilentlyContinue
Uninstall-Module Pester -Force -ErrorAction SilentlyContinue
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted

$azResourcesVersion = "0.12.0"
Write-Host "Installing Az.Resources ${azResourcesVersion}..."
Install-Module -Name Az.Resources -Repository PSGallery -RequiredVersion $azResourcesVersion -Force -Scope CurrentUser
Import-Module -Name Az.Resources -RequiredVersion $azResourcesVersion

$pesterVersion = "4.10.1"
Write-Host "Installing Pester ${pesterVersion}..."
Install-Module -Name Pester -RequiredVersion $pesterVersion -Force -SkipPublisherCheck
Import-Module -Name Pester -RequiredVersion $pesterVersion

Write-Host "Running test-module.ps1..."
./test-module.ps1
if ($LASTEXITCODE)
{
throw "Error while running test-module.ps1."
}

#PACKAGE
Write-Host "Running pack-module.ps1..."
./pack-module.ps1
if ($LASTEXITCODE)
{
throw "Error while running pack-module.ps1."
}

echo "::set-output name=MODULE_PATH::${modulePath}"
Pop-Location
Write-Host "Ending autorest tests."

- name: Upload module nupkgs.
uses: actions/upload-artifact@v3
with:
name: ${{ github.run_id }}-${{ matrix.MODULES_TO_RUN }}
path: ${{ steps.run_tests.outputs.MODULE_PATH }}/bin/*.nupkg





1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ obj
generated
internal
exports
src/**/utils
src/**/tools
src/**/resources
.gitignore
Expand Down
Empty file added docker/Dockerfile-windows
Empty file.
135 changes: 0 additions & 135 deletions src/Azs.Backup.Admin/custom/Clear-AzsBackupConfiguration.ps1

This file was deleted.

20 changes: 2 additions & 18 deletions src/Azs.Backup.Admin/custom/Get-AzsBackup.ps1
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@

# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.Synopsis
Returns a backup from a location based on name.
Expand All @@ -23,10 +8,9 @@ To view examples, please use the -Online parameter with Get-Help or navigate to:
.Inputs
Microsoft.Azure.PowerShell.Cmdlets.BackupAdmin.Models.IBackupAdminIdentity
.Outputs
Microsoft.Azure.PowerShell.Cmdlets.BackupAdmin.Models.Api20210901.IBackup
Microsoft.Azure.PowerShell.Cmdlets.BackupAdmin.Models.Api20180901.IBackup
.Notes
COMPLEX PARAMETER PROPERTIES

To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.

INPUTOBJECT <IBackupAdminIdentity>: Identity Parameter
Expand All @@ -39,7 +23,7 @@ INPUTOBJECT <IBackupAdminIdentity>: Identity Parameter
https://docs.microsoft.com/en-us/powershell/module/azs.backup.admin/get-azsbackup
#>
function Get-AzsBackup {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.BackupAdmin.Models.Api20210901.IBackup])]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.BackupAdmin.Models.Api20180901.IBackup])]
[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)]
param(
[Parameter(ParameterSetName='Get')]
Expand Down
Loading