Skip to content

Commit

Permalink
Move Docker tests to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mlocati committed Oct 31, 2020
1 parent 4f24e62 commit b2ebdc0
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 54 deletions.
22 changes: 3 additions & 19 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ skip_commits:
environment:
PsgKey:
secure: tlhLuUS6x8FcP159+X/EIBDlj9m+u5KCTTuqwzsiNHlPX6K4AolpaZcfAP4ClOdB
matrix:
- DOCKER_IMAGE:
- DOCKER_IMAGE: nanoserver
- DOCKER_IMAGE: windowsservercore

cache:
- test\download-cache -> .appveyor.yml
Expand All @@ -36,23 +32,11 @@ cache:
build: off

install:
- ps: |
if ($null -eq $Env:DOCKER_IMAGE -or $Env:DOCKER_IMAGE -eq '') {
.\test\setup.ps1
} else {
& ".\test\Dockerfile.$Env:DOCKER_IMAGE.ps1"
}
- ps: .\test\setup.ps1
test_script:
- ps: |
if ($null -eq $Env:DOCKER_IMAGE -or $Env:DOCKER_IMAGE -eq '') {
$pesterResult = .\test\pester.ps1
$failCount = $pesterResult.FailedCount
} else {
$volume="$($Env:APPVEYOR_BUILD_FOLDER):C:\App"
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'
$failCount = $LASTEXITCODE
}
$pesterResult = .\test\pester.ps1
$failCount = $pesterResult.FailedCount
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path -LiteralPath .\TestsResults.xml))
if ($failCount -ne 0) {
throw "$failCount tests failed!"
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,29 @@ jobs:
if ($pesterResult.FailedCount -ne 0) {
throw "$($pesterResult.FailedCount) tests failed!"
}
docker:
strategy:
matrix:
docker-image:
- nanoserver
- windowsservercore
name: Docker (${{ matrix.docker-image }})
runs-on: windows-latest
steps:
- name: Enabling Windows containers
run: "& 'C:\\Program Files\\Docker\\DockerCli.exe' -SwitchWindowsEngine"
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Prepare files for Docker image
run: .\test\Prepare-Dockerfile.ps1 "${{ matrix.docker-image }}"
- name: Build Docker image
run: docker build --tag phpmanager/test .\test\docker-build
- name: Test
run: |
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'
$failCount = $LASTEXITCODE
if ($failCount -ne 0) {
throw "$failCount tests failed!"
}
17 changes: 0 additions & 17 deletions test/Dockerfile.nanoserver.ps1

This file was deleted.

18 changes: 0 additions & 18 deletions test/Dockerfile.windowsservercore.ps1

This file was deleted.

11 changes: 11 additions & 0 deletions test/Prepare-Dockerfile.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
param ([string] $DockerImage)

$dockerBuildPath = Join-Path -Path $PSScriptRoot -ChildPath docker-build
if (-Not(Test-Path -LiteralPath $dockerBuildPath)) {
New-Item -ItemType Directory -Path $dockerBuildPath | Out-Null
}
Copy-Item -LiteralPath "$($Env:SystemRoot)\System32\vcruntime140.dll" -Destination $dockerBuildPath
Copy-Item -LiteralPath "$($Env:SystemRoot)\System32\vcomp140.dll" -Destination $dockerBuildPath
Copy-Item -LiteralPath (Join-Path -Path $PSScriptRoot -ChildPath setup-nodejs.ps1) -Destination $dockerBuildPath
Copy-Item -LiteralPath (Join-Path -Path $PSScriptRoot -ChildPath setup.ps1) -Destination $dockerBuildPath
Copy-Item -LiteralPath (Join-Path -Path $PSScriptRoot -ChildPath "Dockerfile.$DockerImage") -Destination (Join-Path -Path $dockerBuildPath -ChildPath Dockerfile)

0 comments on commit b2ebdc0

Please sign in to comment.