Skip to content

Commit a078f14

Browse files
committed
Move Docker tests to GitHub Actions
1 parent 42b486c commit a078f14

File tree

5 files changed

+42
-54
lines changed

5 files changed

+42
-54
lines changed

.appveyor.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ skip_commits:
2222
environment:
2323
PsgKey:
2424
secure: tlhLuUS6x8FcP159+X/EIBDlj9m+u5KCTTuqwzsiNHlPX6K4AolpaZcfAP4ClOdB
25-
matrix:
26-
- DOCKER_IMAGE:
27-
- DOCKER_IMAGE: nanoserver
28-
- DOCKER_IMAGE: windowsservercore
2925

3026
cache:
3127
- test\download-cache -> .appveyor.yml
@@ -36,23 +32,11 @@ cache:
3632
build: off
3733

3834
install:
39-
- ps: |
40-
if ($null -eq $Env:DOCKER_IMAGE -or $Env:DOCKER_IMAGE -eq '') {
41-
.\test\setup.ps1
42-
} else {
43-
& ".\test\Dockerfile.$Env:DOCKER_IMAGE.ps1"
44-
}
45-
35+
- ps: .\test\setup.ps1
4636
test_script:
4737
- ps: |
48-
if ($null -eq $Env:DOCKER_IMAGE -or $Env:DOCKER_IMAGE -eq '') {
49-
$pesterResult = .\test\pester.ps1
50-
$failCount = $pesterResult.FailedCount
51-
} else {
52-
$volume="$($Env:APPVEYOR_BUILD_FOLDER):C:\App"
53-
docker run --rm --volume $volume --workdir C:\App --env "PM_TEST_DOCKER=1" phpmanager/test powershell.exe 'Set-Location -LiteralPath C:\App; $pesterResult=.\test\pester.ps1; exit $pesterResult.FailedCount'
54-
$failCount = $LASTEXITCODE
55-
}
38+
$pesterResult = .\test\pester.ps1
39+
$failCount = $pesterResult.FailedCount
5640
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path -LiteralPath .\TestsResults.xml))
5741
if ($failCount -ne 0) {
5842
throw "$failCount tests failed!"

.github/workflows/test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,31 @@ jobs:
5757
if ($pesterResult.FailedCount -ne 0) {
5858
throw "$($pesterResult.FailedCount) tests failed!"
5959
}
60+
docker:
61+
strategy:
62+
matrix:
63+
docker-image:
64+
- nanoserver
65+
- windowsservercore
66+
name: Docker (${{ matrix.docker-image }})
67+
runs-on: windows-latest
68+
steps:
69+
- name: Debug
70+
run: Get-ChildItem 'C:\\Program Files\\Docker'
71+
- name: Enabling Windows containers
72+
run: "& 'C:\\Program Files\\Docker\\DockerCli.exe' -SwitchWindowsEngine"
73+
- name: Checkout
74+
uses: actions/checkout@v2
75+
with:
76+
fetch-depth: 1
77+
- name: Prepare files for Docker image
78+
run: .\test\Prepare-Dockerfile.ps1 "${{ matrix.docker-image }}"
79+
- name: Build Docker image
80+
run: docker build --tag phpmanager/test .\test\docker-build
81+
- name: Test
82+
run: |
83+
docker run --rm --volume "$($Env:GITHUB_WORKSPACE):C:\App" --workdir C:\App --env "PM_TEST_DOCKER=1" phpmanager/test powershell.exe 'pesterResult=.\test\pester.ps1; exit $pesterResult.FailedCount'
84+
$failCount = $LASTEXITCODE
85+
if ($failCount -ne 0) {
86+
throw "$failCount tests failed!"
87+
}

test/Dockerfile.nanoserver.ps1

Lines changed: 0 additions & 17 deletions
This file was deleted.

test/Dockerfile.windowsservercore.ps1

Lines changed: 0 additions & 18 deletions
This file was deleted.

test/Prepare-Dockerfile.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
param ([string] $DockerImage)
2+
3+
$dockerBuildPath = Join-Path -Path $PSScriptRoot -ChildPath docker-build
4+
if (-Not(Test-Path -LiteralPath $dockerBuildPath)) {
5+
New-Item -ItemType Directory -Path $dockerBuildPath | Out-Null
6+
}
7+
Copy-Item -LiteralPath "$($Env:SystemRoot)\System32\vcruntime140.dll" -Destination $dockerBuildPath
8+
Copy-Item -LiteralPath "$($Env:SystemRoot)\System32\vcomp140.dll" -Destination $dockerBuildPath
9+
Copy-Item -LiteralPath (Join-Path -Path $PSScriptRoot -ChildPath setup-nodejs.ps1) -Destination $dockerBuildPath
10+
Copy-Item -LiteralPath (Join-Path -Path $PSScriptRoot -ChildPath setup.ps1) -Destination $dockerBuildPath
11+
Copy-Item -LiteralPath (Join-Path -Path $PSScriptRoot -ChildPath "Dockerfile.$DockerImage") -Destination (Join-Path -Path $dockerBuildPath -ChildPath Dockerfile)

0 commit comments

Comments
 (0)