-
Notifications
You must be signed in to change notification settings - Fork 39
Archive module preview 1 PR #131
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
Merged
SeeminglyScience
merged 43 commits into
PowerShell:master
from
ayousuf23:merge-with-master
Aug 11, 2022
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
7711837
Add .gitattributes, .gitignore, and README.md.
7512b08
Add project files.
aff9728
added path helper, archive entry
e535995
updated path helper
04adc0b
resolved bug where GetEntryName was throwing an ArgumentException
915f344
fixed a bug, started work on zip support
c05e063
worked on zip archive support
ef66ef9
added ArchiveFactory class
dde4deb
imporved zip support
fcde5dd
fixed a bug in tests, added error handling for DestinationPath
636444d
fixed bug in tests where Test-ZipArchive was not working correctly
50e0da3
added tests for DestinationPath
5cede7e
added additional tests, added TODOs
88ea929
updated tests
3dffd1d
added resx files for messages, refactored code, updated structure, etc.
63490c6
refactored PathHelper class
7986a1e
worked on automatically determining archive format based on Destinati…
e062f64
added support for determining archive format automatically based on D…
8fd551e
fixed a bug with archive format warning, added TarArchive file
d872cf8
renamed Action to WriteMode, fixed bug with compressing directories, …
bc49871
fixed bug where the directory structure of directories was not being …
6ee7ccb
addded exception handling to PathHelper class
3fc29de
removed files from git, removed tar support for preview release, adde…
bf53c33
updated build script, updated exception handling in PathHelper
5b355a6
used FileSystemInfo instead of String to store full path information
615994b
updated checking for the same source path and destination path
33d863d
updated build configuration
29be220
merged tests branch with CI branch
fd9b327
updated project version with prelease info, removed tar support after…
ayousuf23 cb98554
updated CI config, fixed bug with missing error message, fixed tests
ayousuf23 7780be0
updated CI to build module and run tests across all platforms
ayousuf23 68ffa8f
updated CI to run tests, added and reorganized tests, solved a bug wh…
ayousuf23 03ce64a
used pascal case for ArchiveFormat enum members, refactored some code…
ayousuf23 d9c0e8e
fixed formatting for multiple files, updated csproj to generate Messa…
ayousuf23 d384f50
fixed missing quotation mark in CI config, updated switch code in Arc…
ayousuf23 3ae0355
added assertions to prevent possible null error, added RequiredVersio…
ayousuf23 abeb7a2
added localized messages for Add, Create, and progress bar text, mino…
ayousuf23 8373aca
added copyright header, removed usage of DS in tests, minor formattin…
ayousuf23 f7c2af4
updated .gitignore, added explanation for why ArchiveAddition.EntryNa…
ayousuf23 f7cdfd2
updated Compress-Archive cmdlet to resolve a path one at a time rathe…
ayousuf23 b5e23c2
fixed a bug where PathNotFound error was not thrown, fixed a bug when…
ayousuf23 fcaaa8e
added custom assertions for testing zip archives
ayousuf23 dc557a5
updated CI to run tests using new assertion, updated README with Azur…
ayousuf23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
name: Microsoft.PowerShell.Archive-$(Build.BuildId) | ||
trigger: none | ||
|
||
pr: none | ||
|
||
variables: | ||
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | ||
POWERSHELL_TELEMETRY_OPTOUT: 1 | ||
|
||
resources: | ||
repositories: | ||
- repository: ComplianceRepo | ||
type: github | ||
endpoint: ComplianceGHRepo | ||
name: PowerShell/compliance | ||
ref: master | ||
|
||
stages: | ||
- stage: Build | ||
displayName: Build | ||
pool: | ||
name: 1ES | ||
demands: | ||
- ImageOverride -equals PSMMS2019-Secure | ||
jobs: | ||
- job: Build_Job | ||
displayName: Build Microsoft.PowerShell.Archive | ||
variables: | ||
- group: ESRP | ||
steps: | ||
- checkout: self | ||
|
||
- task: UseDotNet@2 | ||
displayName: 'Get .NET 7.0 SDK' | ||
inputs: | ||
packageType: sdk | ||
version: 7.x | ||
includePreviewVersions: true | ||
|
||
- pwsh: | | ||
& $(Build.SourcesDirectory)/Microsoft.PowerShell.Archive/SimpleBuild.ps1 | ||
displayName: Build Microsoft.PowerShell.Archive module | ||
|
||
- pwsh: | | ||
Get-ChildItem "$(BuildOutDir)\*" -Recurse | Write-Verbose -Verbose | ||
displayName: Show BuildOutDirectory | ||
|
||
- pwsh: | | ||
$signSrcPath = "$(BuildOutDir)" | ||
# Set signing src path variable | ||
$vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}" | ||
Write-Host "sending " + $vstsCommandString | ||
Write-Host "##$vstsCommandString" | ||
# Get the module version | ||
$ManifestPath = Join-Path $(BuildOutDir) "Microsoft.PowerShell.Archive.psd1" | ||
$ManifestData = Import-PowerShellDataFile -Path $ManifestPath | ||
$Version = $ManifestData.ModuleVersion | ||
$signOutPath = "$(Build.SourcesDirectory)\signed\Microsoft.PowerShell.Archive\${Version}" | ||
$null = New-Item -ItemType Directory -Path $signOutPath | ||
# Set signing out path variable | ||
$vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}" | ||
Write-Host "sending " + $vstsCommandString | ||
Write-Host "##$vstsCommandString" | ||
# Set path variable for guardian codesign validation | ||
$vstsCommandString = "vso[task.setvariable variable=GDN_CODESIGN_TARGETDIRECTORY]${signOutPath}" | ||
Write-Host "sending " + $vstsCommandString | ||
Write-Host "##$vstsCommandString" | ||
displayName: Setup variables for signing | ||
|
||
- checkout: ComplianceRepo | ||
|
||
- task: UseDotNet@2 | ||
displayName: 'Get .NET 2.1 SDK' | ||
inputs: | ||
packageType: sdk | ||
version: 2.x | ||
includePreviewVersions: true | ||
|
||
- template: EsrpSign.yml@ComplianceRepo | ||
parameters: | ||
# the folder which contains the binaries to sign | ||
buildOutputPath: $(signSrcPath) | ||
# the location to put the signed output | ||
signOutputPath: $(signOutPath) | ||
# the certificate ID to use | ||
certificateId: "CP-230012" | ||
# the file pattern to use, comma separated | ||
pattern: '*.psd1,*.dll' | ||
|
||
- template: Sbom.yml@ComplianceRepo | ||
parameters: | ||
BuildDropPath: $(signOutPath) | ||
Build_Repository_Uri: 'https://github.com/PowerShell/Microsoft.PowerShell.Archive' | ||
|
||
- pwsh: | | ||
Get-ChildItem $(signOutPath) -Recurse | Write-Output | ||
|
||
- pwsh: | | ||
Set-Location "$(Build.SourcesDirectory)" | ||
# signOutPath points to directory with version number -- we want to point to the parent of that directory | ||
$ModulePath = Split-Path $(signOutPath) -Parent | ||
$(Build.SourcesDirectory)/Microsoft.PowerShell.Archive/.azdevops/SignAndPackageModule.ps1 -SignedPath $ModulePath | ||
Get-ChildItem -recurse -file -name | Write-Verbose -Verbose | ||
displayName: package build | ||
|
||
- publish: "$(signSrcPath)" | ||
artifact: build | ||
displayName: Publish build | ||
|
||
- stage: compliance | ||
displayName: Compliance | ||
dependsOn: Build | ||
jobs: | ||
- job: Compliance_Job | ||
pool: | ||
name: 1ES # Package ES CodeHub Lab E | ||
steps: | ||
- checkout: self | ||
- checkout: ComplianceRepo | ||
- download: current | ||
artifact: build | ||
|
||
- pwsh: | | ||
Get-ChildItem -Path "$(Pipeline.Workspace)\build" -Recurse | ||
displayName: Capture downloaded artifacts | ||
- template: script-module-compliance.yml@ComplianceRepo | ||
parameters: | ||
# component-governance | ||
sourceScanPath: '$(Build.SourcesDirectory)\Microsoft.PowerShell.Archive\src' | ||
# credscan | ||
suppressionsFile: '' | ||
# TermCheck | ||
optionsRulesDBPath: '' | ||
optionsFTPath: '' | ||
# tsa-upload | ||
codeBaseName: 'PSNativeCommandProxy_2020' | ||
# selections | ||
APIScan: false # set to false when not using Windows APIs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
# Import the built module | ||
Import-Module "$env:PIPELINE_WORKSPACE/ModuleBuild/Microsoft.PowerShell.Archive.psd1" | ||
|
||
Get-ChildItem "$env:PIPELINE_WORKSPACE/ModuleBuild" | Write-Verbose -Verbose | ||
|
||
$pesterMinVersion = "5.3.0" | ||
$pesterMaxVersion = "5.3.9" | ||
|
||
# If Pester 5.3.x is not installed, install it | ||
$pesterModule = Get-InstalledModule -Name "Pester" -MinimumVersion $pesterMinVersion -MaximumVersion $pesterMaxVersion | ||
if ($null -eq $pesterModule) { | ||
Install-Module -Name "Pester" -MinimumVersion $pesterMinVersion -MaximumVersion $pesterMaxVersion -Force | ||
} | ||
|
||
# Load Pester | ||
Import-Module -Name "Pester" -MinimumVersion $pesterMinVersion -MaximumVersion $pesterMaxVersion | ||
|
||
# Run tests | ||
$OutputFile = "$PWD/build-unit-tests.xml" | ||
$results = $null | ||
$results = Invoke-Pester -Script ./Tests/Compress-Archive.Tests.ps1 -OutputFile $OutputFile -PassThru -OutputFormat NUnitXml -Show Failed, Context, Describe, Fails | ||
Write-Host "##vso[artifact.upload containerfolder=testResults;artifactname=testResults]$OutputFile" | ||
if(!$results -or $results.FailedCount -gt 0 -or !$results.TotalCount) | ||
{ | ||
throw "Build or tests failed. Passed: $($results.PassedCount) Failed: $($results.FailedCount) Total: $($results.TotalCount)" | ||
} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
[CmdletBinding(SupportsShouldProcess=$true)] | ||
param ( | ||
[string]$SignedPath | ||
) | ||
|
||
|
||
$root = (Resolve-Path -Path "${PSScriptRoot}/../")[0] | ||
$Name = "Microsoft.PowerShell.Archive" | ||
$BuildOutputDir = Join-Path $root "\src\bin\Release" | ||
$ManifestPath = "${BuildOutputDir}\${Name}.psd1" | ||
$ManifestData = Import-PowerShellDataFile -Path $ManifestPath | ||
$Version = $ManifestData.ModuleVersion | ||
|
||
# this takes the files for the module and publishes them to a created, local repository | ||
# so the nupkg can be used to publish to the PSGallery | ||
function Export-Module | ||
{ | ||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "")] | ||
param() | ||
$packageRoot = $SignedPath | ||
|
||
if ( -not (Test-Path $packageRoot)) { | ||
throw "'$PubDir' does not exist" | ||
} | ||
|
||
# now constuct a nupkg by registering a local repository and calling publish module | ||
$repoName = [guid]::newGuid().ToString("N") | ||
Register-PSRepository -Name $repoName -SourceLocation $packageRoot -InstallationPolicy Trusted | ||
Publish-Module -Path $packageRoot -Repository $repoName | ||
Unregister-PSRepository -Name $repoName | ||
Get-ChildItem -Recurse -Name $packageRoot | Write-Verbose | ||
$nupkgName = "{0}.{1}-preview1.nupkg" -f ${Name},${Version} | ||
$nupkgPath = Join-Path $packageRoot $nupkgName | ||
if ($env:TF_BUILD) { | ||
# In Azure DevOps | ||
Write-Host "##vso[artifact.upload containerfolder=$nupkgName;artifactname=$nupkgName;]$nupkgPath" | ||
} | ||
} | ||
|
||
# The SBOM should already be in -SignedPath, so there is no need to copy it | ||
|
||
Export-Module |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
parameters: | ||
- name: vmImageName | ||
type: string | ||
default: 'windows-2019' | ||
|
||
- name: jobName | ||
type: string | ||
default: 'run_test_windows' | ||
|
||
- name: jobDisplayName | ||
type: string | ||
default: 'Run test' | ||
|
||
jobs: | ||
- job: '${{ parameters.jobName }}' | ||
pool: | ||
vmImage: ${{ parameters.vmImageName }} | ||
displayName: ${{ parameters.jobDisplayName }} | ||
steps: | ||
- download: current | ||
artifact: ModuleBuild | ||
|
||
- pwsh: | | ||
Write-Output ${{ parameters.vmImageName }} | ||
|
||
if ("${{ parameters.vmImageName }}" -like 'windows-*') | ||
{ | ||
$url = "https://github.com/PowerShell/PowerShell/releases/download/v7.3.0-preview.6/PowerShell-7.3.0-preview.6-win-x64.zip" | ||
$downloadFilename = "pwsh_download.msi" | ||
} | ||
|
||
if ("${{ parameters.vmImageName }}" -like 'macos-*') | ||
{ | ||
$url = "https://github.com/PowerShell/PowerShell/releases/download/v7.3.0-preview.6/powershell-7.3.0-preview.6-osx-x64.pkg" | ||
$downloadFilename = "pwsh_download.pkg" | ||
} | ||
if ("${{ parameters.vmImageName }}" -like 'ubuntu-*') | ||
{ | ||
$url = "https://github.com/PowerShell/PowerShell/releases/download/v7.3.0-preview.6/powershell-7.3.0-preview.6-linux-x64.tar.gz" | ||
$downloadFilename = "pwsh_download.tar.gz" | ||
} | ||
|
||
$downloadDestination = Join-Path $pwd $downloadFilename | ||
Invoke-WebRequest -Uri $url -OutFile $downloadDestination | ||
|
||
# Installation steps for windows | ||
if ("${{ parameters.vmImageName }}" -like 'windows-*') { | ||
Expand-Archive -Path $downloadDestination -DestinationPath "pwsh-preview" | ||
$powerShellPreview = Join-Path $pwd "pwsh-preview" "pwsh.exe" | ||
} | ||
if ("${{ parameters.vmImageName }}" -like 'ubuntu-*') | ||
{ | ||
gunzip -d $downloadDestination | ||
$downloadDestination = $downloadDestination.Replace(".gz", "") | ||
mkdir "pwsh-preview" | ||
tar -x -f $downloadDestination -C "pwsh-preview" | ||
$powerShellPreview = Join-Path $pwd "pwsh-preview" "pwsh" | ||
} | ||
if ("${{ parameters.vmImageName }}" -like 'macos-*') | ||
{ | ||
sudo xattr -rd com.apple.quarantine "${downloadDestination}" | ||
sudo installer -pkg "${downloadDestination}" -target / | ||
$powerShellPreview = "pwsh-preview" | ||
} | ||
# Write the location of PowerShell Preview | ||
Write-Host "##vso[task.setvariable variable=PowerShellPreviewExecutablePath;]$powershellPreview" | ||
displayName: Download and Install PowerShell Preview | ||
|
||
- pwsh: | | ||
$destination = Join-Path $pwd "7z.exe" | ||
$installUrl = "https://www.7-zip.org/a/7z2201-x64.exe" | ||
Invoke-WebRequest -Uri $installUrl -OutFile $destination | ||
# Run the installer in silent mode | ||
.$destination /S /D="C:\Program Files\7-Zip" | ||
displayName: Install 7-zip | ||
condition: and(succeeded(), startswith('${{ parameters.vmImageName }}', 'windows')) | ||
|
||
- pwsh: | | ||
if ("${{ parameters.vmImageName }}" -like 'windows-*') | ||
{ | ||
# Add 7-zip to PATH on Windows | ||
[System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH+';C:\Program Files\7-zip') | ||
} | ||
"$(PowerShellPreviewExecutablePath) .azdevops/RunTests.ps1" | Invoke-Expression | ||
displayName: Run Tests | ||
|
||
- task: PublishTestResults@2 | ||
displayName: 'Publish Test Results **/*tests.xml' | ||
inputs: | ||
testResultsFormat: NUnit | ||
testResultsFiles: '**/*tests.xml' | ||
testRunTitle: 'Build Unit Tests' | ||
continueOnError: true | ||
condition: succeededOrFailed() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.