Skip to content

Commit

Permalink
Merge pull request #398 from ader1990/add_github_actions_v2
Browse files Browse the repository at this point in the history
Add github actions
  • Loading branch information
ader1990 authored Sep 24, 2024
2 parents be8180d + 073553b commit 4ce090f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 21 deletions.
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.

0 comments on commit 4ce090f

Please sign in to comment.