Skip to content

Commit 6589daf

Browse files
deadlydogCopilot
andcommitted
chore: Add Dockerfile and VS Code task for running pester tests in a container
Co-authored-by: Copilot <copilot@github.com>
1 parent b20c2d2 commit 6589daf

2 files changed

Lines changed: 73 additions & 0 deletions

File tree

.vscode/tasks.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,51 @@
140140
"problemMatcher": [
141141
"$func-powershell-watch"
142142
]
143+
},
144+
{
145+
"label": "Build Docker image for Pester tests",
146+
"type": "shell",
147+
"options": {
148+
"shell": {
149+
"executable": "pwsh",
150+
"args": [
151+
"-NoProfile",
152+
"-Command"
153+
]
154+
}
155+
},
156+
"command": "docker build -t pester-tests:latest .",
157+
"group": "build",
158+
"presentation": {
159+
"reveal": "always",
160+
"panel": "dedicated",
161+
"clear": true
162+
},
163+
"problemMatcher": []
164+
},
165+
{
166+
"label": "Run Pester tests in Docker",
167+
"type": "shell",
168+
"options": {
169+
"shell": {
170+
"executable": "pwsh",
171+
"args": [
172+
"-NoProfile",
173+
"-Command"
174+
]
175+
}
176+
},
177+
"command": "docker run --rm -e AZURE_ARTIFACTS_TESTING_FEED_PAT=$Env:AZURE_ARTIFACTS_TESTING_FEED_PAT pester-tests:latest",
178+
"dependsOn": [
179+
"Build Docker image for Pester tests"
180+
],
181+
"group": "test",
182+
"presentation": {
183+
"reveal": "always",
184+
"panel": "dedicated",
185+
"clear": true
186+
},
187+
"problemMatcher": []
143188
}
144189
]
145190
}

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Use .NET 10 runtime as base image
2+
FROM mcr.microsoft.com/dotnet/sdk:10.0
3+
4+
# Install PowerShell
5+
RUN apt-get update && \
6+
apt-get install -y curl gnupg apt-transport-https && \
7+
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
8+
echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye main" > /etc/apt/sources.list.d/microsoft.list && \
9+
apt-get update && \
10+
apt-get install -y powershell && \
11+
apt-get clean && \
12+
rm -rf /var/lib/apt/lists/*
13+
14+
# Create working directory
15+
WORKDIR /workspace
16+
17+
# Copy the module and tests into the container
18+
COPY . .
19+
20+
# Set PowerShell as the default shell
21+
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
22+
23+
# Install required PowerShell modules
24+
RUN Install-Module -Name PowerShellGet -RequiredVersion 2.2.5 -Force && \
25+
Install-Module -Name Pester -Force
26+
27+
# Run Pester tests
28+
ENTRYPOINT ["pwsh", "-NoProfile", "-Command", "Invoke-Pester -Configuration (New-PesterConfiguration @{ Output = @{ Verbosity = 'Detailed' }})"]

0 commit comments

Comments
 (0)