Skip to content
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
26 changes: 26 additions & 0 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Dockerfile to test the library with multiple versions of PowerShell >= 7.
#
# Example run (from repo root):
# > $version="7.1.5"; docker build -f .\test\docker\Dockerfile . -t powershell-featureflags-test:$version --build-arg VERSION=$version --build-arg UBUNTU_VERSION=18.04 && docker run powershell-featureflags-test:$version

ARG VERSION=7.2.5
ARG UBUNTU_VERSION=16.04
FROM mcr.microsoft.com/powershell:${VERSION}-ubuntu-${UBUNTU_VERSION}

# Install dotnet SDK.
#
# Not using the dotnet SDK images because they bring their own powershell,
# see for example https://github.com/dotnet/dotnet-docker/blob/main/src/sdk/6.0/focal/amd64/Dockerfile.
ENV DOTNET_SDK_VERSION=6.0.301
RUN curl -fSL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz
RUN mkdir -p /usr/share/dotnet
RUN tar -oxzf dotnet.tar.gz -C /usr/share/dotnet
RUN rm dotnet.tar.gz
RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet

# Copy the application code.
WORKDIR /app
COPY . .

# Restore dependencies and run tests.
CMD pwsh tools/restore.ps1; pwsh tools/run-tests.ps1
13 changes: 3 additions & 10 deletions tools/run-tests.ps1
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
# Mostly for use of CI/CD. Install Pester and run tests.
param (
# Set to true to install Pester 5.1.0, regardless of whether a Pester version
# is present in the environment.
[switch] $InstallPester = $false
)

$parentDir = Split-Path -Parent (Split-Path -Parent $PSCommandPath)
$testDir = Join-Path $parentDir -ChildPath "test"

# Debug info.
$PSVersionTable | Out-String
$RequiredPesterVersion = "5.3.3"
Write-Host "PowerShell version" $PSVersionTable.PSVersion

$RequiredPesterVersion = "5.3.3"
$pesterVersions = Get-Module -ListAvailable | Where-Object {$_.Name -eq "Pester" -and $_.Version -eq $RequiredPesterVersion}

$InstallPester = $false
if ($pesterVersions.Count -eq 0) {
Write-Warning "Pester $RequiredPesterVersion not found, installing it."
$InstallPester = $true
Expand Down