From f4724b7e2d87ba24d70ed78093d1c040f2abd649 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 9 Nov 2017 16:09:52 -0800 Subject: [PATCH 1/4] PackageValidation automation --- docker/tests/Templates/centos7/Dockerfile | 17 +++++ docker/tests/Templates/debian.8/Dockerfile | 22 ++++++ docker/tests/Templates/debian.9/Dockerfile | 22 ++++++ docker/tests/Templates/fedora25/Dockerfile | 17 +++++ docker/tests/Templates/fedora26/Dockerfile | 17 +++++ docker/tests/Templates/kalilinux/Dockerfile | 24 +++++++ .../tests/Templates/opensuse42.2/Dockerfile | 34 +++++++++ docker/tests/Templates/ubuntu14.04/Dockerfile | 22 ++++++ docker/tests/Templates/ubuntu16.04/Dockerfile | 22 ++++++ docker/tests/Templates/ubuntu17.04/Dockerfile | 22 ++++++ docker/tests/containerTestCommon.psm1 | 69 +++++++++++++++++++ 11 files changed, 288 insertions(+) create mode 100644 docker/tests/Templates/centos7/Dockerfile create mode 100644 docker/tests/Templates/debian.8/Dockerfile create mode 100644 docker/tests/Templates/debian.9/Dockerfile create mode 100644 docker/tests/Templates/fedora25/Dockerfile create mode 100644 docker/tests/Templates/fedora26/Dockerfile create mode 100644 docker/tests/Templates/kalilinux/Dockerfile create mode 100644 docker/tests/Templates/opensuse42.2/Dockerfile create mode 100644 docker/tests/Templates/ubuntu14.04/Dockerfile create mode 100644 docker/tests/Templates/ubuntu16.04/Dockerfile create mode 100644 docker/tests/Templates/ubuntu17.04/Dockerfile diff --git a/docker/tests/Templates/centos7/Dockerfile b/docker/tests/Templates/centos7/Dockerfile new file mode 100644 index 00000000000..c2b3c3da19e --- /dev/null +++ b/docker/tests/Templates/centos7/Dockerfile @@ -0,0 +1,17 @@ +FROM centos:7 + +# Install dependencies +RUN yum install -y \ + curl \ + glibc-locale-source \ + git + +# Setup the locale +ENV LANG en_US.UTF-8 +ENV LC_ALL $LANG +RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG + +RUN curl -L -o powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm {PACKAGELOCATIONSTUB}/powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm +RUN yum install -y powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm +RUN git clone --recursive https://github.com/PowerShell/PowerShell.git +RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" \ No newline at end of file diff --git a/docker/tests/Templates/debian.8/Dockerfile b/docker/tests/Templates/debian.8/Dockerfile new file mode 100644 index 00000000000..c9b78bcc995 --- /dev/null +++ b/docker/tests/Templates/debian.8/Dockerfile @@ -0,0 +1,22 @@ +FROM debian:jessie + +# Install dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + apt-utils \ + ca-certificates \ + curl \ + apt-transport-https \ + locales \ + git + +# Setup the locale +ENV LANG en_US.UTF-8 +ENV LC_ALL $LANG +RUN locale-gen $LANG && update-locale + +RUN curl -L -o powershell_{PSVERSIONSTUB}-1.debian.8_amd64.deb {PACKAGELOCATIONSTUB}/powershell_{PSVERSIONSTUB}-1.debian.8_amd64.deb +RUN dpkg -i powershell_{PSVERSIONSTUB}-1.debian.8_amd64.deb || : +RUN apt-get install -y -f +RUN git clone --recursive https://github.com/PowerShell/PowerShell.git +RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" diff --git a/docker/tests/Templates/debian.9/Dockerfile b/docker/tests/Templates/debian.9/Dockerfile new file mode 100644 index 00000000000..7668047ee6c --- /dev/null +++ b/docker/tests/Templates/debian.9/Dockerfile @@ -0,0 +1,22 @@ +FROM debian:stretch + +# Install dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + apt-utils \ + ca-certificates \ + curl \ + apt-transport-https \ + locales \ + git + +# Setup the locale +ENV LANG en_US.UTF-8 +ENV LC_ALL $LANG +RUN locale-gen $LANG && update-locale + +RUN curl -L -o powershell_{PSVERSIONSTUB}-1.debian.9_amd64.deb {PACKAGELOCATIONSTUB}/powershell_{PSVERSIONSTUB}-1.debian.9_amd64.deb +RUN dpkg -i powershell_{PSVERSIONSTUB}-1.debian.9_amd64.deb || : +RUN apt-get install -y -f +RUN git clone --recursive https://github.com/PowerShell/PowerShell.git +RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" diff --git a/docker/tests/Templates/fedora25/Dockerfile b/docker/tests/Templates/fedora25/Dockerfile new file mode 100644 index 00000000000..4910d9133a7 --- /dev/null +++ b/docker/tests/Templates/fedora25/Dockerfile @@ -0,0 +1,17 @@ +FROM fedora:25 + +# Install dependencies +RUN dnf install -y \ + curl \ + glibc-locale-source \ + git + +# Setup the locale +ENV LANG en_US.UTF-8 +ENV LC_ALL $LANG +RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG + +RUN curl -L -o powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm {PACKAGELOCATIONSTUB}/powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm +RUN dnf install -y powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm +RUN git clone --recursive https://github.com/PowerShell/PowerShell.git +RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" \ No newline at end of file diff --git a/docker/tests/Templates/fedora26/Dockerfile b/docker/tests/Templates/fedora26/Dockerfile new file mode 100644 index 00000000000..4f654e363f8 --- /dev/null +++ b/docker/tests/Templates/fedora26/Dockerfile @@ -0,0 +1,17 @@ +FROM fedora:26 + +# Install dependencies +RUN dnf install -y \ + curl \ + glibc-locale-source \ + git + +# Setup the locale +ENV LANG en_US.UTF-8 +ENV LC_ALL $LANG +RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG + +RUN curl -L -o powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm {PACKAGELOCATIONSTUB}/powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm +RUN dnf install -y powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm +RUN git clone --recursive https://github.com/PowerShell/PowerShell.git +RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" \ No newline at end of file diff --git a/docker/tests/Templates/kalilinux/Dockerfile b/docker/tests/Templates/kalilinux/Dockerfile new file mode 100644 index 00000000000..6cc8204985f --- /dev/null +++ b/docker/tests/Templates/kalilinux/Dockerfile @@ -0,0 +1,24 @@ +FROM kalilinux/kali-linux-docker:latest + +# Install dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + apt-utils \ + ca-certificates \ + curl \ + apt-transport-https \ + locales \ + git + +# Setup the locale +ENV LANG en_US.UTF-8 +ENV LC_ALL $LANG +RUN locale-gen $LANG && update-locale + +RUN curl -L -o libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb +RUN curl -L -o powershell_{PSVERSIONSTUB}-1.ubuntu.16.04_amd64.deb {PACKAGELOCATIONSTUB}/powershell_{PSVERSIONSTUB}-1.ubuntu.16.04_amd64.deb +RUN dpkg -i libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb || : +RUN dpkg -i powershell_{PSVERSIONSTUB}-1.ubuntu.16.04_amd64.deb || : +RUN apt-get install -y -f +RUN git clone --recursive https://github.com/PowerShell/PowerShell.git +RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" diff --git a/docker/tests/Templates/opensuse42.2/Dockerfile b/docker/tests/Templates/opensuse42.2/Dockerfile new file mode 100644 index 00000000000..ab6cd0dcecc --- /dev/null +++ b/docker/tests/Templates/opensuse42.2/Dockerfile @@ -0,0 +1,34 @@ +FROM opensuse:42.2 + +ARG POWERSHELL_VERSION={PSVERSIONSTUB} +ARG POWERSHELL_LINKFILE=/usr/bin/pwsh + +# Install dependencies +RUN zypper --non-interactive update --skip-interactive \ + && zypper --non-interactive install \ + glibc-locale \ + glibc-i18ndata \ + tar \ + curl \ + libunwind \ + libicu \ + openssl \ + git + +# Setup the locale +ENV LANG en_US.UTF-8 +ENV LC_ALL $LANG +RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG + +RUN curl -L -o powershell-{PSVERSIONSTUB}-linux-x64.tar.gz {PACKAGELOCATIONSTUB}/powershell-{PSVERSIONSTUB}-linux-x64.tar.gz + +# Create the target folder where powershell will be placed +RUN mkdir -p /opt/microsoft/powershell/$POWERSHELL_VERSION +# Expand powershell to the target folder +RUN tar zxf powershell-{PSVERSIONSTUB}-linux-x64.tar.gz -C /opt/microsoft/powershell/$POWERSHELL_VERSION + +# Create the symbolic link that points to powershell +RUN ln -s /opt/microsoft/powershell/$POWERSHELL_VERSION/pwsh $POWERSHELL_LINKFILE + +RUN git clone --recursive https://github.com/PowerShell/PowerShell.git +RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" \ No newline at end of file diff --git a/docker/tests/Templates/ubuntu14.04/Dockerfile b/docker/tests/Templates/ubuntu14.04/Dockerfile new file mode 100644 index 00000000000..07462603658 --- /dev/null +++ b/docker/tests/Templates/ubuntu14.04/Dockerfile @@ -0,0 +1,22 @@ +FROM ubuntu:trusty + +# Install dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + apt-utils \ + ca-certificates \ + curl \ + apt-transport-https \ + locales \ + git + +# Setup the locale +ENV LANG en_US.UTF-8 +ENV LC_ALL $LANG +RUN locale-gen $LANG && update-locale + +RUN curl -L -o powershell_{PSVERSIONSTUB}-1.ubuntu.14.04_amd64.deb {PACKAGELOCATIONSTUB}/powershell_{PSVERSIONSTUB}-1.ubuntu.14.04_amd64.deb +RUN dpkg -i powershell_{PSVERSIONSTUB}-1.ubuntu.14.04_amd64.deb || : +RUN apt-get install -y -f +RUN git clone --recursive https://github.com/PowerShell/PowerShell.git +RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" diff --git a/docker/tests/Templates/ubuntu16.04/Dockerfile b/docker/tests/Templates/ubuntu16.04/Dockerfile new file mode 100644 index 00000000000..6d5d06f4ad6 --- /dev/null +++ b/docker/tests/Templates/ubuntu16.04/Dockerfile @@ -0,0 +1,22 @@ +FROM ubuntu:xenial + +# Install dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + apt-utils \ + ca-certificates \ + curl \ + apt-transport-https \ + locales \ + git + +# Setup the locale +ENV LANG en_US.UTF-8 +ENV LC_ALL $LANG +RUN locale-gen $LANG && update-locale + +RUN curl -L -o powershell_{PSVERSIONSTUB}-1.ubuntu.16.04_amd64.deb {PACKAGELOCATIONSTUB}/powershell_{PSVERSIONSTUB}-1.ubuntu.16.04_amd64.deb +RUN dpkg -i powershell_{PSVERSIONSTUB}-1.ubuntu.16.04_amd64.deb || : +RUN apt-get install -y -f +RUN git clone --recursive https://github.com/PowerShell/PowerShell.git +RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" diff --git a/docker/tests/Templates/ubuntu17.04/Dockerfile b/docker/tests/Templates/ubuntu17.04/Dockerfile new file mode 100644 index 00000000000..3bd43b3d1bf --- /dev/null +++ b/docker/tests/Templates/ubuntu17.04/Dockerfile @@ -0,0 +1,22 @@ +FROM ubuntu:zesty + +# Install dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + apt-utils \ + ca-certificates \ + curl \ + apt-transport-https \ + locales \ + git + +# Setup the locale +ENV LANG en_US.UTF-8 +ENV LC_ALL $LANG +RUN locale-gen $LANG && update-locale + +RUN curl -L -o powershell_{PSVERSIONSTUB}-1.ubuntu.17.04_amd64.deb {PACKAGELOCATIONSTUB}/powershell_{PSVERSIONSTUB}-1.ubuntu.17.04_amd64.deb +RUN dpkg -i powershell_{PSVERSIONSTUB}-1.ubuntu.17.04_amd64.deb || : +RUN apt-get install -y -f +RUN git clone --recursive https://github.com/PowerShell/PowerShell.git +RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" diff --git a/docker/tests/containerTestCommon.psm1 b/docker/tests/containerTestCommon.psm1 index 5b3971e5cb2..4f6a7e51655 100644 --- a/docker/tests/containerTestCommon.psm1 +++ b/docker/tests/containerTestCommon.psm1 @@ -190,3 +190,72 @@ function Get-ContainerPowerShellVersion } return (Get-Content -Encoding Ascii $testContext.resolvedLogPath)[0] } + +# This function is used for basic validation of PS packages during a release; +# During the process Docker files are filled out and executed with Docker build; +# During the build PS packages are downloaded onto Docker containers, installed and selected Pester tests from PowerShell Github repo are executed. +# This function must be run on a Docker host machine in 'Linux containers' mode, such as Windows 10 server with Hyper-V role installed. +function ValidatePSPackage +{ + param( + [string] + [Parameter(Mandatory=$true)] + $PSPackageLocation, # e.g. Azure storage + [string] + $PSVersion = "6.0.0-beta.9", + [string] + $TestList = "/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module" + ) + + $PSPackageLocation = $PSPackageLocation.TrimEnd('/','\') + Write-Verbose "Ensure that PowerShell packages of version $PSVersion exist at $PSPackageLocation" -Verbose + + $tempFolder = $env:Temp + if (-not $tempFolder) {$tempFolder = "~"} + $RootFolder = Join-Path $tempFolder 'PSPackageDockerValidation' + $SourceFolder = Join-Path $PSScriptRoot 'Templates' + + if (Test-Path $RootFolder) + { + Remove-Item $RootFolder -Recurse -Force + } + + Copy-Item -Recurse $SourceFolder $RootFolder + + $versionRpmStubName = '{PSVERSIONSTUBRPM}' + $versionRpmStubValue = $PSVersion -replace '-','_' + $versionStubName = '{PSVERSIONSTUB}' + $versionStubValue = $PSVersion + $testlistStubName = '{TESTLISTSTUB}' + $testlistStubValue = $TestList + $packageLocationStubName = '{PACKAGELOCATIONSTUB}' + $packageLocationStubValue = $PSPackageLocation + + $tempateFiles = (Get-ChildItem -Recurse -Path $RootFolder -Filter Dockerfile).FullName + + foreach($file in $tempateFiles) + { + (Get-Content $file)` + -replace $versionRpmStubName,$versionRpmStubValue` + -replace $versionStubName,$versionStubValue` + -replace $testlistStubName,$testlistStubValue` + -replace $packageLocationStubName,$packageLocationStubValue | Set-Content $file + } + + $results = @{} + $returnValue = $true + + # run builds sequentially, but don't block for errors so that configs after failed one can run + foreach($dir in Get-ChildItem -Path $RootFolder) + { + $dockerResult = Invoke-Docker -Command 'build' -Params $dir.FullName -FailureAction warning + $results.Add($dir.Name, $dockerResult) + if (-not $dockerResult) {$returnValue = $false} + } + + # in the end print results for all configurations + Write-Verbose "Package validation results:" -Verbose + $results + + return $returnValue +} \ No newline at end of file From 2988c167462ae98f0ccbed9b20fa29c9a7ef62be Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 10 Nov 2017 13:51:30 -0800 Subject: [PATCH 2/4] Fixed file-ending newlines and fedora26 config --- docker/tests/Templates/centos7/Dockerfile | 2 +- docker/tests/Templates/fedora25/Dockerfile | 2 +- docker/tests/Templates/fedora26/Dockerfile | 3 ++- docker/tests/Templates/opensuse42.2/Dockerfile | 2 +- docker/tests/containerTestCommon.psm1 | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docker/tests/Templates/centos7/Dockerfile b/docker/tests/Templates/centos7/Dockerfile index c2b3c3da19e..53757871795 100644 --- a/docker/tests/Templates/centos7/Dockerfile +++ b/docker/tests/Templates/centos7/Dockerfile @@ -14,4 +14,4 @@ RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG RUN curl -L -o powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm {PACKAGELOCATIONSTUB}/powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm RUN yum install -y powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm RUN git clone --recursive https://github.com/PowerShell/PowerShell.git -RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" \ No newline at end of file +RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" diff --git a/docker/tests/Templates/fedora25/Dockerfile b/docker/tests/Templates/fedora25/Dockerfile index 4910d9133a7..7b4ecb8492f 100644 --- a/docker/tests/Templates/fedora25/Dockerfile +++ b/docker/tests/Templates/fedora25/Dockerfile @@ -14,4 +14,4 @@ RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG RUN curl -L -o powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm {PACKAGELOCATIONSTUB}/powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm RUN dnf install -y powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm RUN git clone --recursive https://github.com/PowerShell/PowerShell.git -RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" \ No newline at end of file +RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" diff --git a/docker/tests/Templates/fedora26/Dockerfile b/docker/tests/Templates/fedora26/Dockerfile index 4f654e363f8..032a3312761 100644 --- a/docker/tests/Templates/fedora26/Dockerfile +++ b/docker/tests/Templates/fedora26/Dockerfile @@ -4,6 +4,7 @@ FROM fedora:26 RUN dnf install -y \ curl \ glibc-locale-source \ + compat-openssl10 \ git # Setup the locale @@ -14,4 +15,4 @@ RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG RUN curl -L -o powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm {PACKAGELOCATIONSTUB}/powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm RUN dnf install -y powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm RUN git clone --recursive https://github.com/PowerShell/PowerShell.git -RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" \ No newline at end of file +RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" diff --git a/docker/tests/Templates/opensuse42.2/Dockerfile b/docker/tests/Templates/opensuse42.2/Dockerfile index ab6cd0dcecc..5f09f9d8779 100644 --- a/docker/tests/Templates/opensuse42.2/Dockerfile +++ b/docker/tests/Templates/opensuse42.2/Dockerfile @@ -31,4 +31,4 @@ RUN tar zxf powershell-{PSVERSIONSTUB}-linux-x64.tar.gz -C /opt/microsoft/powers RUN ln -s /opt/microsoft/powershell/$POWERSHELL_VERSION/pwsh $POWERSHELL_LINKFILE RUN git clone --recursive https://github.com/PowerShell/PowerShell.git -RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" \ No newline at end of file +RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" diff --git a/docker/tests/containerTestCommon.psm1 b/docker/tests/containerTestCommon.psm1 index 4f6a7e51655..47a3a9330ba 100644 --- a/docker/tests/containerTestCommon.psm1 +++ b/docker/tests/containerTestCommon.psm1 @@ -258,4 +258,4 @@ function ValidatePSPackage $results return $returnValue -} \ No newline at end of file +} From 58ba3e26875c83aca4c56f199d62f24b1719dfd9 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 10 Nov 2017 16:14:39 -0800 Subject: [PATCH 3/4] Changed to using build-args and other misc updates --- docker/tests/Templates/centos7/Dockerfile | 11 +++++-- docker/tests/Templates/debian.8/Dockerfile | 11 +++++-- docker/tests/Templates/debian.9/Dockerfile | 11 +++++-- docker/tests/Templates/fedora25/Dockerfile | 11 +++++-- docker/tests/Templates/fedora26/Dockerfile | 11 +++++-- docker/tests/Templates/kalilinux/Dockerfile | 11 +++++-- .../tests/Templates/opensuse42.2/Dockerfile | 16 ++++++---- docker/tests/Templates/ubuntu14.04/Dockerfile | 11 +++++-- docker/tests/Templates/ubuntu16.04/Dockerfile | 11 +++++-- docker/tests/Templates/ubuntu17.04/Dockerfile | 11 +++++-- docker/tests/containerTestCommon.psm1 | 31 +++++++++---------- 11 files changed, 96 insertions(+), 50 deletions(-) diff --git a/docker/tests/Templates/centos7/Dockerfile b/docker/tests/Templates/centos7/Dockerfile index 53757871795..89816a47828 100644 --- a/docker/tests/Templates/centos7/Dockerfile +++ b/docker/tests/Templates/centos7/Dockerfile @@ -1,5 +1,10 @@ FROM centos:7 +ARG PSVERSIONSTUB +ARG PSVERSIONSTUBRPM +ARG PACKAGELOCATIONSTUB +ARG TESTLISTSTUB + # Install dependencies RUN yum install -y \ curl \ @@ -11,7 +16,7 @@ ENV LANG en_US.UTF-8 ENV LC_ALL $LANG RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG -RUN curl -L -o powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm {PACKAGELOCATIONSTUB}/powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm -RUN yum install -y powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm +RUN curl -L -o powershell-$PSVERSIONSTUBRPM-1.rhel.7.x86_64.rpm $PACKAGELOCATIONSTUB/powershell-$PSVERSIONSTUBRPM-1.rhel.7.x86_64.rpm +RUN yum install -y powershell-$PSVERSIONSTUBRPM-1.rhel.7.x86_64.rpm RUN git clone --recursive https://github.com/PowerShell/PowerShell.git -RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" +RUN pwsh -c "Import-Module /PowerShell/build.psm1;exit (Invoke-Pester $TESTLISTSTUB -PassThru).FailedCount" diff --git a/docker/tests/Templates/debian.8/Dockerfile b/docker/tests/Templates/debian.8/Dockerfile index c9b78bcc995..f6224837884 100644 --- a/docker/tests/Templates/debian.8/Dockerfile +++ b/docker/tests/Templates/debian.8/Dockerfile @@ -1,5 +1,10 @@ FROM debian:jessie +ARG PSVERSIONSTUB +ARG PSVERSIONSTUBRPM +ARG PACKAGELOCATIONSTUB +ARG TESTLISTSTUB + # Install dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends \ @@ -15,8 +20,8 @@ ENV LANG en_US.UTF-8 ENV LC_ALL $LANG RUN locale-gen $LANG && update-locale -RUN curl -L -o powershell_{PSVERSIONSTUB}-1.debian.8_amd64.deb {PACKAGELOCATIONSTUB}/powershell_{PSVERSIONSTUB}-1.debian.8_amd64.deb -RUN dpkg -i powershell_{PSVERSIONSTUB}-1.debian.8_amd64.deb || : +RUN curl -L -o powershell_$PSVERSIONSTUB-1.debian.8_amd64.deb $PACKAGELOCATIONSTUB/powershell_$PSVERSIONSTUB-1.debian.8_amd64.deb +RUN dpkg -i powershell_$PSVERSIONSTUB-1.debian.8_amd64.deb || : RUN apt-get install -y -f RUN git clone --recursive https://github.com/PowerShell/PowerShell.git -RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" +RUN pwsh -c "Import-Module /PowerShell/build.psm1;exit (Invoke-Pester $TESTLISTSTUB -PassThru).FailedCount" diff --git a/docker/tests/Templates/debian.9/Dockerfile b/docker/tests/Templates/debian.9/Dockerfile index 7668047ee6c..80e21cd407b 100644 --- a/docker/tests/Templates/debian.9/Dockerfile +++ b/docker/tests/Templates/debian.9/Dockerfile @@ -1,5 +1,10 @@ FROM debian:stretch +ARG PSVERSIONSTUB +ARG PSVERSIONSTUBRPM +ARG PACKAGELOCATIONSTUB +ARG TESTLISTSTUB + # Install dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends \ @@ -15,8 +20,8 @@ ENV LANG en_US.UTF-8 ENV LC_ALL $LANG RUN locale-gen $LANG && update-locale -RUN curl -L -o powershell_{PSVERSIONSTUB}-1.debian.9_amd64.deb {PACKAGELOCATIONSTUB}/powershell_{PSVERSIONSTUB}-1.debian.9_amd64.deb -RUN dpkg -i powershell_{PSVERSIONSTUB}-1.debian.9_amd64.deb || : +RUN curl -L -o powershell_$PSVERSIONSTUB-1.debian.9_amd64.deb $PACKAGELOCATIONSTUB/powershell_$PSVERSIONSTUB-1.debian.9_amd64.deb +RUN dpkg -i powershell_$PSVERSIONSTUB-1.debian.9_amd64.deb || : RUN apt-get install -y -f RUN git clone --recursive https://github.com/PowerShell/PowerShell.git -RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" +RUN pwsh -c "Import-Module /PowerShell/build.psm1;exit (Invoke-Pester $TESTLISTSTUB -PassThru).FailedCount" diff --git a/docker/tests/Templates/fedora25/Dockerfile b/docker/tests/Templates/fedora25/Dockerfile index 7b4ecb8492f..828c3660078 100644 --- a/docker/tests/Templates/fedora25/Dockerfile +++ b/docker/tests/Templates/fedora25/Dockerfile @@ -1,5 +1,10 @@ FROM fedora:25 +ARG PSVERSIONSTUB +ARG PSVERSIONSTUBRPM +ARG PACKAGELOCATIONSTUB +ARG TESTLISTSTUB + # Install dependencies RUN dnf install -y \ curl \ @@ -11,7 +16,7 @@ ENV LANG en_US.UTF-8 ENV LC_ALL $LANG RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG -RUN curl -L -o powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm {PACKAGELOCATIONSTUB}/powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm -RUN dnf install -y powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm +RUN curl -L -o powershell-$PSVERSIONSTUBRPM-1.rhel.7.x86_64.rpm $PACKAGELOCATIONSTUB/powershell-$PSVERSIONSTUBRPM-1.rhel.7.x86_64.rpm +RUN dnf install -y powershell-$PSVERSIONSTUBRPM-1.rhel.7.x86_64.rpm RUN git clone --recursive https://github.com/PowerShell/PowerShell.git -RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" +RUN pwsh -c "Import-Module /PowerShell/build.psm1;exit (Invoke-Pester $TESTLISTSTUB -PassThru).FailedCount" diff --git a/docker/tests/Templates/fedora26/Dockerfile b/docker/tests/Templates/fedora26/Dockerfile index 032a3312761..b4207d7c22a 100644 --- a/docker/tests/Templates/fedora26/Dockerfile +++ b/docker/tests/Templates/fedora26/Dockerfile @@ -1,5 +1,10 @@ FROM fedora:26 +ARG PSVERSIONSTUB +ARG PSVERSIONSTUBRPM +ARG PACKAGELOCATIONSTUB +ARG TESTLISTSTUB + # Install dependencies RUN dnf install -y \ curl \ @@ -12,7 +17,7 @@ ENV LANG en_US.UTF-8 ENV LC_ALL $LANG RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG -RUN curl -L -o powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm {PACKAGELOCATIONSTUB}/powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm -RUN dnf install -y powershell-{PSVERSIONSTUBRPM}-1.rhel.7.x86_64.rpm +RUN curl -L -o powershell-$PSVERSIONSTUBRPM-1.rhel.7.x86_64.rpm $PACKAGELOCATIONSTUB/powershell-$PSVERSIONSTUBRPM-1.rhel.7.x86_64.rpm +RUN dnf install -y powershell-$PSVERSIONSTUBRPM-1.rhel.7.x86_64.rpm RUN git clone --recursive https://github.com/PowerShell/PowerShell.git -RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" +RUN pwsh -c "Import-Module /PowerShell/build.psm1;exit (Invoke-Pester $TESTLISTSTUB -PassThru).FailedCount" diff --git a/docker/tests/Templates/kalilinux/Dockerfile b/docker/tests/Templates/kalilinux/Dockerfile index 6cc8204985f..6d02c38a465 100644 --- a/docker/tests/Templates/kalilinux/Dockerfile +++ b/docker/tests/Templates/kalilinux/Dockerfile @@ -1,5 +1,10 @@ FROM kalilinux/kali-linux-docker:latest +ARG PSVERSIONSTUB +ARG PSVERSIONSTUBRPM +ARG PACKAGELOCATIONSTUB +ARG TESTLISTSTUB + # Install dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends \ @@ -16,9 +21,9 @@ ENV LC_ALL $LANG RUN locale-gen $LANG && update-locale RUN curl -L -o libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb -RUN curl -L -o powershell_{PSVERSIONSTUB}-1.ubuntu.16.04_amd64.deb {PACKAGELOCATIONSTUB}/powershell_{PSVERSIONSTUB}-1.ubuntu.16.04_amd64.deb +RUN curl -L -o powershell_$PSVERSIONSTUB-1.ubuntu.16.04_amd64.deb $PACKAGELOCATIONSTUB/powershell_$PSVERSIONSTUB-1.ubuntu.16.04_amd64.deb RUN dpkg -i libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb || : -RUN dpkg -i powershell_{PSVERSIONSTUB}-1.ubuntu.16.04_amd64.deb || : +RUN dpkg -i powershell_$PSVERSIONSTUB-1.ubuntu.16.04_amd64.deb || : RUN apt-get install -y -f RUN git clone --recursive https://github.com/PowerShell/PowerShell.git -RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" +RUN pwsh -c "Import-Module /PowerShell/build.psm1;exit (Invoke-Pester $TESTLISTSTUB -PassThru).FailedCount" diff --git a/docker/tests/Templates/opensuse42.2/Dockerfile b/docker/tests/Templates/opensuse42.2/Dockerfile index 5f09f9d8779..5ac50b1a01d 100644 --- a/docker/tests/Templates/opensuse42.2/Dockerfile +++ b/docker/tests/Templates/opensuse42.2/Dockerfile @@ -1,6 +1,10 @@ FROM opensuse:42.2 -ARG POWERSHELL_VERSION={PSVERSIONSTUB} +ARG PSVERSIONSTUB +ARG PSVERSIONSTUBRPM +ARG PACKAGELOCATIONSTUB +ARG TESTLISTSTUB + ARG POWERSHELL_LINKFILE=/usr/bin/pwsh # Install dependencies @@ -20,15 +24,15 @@ ENV LANG en_US.UTF-8 ENV LC_ALL $LANG RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG -RUN curl -L -o powershell-{PSVERSIONSTUB}-linux-x64.tar.gz {PACKAGELOCATIONSTUB}/powershell-{PSVERSIONSTUB}-linux-x64.tar.gz +RUN curl -L -o powershell-$PSVERSIONSTUB-linux-x64.tar.gz $PACKAGELOCATIONSTUB/powershell-$PSVERSIONSTUB-linux-x64.tar.gz # Create the target folder where powershell will be placed -RUN mkdir -p /opt/microsoft/powershell/$POWERSHELL_VERSION +RUN mkdir -p /opt/microsoft/powershell/$PSVERSIONSTUB # Expand powershell to the target folder -RUN tar zxf powershell-{PSVERSIONSTUB}-linux-x64.tar.gz -C /opt/microsoft/powershell/$POWERSHELL_VERSION +RUN tar zxf powershell-$PSVERSIONSTUB-linux-x64.tar.gz -C /opt/microsoft/powershell/$PSVERSIONSTUB # Create the symbolic link that points to powershell -RUN ln -s /opt/microsoft/powershell/$POWERSHELL_VERSION/pwsh $POWERSHELL_LINKFILE +RUN ln -s /opt/microsoft/powershell/$PSVERSIONSTUB/pwsh $POWERSHELL_LINKFILE RUN git clone --recursive https://github.com/PowerShell/PowerShell.git -RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" +RUN pwsh -c "Import-Module /PowerShell/build.psm1;exit (Invoke-Pester $TESTLISTSTUB -PassThru).FailedCount" diff --git a/docker/tests/Templates/ubuntu14.04/Dockerfile b/docker/tests/Templates/ubuntu14.04/Dockerfile index 07462603658..1533bc2395d 100644 --- a/docker/tests/Templates/ubuntu14.04/Dockerfile +++ b/docker/tests/Templates/ubuntu14.04/Dockerfile @@ -1,5 +1,10 @@ FROM ubuntu:trusty +ARG PSVERSIONSTUB +ARG PSVERSIONSTUBRPM +ARG PACKAGELOCATIONSTUB +ARG TESTLISTSTUB + # Install dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends \ @@ -15,8 +20,8 @@ ENV LANG en_US.UTF-8 ENV LC_ALL $LANG RUN locale-gen $LANG && update-locale -RUN curl -L -o powershell_{PSVERSIONSTUB}-1.ubuntu.14.04_amd64.deb {PACKAGELOCATIONSTUB}/powershell_{PSVERSIONSTUB}-1.ubuntu.14.04_amd64.deb -RUN dpkg -i powershell_{PSVERSIONSTUB}-1.ubuntu.14.04_amd64.deb || : +RUN curl -L -o powershell_$PSVERSIONSTUB-1.ubuntu.14.04_amd64.deb $PACKAGELOCATIONSTUB/powershell_$PSVERSIONSTUB-1.ubuntu.14.04_amd64.deb +RUN dpkg -i powershell_$PSVERSIONSTUB-1.ubuntu.14.04_amd64.deb || : RUN apt-get install -y -f RUN git clone --recursive https://github.com/PowerShell/PowerShell.git -RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" +RUN pwsh -c "Import-Module /PowerShell/build.psm1;exit (Invoke-Pester $TESTLISTSTUB -PassThru).FailedCount" diff --git a/docker/tests/Templates/ubuntu16.04/Dockerfile b/docker/tests/Templates/ubuntu16.04/Dockerfile index 6d5d06f4ad6..db84a97f535 100644 --- a/docker/tests/Templates/ubuntu16.04/Dockerfile +++ b/docker/tests/Templates/ubuntu16.04/Dockerfile @@ -1,5 +1,10 @@ FROM ubuntu:xenial +ARG PSVERSIONSTUB +ARG PSVERSIONSTUBRPM +ARG PACKAGELOCATIONSTUB +ARG TESTLISTSTUB + # Install dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends \ @@ -15,8 +20,8 @@ ENV LANG en_US.UTF-8 ENV LC_ALL $LANG RUN locale-gen $LANG && update-locale -RUN curl -L -o powershell_{PSVERSIONSTUB}-1.ubuntu.16.04_amd64.deb {PACKAGELOCATIONSTUB}/powershell_{PSVERSIONSTUB}-1.ubuntu.16.04_amd64.deb -RUN dpkg -i powershell_{PSVERSIONSTUB}-1.ubuntu.16.04_amd64.deb || : +RUN curl -L -o powershell_$PSVERSIONSTUB-1.ubuntu.16.04_amd64.deb $PACKAGELOCATIONSTUB/powershell_$PSVERSIONSTUB-1.ubuntu.16.04_amd64.deb +RUN dpkg -i powershell_$PSVERSIONSTUB-1.ubuntu.16.04_amd64.deb || : RUN apt-get install -y -f RUN git clone --recursive https://github.com/PowerShell/PowerShell.git -RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" +RUN pwsh -c "Import-Module /PowerShell/build.psm1;exit (Invoke-Pester $TESTLISTSTUB -PassThru).FailedCount" diff --git a/docker/tests/Templates/ubuntu17.04/Dockerfile b/docker/tests/Templates/ubuntu17.04/Dockerfile index 3bd43b3d1bf..506cb8b5112 100644 --- a/docker/tests/Templates/ubuntu17.04/Dockerfile +++ b/docker/tests/Templates/ubuntu17.04/Dockerfile @@ -1,5 +1,10 @@ FROM ubuntu:zesty +ARG PSVERSIONSTUB +ARG PSVERSIONSTUBRPM +ARG PACKAGELOCATIONSTUB +ARG TESTLISTSTUB + # Install dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends \ @@ -15,8 +20,8 @@ ENV LANG en_US.UTF-8 ENV LC_ALL $LANG RUN locale-gen $LANG && update-locale -RUN curl -L -o powershell_{PSVERSIONSTUB}-1.ubuntu.17.04_amd64.deb {PACKAGELOCATIONSTUB}/powershell_{PSVERSIONSTUB}-1.ubuntu.17.04_amd64.deb -RUN dpkg -i powershell_{PSVERSIONSTUB}-1.ubuntu.17.04_amd64.deb || : +RUN curl -L -o powershell_$PSVERSIONSTUB-1.ubuntu.17.04_amd64.deb $PACKAGELOCATIONSTUB/powershell_$PSVERSIONSTUB-1.ubuntu.17.04_amd64.deb +RUN dpkg -i powershell_$PSVERSIONSTUB-1.ubuntu.17.04_amd64.deb || : RUN apt-get install -y -f RUN git clone --recursive https://github.com/PowerShell/PowerShell.git -RUN pwsh -c "ipmo /PowerShell/build.psm1;exit (Invoke-Pester {TESTLISTSTUB} -PassThru).FailedCount" +RUN pwsh -c "Import-Module /PowerShell/build.psm1;exit (Invoke-Pester $TESTLISTSTUB -PassThru).FailedCount" diff --git a/docker/tests/containerTestCommon.psm1 b/docker/tests/containerTestCommon.psm1 index 47a3a9330ba..a851a1d3c47 100644 --- a/docker/tests/containerTestCommon.psm1 +++ b/docker/tests/containerTestCommon.psm1 @@ -195,7 +195,7 @@ function Get-ContainerPowerShellVersion # During the process Docker files are filled out and executed with Docker build; # During the build PS packages are downloaded onto Docker containers, installed and selected Pester tests from PowerShell Github repo are executed. # This function must be run on a Docker host machine in 'Linux containers' mode, such as Windows 10 server with Hyper-V role installed. -function ValidatePSPackage +function Test-PSPackage { param( [string] @@ -222,25 +222,15 @@ function ValidatePSPackage Copy-Item -Recurse $SourceFolder $RootFolder - $versionRpmStubName = '{PSVERSIONSTUBRPM}' + $versionRpmStubName = 'PSVERSIONSTUBRPM' $versionRpmStubValue = $PSVersion -replace '-','_' - $versionStubName = '{PSVERSIONSTUB}' + $versionStubName = 'PSVERSIONSTUB' $versionStubValue = $PSVersion - $testlistStubName = '{TESTLISTSTUB}' + $testlistStubName = 'TESTLISTSTUB' $testlistStubValue = $TestList - $packageLocationStubName = '{PACKAGELOCATIONSTUB}' + $packageLocationStubName = 'PACKAGELOCATIONSTUB' $packageLocationStubValue = $PSPackageLocation - $tempateFiles = (Get-ChildItem -Recurse -Path $RootFolder -Filter Dockerfile).FullName - - foreach($file in $tempateFiles) - { - (Get-Content $file)` - -replace $versionRpmStubName,$versionRpmStubValue` - -replace $versionStubName,$versionStubValue` - -replace $testlistStubName,$testlistStubValue` - -replace $packageLocationStubName,$packageLocationStubValue | Set-Content $file - } $results = @{} $returnValue = $true @@ -248,7 +238,14 @@ function ValidatePSPackage # run builds sequentially, but don't block for errors so that configs after failed one can run foreach($dir in Get-ChildItem -Path $RootFolder) { - $dockerResult = Invoke-Docker -Command 'build' -Params $dir.FullName -FailureAction warning + $buildArgs = @() + $buildArgs += "--build-arg","$versionRpmStubName=$versionRpmStubValue" + $buildArgs += "--build-arg","$versionStubName=$versionStubValue" + $buildArgs += "--build-arg","$testlistStubName=$testlistStubValue" + $buildArgs += "--build-arg","$packageLocationStubName=$packageLocationStubValue" + $buildArgs += $dir.FullName + + $dockerResult = Invoke-Docker -Command 'build' -Params $buildArgs -FailureAction warning $results.Add($dir.Name, $dockerResult) if (-not $dockerResult) {$returnValue = $false} } @@ -258,4 +255,4 @@ function ValidatePSPackage $results return $returnValue -} +} \ No newline at end of file From 10e54da9af8bbde109e0ca0538d1291e827f28e0 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 10 Nov 2017 16:22:35 -0800 Subject: [PATCH 4/4] Ending newline in psm1 --- docker/tests/containerTestCommon.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/tests/containerTestCommon.psm1 b/docker/tests/containerTestCommon.psm1 index a851a1d3c47..a89e30bd21e 100644 --- a/docker/tests/containerTestCommon.psm1 +++ b/docker/tests/containerTestCommon.psm1 @@ -255,4 +255,4 @@ function Test-PSPackage $results return $returnValue -} \ No newline at end of file +}