Skip to content

Commit

Permalink
feature: Accept scriptblock as pipeline input (#1)
Browse files Browse the repository at this point in the history
* Adds ValueFromPipeline to Document parameter
* Adds testspace
* Release v0.1.1

---------

Co-authored-by: Chris Hunt <[email protected]>
  • Loading branch information
cdhunt and Chris Hunt authored Feb 2, 2024
1 parent 6d378b7 commit abc66ec
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 10 deletions.
31 changes: 27 additions & 4 deletions .github/workflows/powershell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
run: ./build.ps1 build ${{ steps.nbgv.outputs.VersionMajor }} ${{ steps.nbgv.outputs.VersionMinor }} ${{ steps.nbgv.outputs.BuildNumber }} ${{ steps.nbgv.outputs.VersionRevision }} ${{ steps.nbgv.outputs.PrereleaseVersionNoLeadingHyphen }}

- name: Store build output
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: build
path: |
Expand All @@ -76,15 +76,30 @@ jobs:
- uses: actions/checkout@v4

- name: Download build output
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: build
path: publish

- name: Install Utils
shell: pwsh
run: |
apt-get update
apt-get install curl jq -y
- uses: testspace-com/setup-testspace@v1
with:
domain: ${{github.repository_owner}}

- name: Test
shell: pwsh
run: ./build.ps1 test

- name: Publish Results to Testspace
run: testspace "[v${{ matrix.pwshv }}]testResults.xml"

if: always()

test5:
permissions:
contents: read # for actions/checkout to fetch code
Expand All @@ -98,15 +113,23 @@ jobs:
fetch-depth: 0

- name: Download build output
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: build
path: publish

- uses: testspace-com/setup-testspace@v1
with:
domain: ${{github.repository_owner}}

- name: Test
shell: powershell
run: ./build.ps1 test

- name: Publish Results to Testspace
run: testspace "[v5.1]testResults.xml"
if: always()

publish:
permissions:
contents: read # for actions/checkout to fetch code
Expand All @@ -121,7 +144,7 @@ jobs:
- uses: actions/checkout@v4

- name: Download build output
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: build
path: publish
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ You can use this to automatically maintain and synchronize documentation in mult

## CI Status

[![PowerShell](https://github.com/cdhunt/Format-Document/actions/workflows/powershell.yml/badge.svg)](https://github.com/cdhunt/Format-Document/actions/workflows/powershell.yml)
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/cdhunt/Format-Document/powershell.yml?style=flat&logo=github)
[![Testspace pass ratio](https://img.shields.io/testspace/pass-ratio/cdhunt/cdhunt%3AFormat-Document/main)](https://cdhunt.testspace.com/projects/67973/spaces)
[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/Format-Document.svg?color=%235391FE&label=PowerShellGallery&logo=powershell&style=flat)](https://www.powershellgallery.com/packages/Format-Document)

![Build history](https://buildstats.info/github/chart/cdhunt/Format-Document?branch=main)

## Install

[powershellgallery.com/packages/Format-Document](https://www.powershellgallery.com/packages/Format-Document)

`Install-Module -Name Format-Document` or `Install-PSResource -Name Format-Document`

![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/httpunitps?color=%235391FE&style=flat)

## Docs

[Full Docs](docs)
Expand Down
15 changes: 12 additions & 3 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,20 @@ function Build {
function Test {
param ()

if ($null -eq (Get-Module Pester -ListAvailable)) {
Install-Module -Name Pester -Confirm:$false -Force
if ($null -eq (Get-Module Pester -ListAvailable | Where-Object { [version]$_.Version -ge [version]"5.5.0" })) {
Install-Module -Name Pester -MinimumVersion 5.5.0 -Confirm:$false -Force
}

Invoke-Pester -Path test -Output detailed
$config = New-PesterConfiguration -Hashtable @{
Run = @{ Path = "test" }
TestResult = @{
Enabled = $true
OutputFormat = "NUnitXml"
}
Output = @{ Verbosity = "Detailed" }
}

Invoke-Pester -Configuration $config
}


Expand Down
2 changes: 1 addition & 1 deletion src/public/New-Document.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function New-Document {
#>
[CmdletBinding()]
param (
[Parameter(Mandatory, Position = 0)]
[Parameter(Mandatory, Position = 0, ValueFromPipeline)]
[scriptblock]
$Document,

Expand Down
13 changes: 13 additions & 0 deletions test/Format-Document.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ Describe 'Format-Document' {
}

}

Context 'Content by Pipeline' {
It 'New-Document should accept a scriptblock by pipeline' {
$doc = {
H1 "My Text"
}
$resultMd = $doc | New-Document
$resultHtml = $doc | New-Document -Type 'Html/Bootstrap'

$resultMd | Should -Contain '# My Text'
$resultHtml | Should -Contain '<h1>My Text</h1>'
}
}
}


Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.1.0",
"version": "0.1.1",
"cloudBuild": {
"buildNumber": {
"enabled": true
Expand Down

0 comments on commit abc66ec

Please sign in to comment.