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

Test (ci): Add execution of tests on Github Actions #17

Merged
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
116 changes: 116 additions & 0 deletions .github/workflows/ci-master-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: ci-master-pr

on:
push:
branches:
- master
tags:
- '**'
pull_request:
branches:
- master

jobs:
test-powershell-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
- name: Test
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command './test/test.ps1'

test-powershell-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
- name: Test
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command './test/test.ps1'

test-powershell-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
- name: Test
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command './test/test.ps1'

test-powershell-5-1-windows-2019:
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Powershell version
run: |
powershell -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
- name: Test
run: |
powershell -NoLogo -NonInteractive -NoProfile -Command './test/test.ps1'

##########
# Docker #
##########
# Get powershell tags: https://mcr.microsoft.com/v2/powershell/tags/list
test-powershell-7-2:
runs-on: ubuntu-latest
container:
image: theohbrothers/docker-powershell:7.2-ubuntu-22.04-git
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
- name: Test
run: |
git config --global --add safe.directory '*'
pwsh -NoLogo -NonInteractive -NoProfile -Command './test/test.ps1'

test-powershell-7-3:
runs-on: ubuntu-latest
container:
image: theohbrothers/docker-powershell:7.3-ubuntu-22.04-git
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
- name: Test
run: |
git config --global --add safe.directory '*'
pwsh -NoLogo -NonInteractive -NoProfile -Command './test/test.ps1'

test-powershell-7-4:
runs-on: ubuntu-latest
container:
image: theohbrothers/docker-powershell:7.4-ubuntu-22.04-git
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
- name: Test
run: |
git config --global --add safe.directory '*'
pwsh -NoLogo -NonInteractive -NoProfile -Command './test/test.ps1'
25 changes: 25 additions & 0 deletions test/Install-TestDependencies.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[CmdletBinding()]
param()

$ErrorActionPreference = 'Stop'

try {
Push-Location $PSScriptRoot

# Install Pester if needed
"Checking Pester version" | Write-Host
$pesterMinimumVersion = [version]'4.0.0'
$pesterMaximumVersion = [version]'4.10.1'
$pester = Get-Module 'Pester' -ListAvailable -ErrorAction SilentlyContinue
if (!$pester -or !($pester | ? { $_.Version -ge $pesterMinimumVersion -and $_.Version -le $pesterMaximumVersion })) {
"Installing Pester" | Write-Host
Install-Module -Name 'Pester' -Repository 'PSGallery' -MinimumVersion $pesterMinimumVersion -MaximumVersion $pesterMaximumVersion -Scope CurrentUser -Force
}
Get-Module Pester -ListAvailable | Out-String | Write-Verbose
Import-Module -Name 'Pester' -RequiredVersion '4.10.1' -Force # Force import to ensure environment uses the correct version of Pester

}catch {
throw
}finally{
Pop-Location
}
4 changes: 2 additions & 2 deletions test/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ try {
Push-Location $PSScriptRoot

# Install test dependencies
# "Installing test dependencies" | Write-Verbose
# & "$PSScriptRoot\scripts\dep\Install-TestDependencies.ps1" > $null
"Installing test dependencies" | Write-Verbose
& "$PSScriptRoot\Install-TestDependencies.ps1" > $null

# Run unit tests
"Running unit tests" | Write-Verbose
Expand Down
Loading