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

Automation for PS package validation using Docker containers #5401

Merged
merged 4 commits into from
Nov 13, 2017

Conversation

anmenaga
Copy link
Contributor

This automation is used for basic validation of PS packages during a release;
Covered configs:

  1. ubuntu14.04
  2. ubuntu16.04
  3. ubuntu17.04
  4. debian.8
  5. debian.9
  6. centos7
  7. fedora25
  8. fedora26
  9. kalilinux
  10. opensuse42.2

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.

@anmenaga anmenaga added the Area-Maintainers-Build specific to affecting the build label Nov 10, 2017
[string]
$PSVersion = "6.0.0-beta.9",
[string]
$TestList = "/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing newline at end of file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated for all files

$results

return $returnValue
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing newline

foreach($file in $tempateFiles)
{
(Get-Content $file)`
-replace $versionRpmStubName,$versionRpmStubValue`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add args to the dockerfile and pass them in when running build instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea; Updated to use --build-arg's

Copy link
Member

@TravisEz13 TravisEz13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

@TravisEz13 TravisEz13 self-assigned this Nov 10, 2017
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use the release dockefiles the just run this command. This would cause less code duplication

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use full cmdlet name Import-Module

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated for all files.

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

$packageLocationStubName = '{PACKAGELOCATIONSTUB}'
$packageLocationStubValue = $PSPackageLocation

$tempateFiles = (Get-ChildItem -Recurse -Path $RootFolder -Filter Dockerfile).FullName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in variable name $tempateFiles -> $templateFiles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable got removed in refactoring.

$results

return $returnValue
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Export-ModuleMember to specify which functions are public.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a public function, should be named Test-PSPackage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to Test-PSPackage

@TravisEz13 TravisEz13 merged commit 06d3114 into PowerShell:master Nov 13, 2017
@anmenaga anmenaga deleted the DockerPackageValidation branch October 31, 2018 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Maintainers-Build specific to affecting the build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants