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

Move Docker tests to GitHub Actions #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,27 @@ 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: 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)