Skip to content
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

Add github actions #398

Merged
merged 1 commit into from
Sep 24, 2024
Merged
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
63 changes: 63 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Windows Image Builder tests

on: [push, pull_request]

jobs:
code_checks:
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Dependencies
shell: powershell
run: |
Install-Module -Force -AllowClobber -Confirm:$false "PSScriptAnalyzer"
- name: Run code checks
shell: powershell
run: |
$rules = @("PSProvideCommentHelp","PSUseDeclaredVarsMoreThanAssignments","PSAvoidUsingEmptyCatchBlock","PSAvoidUsingCmdletAliases","PSAvoidDefaultValueForMandatoryParameter","PSAvoidDefaultValueSwitchParameter","PSUseToExportFieldsInManifest","PSAvoidUsingPositionalParameters");
$resScryptAnalyzer = Invoke-ScriptAnalyzer -Path . -IncludeRule $rules;
if ($resScryptAnalyzer.Count -gt 0) {
throw "$($resScryptAnalyzer.Count) failed style warnings found."
}
functional_tests_2019:
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Dependencies
shell: powershell
run: |
Uninstall-Module "Pester" -Force
Install-Module -Force -AllowClobber -Confirm:$false "Pester" -RequiredVersion 4.10.1 -SkipPublisherCheck
- name: Run code checks
shell: powershell
run: |
Import-Module Pester
$res = Invoke-Pester -OutputFormat NUnitXml -OutputFile TestsResults.xml -PassThru
if (($res.FailedCount -gt 0)) {
Get-Content -Path TestsResults.xml -Encoding Ascii | Write-Output
throw "$($res.FailedCount) Pester tests failed."
}
functional_tests_latest:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Dependencies
shell: powershell
run: |
Uninstall-Module "Pester" -Force
Install-Module -Force -AllowClobber -Confirm:$false "Pester" -RequiredVersion 4.10.1 -SkipPublisherCheck
- name: Run code checks
shell: powershell
run: |
Import-Module Pester
$res = Invoke-Pester -OutputFormat NUnitXml -OutputFile TestsResults.xml -PassThru
if (($res.FailedCount -gt 0)) {
Get-Content -Path TestsResults.xml -Encoding Ascii | Write-Output
throw "$($res.FailedCount) Pester tests failed."
}
5 changes: 4 additions & 1 deletion Tests/WinImageBuilder.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ function Get-VMSwitch {}

function Optimize-VHD {}

Import-Module $modulePath
$LastErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = "Stop"
Import-Module "${modulePath}"
$ErrorActionPreference = $LastErrorActionPreference

Describe "Test New-WindowsCloudImage" {
Mock Write-Host -Verifiable -ModuleName $moduleName { return 0 }
Expand Down
20 changes: 0 additions & 20 deletions appveyor.yml

This file was deleted.