Skip to content

Commit

Permalink
Merge branch 'release/1.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
abbgrade committed Dec 19, 2021
2 parents 1950c36 + bd8fb63 commit fcbbd24
Show file tree
Hide file tree
Showing 29 changed files with 498 additions and 344 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ for:
-
matrix:
only:
- image: Visual Studio 2017
- image: Visual Studio 2019
deploy_script:
- ps: |
if ( $env:APPVEYOR_REPO_TAG_NAME ) {
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/ci.yml

This file was deleted.

66 changes: 66 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
on:
push:
branches: [ develop, bugfix/*, feature/* ]
pull_request:
branches: [ develop ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2

- name: Install build dependencies
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module InvokeBuild -ErrorAction Stop
Install-Module PlatyPS -ErrorAction Stop
- name: Update docs
shell: pwsh
run: Invoke-Build UpdateDocs

- name: Create build
shell: pwsh
run: Invoke-Build Build

- name: Upload build
uses: actions/upload-artifact@v2
with:
path: build/PSDocker
name: build

test:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source
uses: actions/checkout@v2

- name: Run tests
shell: pwsh
run: |
$config = New-PesterConfiguration @{
'Run.Path' = 'test'
'Run.Exit' = $true
'TestResult.Enabled' = $true
'CodeCoverage.Enabled' = $true
}
Invoke-Pester -Configuration $config
- name: Upload test results
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os }}-test-results
path: testResults.xml

- name: Upload test coverage
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os }}-test-coverage
path: coverage.xml
50 changes: 39 additions & 11 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
"windows": {
"options": {
"shell": {
"executable": "powershell.exe",
"args": [ "-NoProfile", "-ExecutionPolicy Bypass", "-NonInteractive", "-Command" ]
"executable": "pwsh.exe",
"args": [
"-NoProfile",
"-ExecutionPolicy Bypass",
"-NonInteractive",
"-Command"
]
}
}
},
Expand All @@ -31,28 +36,51 @@
"label": "Build",
"type": "shell",
"group": "build",
"command": "$DebugPreference = 'Continue'; Invoke-Build Clean,Build",
"command": "Invoke-Build Build",
"problemMatcher": []
},
{
"label": "Rebuild",
"type": "shell",
"group": "build",
"command": "Invoke-Build Clean, Build",
"problemMatcher": []
},
{
"label": "Clean",
"type": "shell",
"command": "$DebugPreference = 'Continue'; Invoke-Build Clean"
"command": "Invoke-Build Clean",
"problemMatcher": []
},
{
"label": "Install",
"type": "shell",
"command": "Invoke-Build Clean, Install",
"problemMatcher": []
},
{
"label": "Update docs",
"type": "shell",
"command": "$DebugPreference = 'Continue'; Invoke-Build UpdateDocs",
"command": "Invoke-Build UpdateDocs",
"problemMatcher": []
},
{
"label": "Test",
"type": "shell",
"group": "test",
"command": "Invoke-Build Test",
"problemMatcher": [
"$pester"
]
}
"type": "shell",
"command": "Invoke-Pester",
"args": [
"-Output", "Detailed"
],
"options": {
"cwd": "test"
},
"problemMatcher": "$msCompile",
"presentation": {
"echo": false,
"showReuseMessage": false
},
"dependsOn": "Rebuild"
},
]
}
54 changes: 11 additions & 43 deletions PSDocker.build.ps1
Original file line number Diff line number Diff line change
@@ -1,47 +1,15 @@
function Get-BuildRoot {
if ( $env:APPVEYOR ) {
Write-Output $env:APPVEYOR_BUILD_FOLDER
} else {
Write-Output '.'
}
}
<#
.Synopsis
Build script <https://github.com/nightroman/Invoke-Build>
[string] $root = Get-BuildRoot
[string] $sourcePath = "$root\src"
[string] $buildPath = "$root\build"
[string] $docPath = "$root\docs"
[string] $manifestFilePath = "$sourcePath\PSDocker.psd1"
[string] $moduleBuildPath = "$buildPath\PSDocker"
.Example
Invoke-Build Publish -NuGetApiKey xyz
#>

task Build PrepareBuildPath, CopyArtefacts
param(
[string] $NuGetApiKey = $env:nuget_apikey
)

task PrepareBuildPath {
New-Item -Path $buildPath -ItemType Directory | Out-Null
}
. $PsScriptRoot\tasks\Build.Tasks.ps1

task CleanBuildPath {
Remove-Item $buildPath -Recurse -ErrorAction 'Continue'
}

task CopyArtefacts {
Copy-Item -Path $sourcePath -Destination $moduleBuildPath -Recurse
}

task Test {
Invoke-Pester $sourcePath
}

task Publish {
Publish-Module -Path $moduleBuildPath -NuGetApiKey $env:nuget_apikey
}

task Clean CleanBuildPath

task UpdateDocs {
Import-Module $manifestFilePath -Force
Remove-Item -Path $docPath/*
New-MarkdownHelp -Module PSDocker -OutputFolder $docPath
# Update-MarkdownHelp -Path $docPath -AlphabeticParamsOrder -Force
}

task . Clean, Build
task . Clean, Build
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## Installation

Make sure that the docker cli is installed. e.g. from [Chocolatey](https://chocolatey.org/packages/docker-cli) or with [Docker Desktop](https://hub.docker.com/editions/community/docker-ce-desktop-windows/).

Install PSDocker from [PowerShell Gallery](https://www.powershellgallery.com/packages/psdocker) using a PowerShell command line:

Install-Module -Name PSDocker -Scope CurrentUser
Expand All @@ -12,6 +14,7 @@ Install PSDocker from [PowerShell Gallery](https://www.powershellgallery.com/pac

This project uses a [build script](./PsDocker.build.ps1) that is based on [Invoke-Build](https://github.com/nightroman/Invoke-Build).
For installation details see the instructions from the Invoke-Build project, but we recommend `Install-Module InvokeBuild -Scope CurrentUser`.
The documentation is based on [platyPS](https://github.com/PowerShell/platyPS), so you may want to execute `Install-Module PlatyPs -Scope CurrentUser`.

You can run the build by:

Expand All @@ -36,6 +39,11 @@ See the folder [docs](./docs) for examples.

## Changelog

### Version 1.6.0

- Fixed timeout issue
- Added `-Remove` parameter to New-Container.

### Version 1.5.0

- Adopted changes from the Docker CLI
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Invoke-ClientCommand.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function Invoke-ClientCommand {
} else {
Write-Verbose 'No process error output'
}
if ( $process.TotalProcessorTime.TotalSeconds -ge $Timeout ) {
if ( $Timeout -gt 0 -and $process.TotalProcessorTime.TotalSeconds -ge $Timeout ) {
Write-Error "Process timed out ($processCall) after $( $process.TotalProcessorTime )."
}
}
2 changes: 1 addition & 1 deletion src/PSDocker.psd1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
RootModule = 'PSDocker.psm1'
ModuleVersion = '0.0.1'
ModuleVersion = '1.6.0'
GUID = '22cb8e1e-1c64-446b-960c-7c5e8529eb31'
Author = 'Steffen Kampmann'
Copyright = '(c) 2018 s.kampmann. Alle Rechte vorbehalten.'
Expand Down
56 changes: 45 additions & 11 deletions src/Public/New-Container.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ function New-Container {
Specifies if the container should be interactive.
That means to connect the standard-in stream of container and client.
.PARAMETER Terminal
Allocate a pseudo-TTY.
.PARAMETER Remove
Automatically remove the container when it exits.
.PARAMETER ArgumentList
Specifies a command or arguments to run on the container.
.OUTPUTS
Container: Returns a Container object for the created container.
Expand Down Expand Up @@ -94,7 +103,19 @@ function New-Container {
[switch] $Detach,

[Parameter( Mandatory = $false, ValueFromPipelineByPropertyName = $true )]
[switch] $Interactive
[switch] $Interactive,

[Parameter( Mandatory = $false, ValueFromPipelineByPropertyName = $true )]
[switch] $Terminal,

[Parameter( Mandatory = $false )]
[switch] $Remove,

[Parameter( Mandatory = $false )]
[switch] $StringOutput,

[Parameter( Mandatory = $false )]
[string[]] $ArgumentList
)

process {
Expand Down Expand Up @@ -132,20 +153,33 @@ function New-Container {
$arguments.Add( '--interactive' ) | Out-Null
}

$arguments.Add( $ImageName ) | Out-Null
if ( $Terminal ) {
$arguments.Add( '--tty' ) | Out-Null
}

# create container
Invoke-ClientCommand 'run', $arguments -Timeout $Timeout
if ( $Remove ) {
$arguments.Add( '--rm' ) | Out-Null
}

$arguments.Add( $ImageName ) | Out-Null

# check container
$container = Get-Container -Latest -Timeout $StatusTimeout
if ( -not $container.Name ) {
Write-Error "Failed to create container"
if ( $ArgumentList ) {
$arguments.AddRange( $ArgumentList )
}
Write-Verbose "Docker container '$( $container.Name )' created."

# return result
Write-Output $container
# create container
Invoke-ClientCommand 'run', $arguments -StringOutput:$StringOutput -Timeout $Timeout

if ( -Not $Remove ) {
# check container
$container = Get-Container -Latest -Timeout $StatusTimeout
if ( -not $container.Name ) {
Write-Error "Failed to create container"
}
Write-Verbose "Docker container '$( $container.Name )' created."

# return result
Write-Output $container
}
}
}
Loading

0 comments on commit fcbbd24

Please sign in to comment.