Automation for PS package validation using Docker containers#5401
Automation for PS package validation using Docker containers#5401TravisEz13 merged 4 commits intoPowerShell:masterfrom
Conversation
| [string] | ||
| $PSVersion = "6.0.0-beta.9", | ||
| [string] | ||
| $TestList = "/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module" |
There was a problem hiding this comment.
Need to review default set of tests to run.
| 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 |
There was a problem hiding this comment.
missing newline at end of file
| $results | ||
|
|
||
| return $returnValue | ||
| } No newline at end of file |
| foreach($file in $tempateFiles) | ||
| { | ||
| (Get-Content $file)` | ||
| -replace $versionRpmStubName,$versionRpmStubValue` |
There was a problem hiding this comment.
Add args to the dockerfile and pass them in when running build instead.
There was a problem hiding this comment.
Good idea; Updated to use --build-arg's
| 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" |
There was a problem hiding this comment.
why not use the release dockefiles the just run this command. This would cause less code duplication
There was a problem hiding this comment.
These tests are to test the generated packages before publishing them to Microsoft Repository, so the release dockerfiles won't help here. We need to download the packages from the Azure blob.
| 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" |
There was a problem hiding this comment.
Please use full cmdlet name Import-Module
| 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 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 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 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 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 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" |
| $packageLocationStubName = '{PACKAGELOCATIONSTUB}' | ||
| $packageLocationStubValue = $PSPackageLocation | ||
|
|
||
| $tempateFiles = (Get-ChildItem -Recurse -Path $RootFolder -Filter Dockerfile).FullName |
There was a problem hiding this comment.
typo in variable name $tempateFiles -> $templateFiles
There was a problem hiding this comment.
This variable got removed in refactoring.
| $results | ||
|
|
||
| return $returnValue | ||
| } |
There was a problem hiding this comment.
Use Export-ModuleMember to specify which functions are public.
There was a problem hiding this comment.
Unless it is required, I'd rather not.
It appears that this module does not do this for other functions.
| # 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 |
There was a problem hiding this comment.
This seems to be a public function, should be named Test-PSPackage
This automation is used for basic validation of PS packages during a release;
Covered configs:
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.