From a57ec24788ec54151ecc11c2442ddfe5bcb07f04 Mon Sep 17 00:00:00 2001 From: Tyler Doerksen Date: Mon, 12 Aug 2019 13:02:45 -0500 Subject: [PATCH 1/8] pester test results output for build pipeline --- PoshWyam.build.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/PoshWyam.build.ps1 b/PoshWyam.build.ps1 index 25e9c56..ecb3295 100644 --- a/PoshWyam.build.ps1 +++ b/PoshWyam.build.ps1 @@ -52,9 +52,7 @@ Task RunTests InstallDependencies, Stage, { } - $testResults = Invoke-Pester @invokePesterParams - - $testResults | ConvertTo-Json -Depth 5 | Set-Content (Join-Path $Artifacts 'PesterResults.json') + Invoke-Pester -OutputFile (Join-Path $Artifacts 'PesterResults.xml') } Task ConfirmTestsPassed { From 8f4ae33713c9f675c219b679136501a05a3ca378 Mon Sep 17 00:00:00 2001 From: Tyler Doerksen Date: Mon, 12 Aug 2019 14:36:01 -0500 Subject: [PATCH 2/8] fixing tests --- PoshWyam/Private/ConvertFrom-Yaml.ps1 | 4 ++-- PoshWyam/Public/Invoke-Wyam.ps1 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/PoshWyam/Private/ConvertFrom-Yaml.ps1 b/PoshWyam/Private/ConvertFrom-Yaml.ps1 index 7736d7d..3fe510f 100644 --- a/PoshWyam/Private/ConvertFrom-Yaml.ps1 +++ b/PoshWyam/Private/ConvertFrom-Yaml.ps1 @@ -9,9 +9,9 @@ function ConvertFrom-Yaml { if ($Yaml) { $stringReader = New-Object System.IO.StringReader($Yaml) try { - $deserializer = [YamlDotNet.Serialization.Deserializer]::new() + $deserializer = [YamlDotNet.Serialization.DeserializerBuilder]::new().Build() $yamlObject = $deserializer.Deserialize($stringReader); - $serializer = [YamlDotNet.Serialization.Serializer]::new('JsonCompatible') + $serializer = [YamlDotNet.Serialization.SerializerBuilder]::new().JsonCompatible().Build() $stringBuilder = [System.Text.StringBuilder]::new() $stringWriter = [System.IO.StringWriter]::new($stringBuilder) $serializer.Serialize($stringWriter, $yamlObject) diff --git a/PoshWyam/Public/Invoke-Wyam.ps1 b/PoshWyam/Public/Invoke-Wyam.ps1 index a27272d..35074bb 100644 --- a/PoshWyam/Public/Invoke-Wyam.ps1 +++ b/PoshWyam/Public/Invoke-Wyam.ps1 @@ -255,7 +255,7 @@ function Invoke-Wyam { if (-not $root -or -not (Test-Path $root)) { $root = Join-Path $ModuleRoot 'Wyam' } - $wyam = Get-ChildItem -Path $root -Include wyam.exe -Recurse | Select-Object -First 1 + $wyam = Get-ChildItem -Path $root -Include wyam.dll -Recurse | Select-Object -First 1 $wyam = Resolve-Path $wyam Write-Verbose "Invoke-Wyam: Tool located at '$wyam'" $Arguments = ($Arguments | Quote) -join ' ' @@ -266,7 +266,7 @@ function Invoke-Wyam { Install-Wyam -Root $root } - $expr = "&`"$wyam`" $Arguments" + $expr = "&`"dotnet`" `"$wyam`" $Arguments" Write-Verbose "Invoke-Wyam: Running command '$expr'" Invoke-Expression $expr } From 0daec1c6e23a0ac7ecb48e953b12c7b762986f75 Mon Sep 17 00:00:00 2001 From: Tyler Doerksen Date: Mon, 12 Aug 2019 15:04:35 -0500 Subject: [PATCH 3/8] fixing New-BlogPost --- PoshWyam/Public/New-BlogPost.ps1 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/PoshWyam/Public/New-BlogPost.ps1 b/PoshWyam/Public/New-BlogPost.ps1 index 640efe7..4935180 100644 --- a/PoshWyam/Public/New-BlogPost.ps1 +++ b/PoshWyam/Public/New-BlogPost.ps1 @@ -11,7 +11,7 @@ function New-BlogPost { [Parameter(Position=0, Mandatory=$True)] [string] $Title, - + # The tags to include in the blog post. [Parameter(Position=1, Mandatory=$False)] [string[]] @@ -24,10 +24,10 @@ function New-BlogPost { [switch] $Draft ) - + begin { } - + process { # Get directory $parms = @{ 'Root' = $Root } @@ -36,8 +36,10 @@ function New-BlogPost { } $posts = Get-BlogPostsLocation @parms + $dateString = (Get-Date).ToString("yyyy-MM-dd") + $fileName = Get-FileName -Title $Title -Extension ".md" # Get path to post to create - $path = Join-Path $posts (Get-BlogPostName $Title) + $path = Join-Path $posts "$dateString-$fileName" # Create post $content = @" @@ -52,7 +54,7 @@ Tags: [$(($Tag | ForEach-Object { """$_""" }) -join ', ')] Set-Content -Path $path -Value $content Resolve-Path $path } - + end { } } From 6cfd5a799a8e36e7f202b44440fa67d89d489c94 Mon Sep 17 00:00:00 2001 From: Tyler Doerksen Date: Mon, 12 Aug 2019 15:22:56 -0500 Subject: [PATCH 4/8] adding flag for date prefix. Adding Tests. --- PoshWyam/Public/New-BlogPost.ps1 | 10 ++++++++-- tests/Public/New-BlogPost.tests.ps1 | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/Public/New-BlogPost.tests.ps1 diff --git a/PoshWyam/Public/New-BlogPost.ps1 b/PoshWyam/Public/New-BlogPost.ps1 index 4935180..85d0461 100644 --- a/PoshWyam/Public/New-BlogPost.ps1 +++ b/PoshWyam/Public/New-BlogPost.ps1 @@ -17,6 +17,9 @@ function New-BlogPost { [string[]] $Tag = @(), + [switch] + $IncludeDateInFileName, + # The Wyam project root. $Root = (Get-WyamRoot), @@ -36,10 +39,13 @@ function New-BlogPost { } $posts = Get-BlogPostsLocation @parms - $dateString = (Get-Date).ToString("yyyy-MM-dd") $fileName = Get-FileName -Title $Title -Extension ".md" + + if($IncludeDateInFileName){ + $fileName = "$((Get-Date).ToString("yyyy-MM-dd"))-$fileName" + } # Get path to post to create - $path = Join-Path $posts "$dateString-$fileName" + $path = Join-Path $posts $fileName # Create post $content = @" diff --git a/tests/Public/New-BlogPost.tests.ps1 b/tests/Public/New-BlogPost.tests.ps1 new file mode 100644 index 0000000..5f5364d --- /dev/null +++ b/tests/Public/New-BlogPost.tests.ps1 @@ -0,0 +1,27 @@ +Import-Module "$Artifacts\PoshWyam\PoshWyam.psd1" -Force + +Describe "New-BlogPost" { + + BeforeAll { + [void](New-Item -Path "TestDrive:\config.wyam" -ItemType File) + [void](New-Item -Path "TestDrive:\input\posts" -ItemType Directory) + + Push-Location "TestDrive:\" + } + + AfterAll { + Pop-Location + } + + Context "With -Title" { + It "runs without error" { + + $before = (Get-ChildItem "TestDrive:\input\posts").Count + New-BlogPost -Title "test post" + + (Get-ChildItem "TestDrive:\input\posts").Count | Should be ($before + 1) + + } + } + +} \ No newline at end of file From 87397de80999083b0a37ae2a616db984637bd043 Mon Sep 17 00:00:00 2001 From: Tyler D Date: Thu, 12 Dec 2019 15:21:28 -0600 Subject: [PATCH 5/8] Adding GitHub Actions --- .github/workflows/main.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..93e657a --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,14 @@ +name: CI + +on: [push] + +jobs: + build: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v1 + - name: Invoke-Build + run: build.ps1 + shell: powershell From 9c8264d06dce876343d4a0e3a8ced5df20814e79 Mon Sep 17 00:00:00 2001 From: Tyler Doerksen Date: Thu, 12 Dec 2019 15:23:09 -0600 Subject: [PATCH 6/8] fixing GitHub actions build --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 93e657a..52e4598 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,5 +10,5 @@ jobs: steps: - uses: actions/checkout@v1 - name: Invoke-Build - run: build.ps1 + run: .\build.ps1 shell: powershell From e7ceb587914e723acfd1ea7e6e2c38c105cd7ac0 Mon Sep 17 00:00:00 2001 From: Tyler Doerksen Date: Thu, 12 Dec 2019 15:25:35 -0600 Subject: [PATCH 7/8] fixing build - error when running powershell --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 27754f0..6900d53 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,7 +1,7 @@ if (-not (Get-Module InvokeBuild)) { Import-Module InvokeBuild -ErrorAction SilentlyContinue if (-not (Get-Module InvokeBuild)) { - Install-Module InvokeBuild -Scope CurrentUser + Install-Module InvokeBuild -Scope CurrentUser -Force Import-Module InvokeBuild -ErrorAction Stop } } From 6297b08c66b2efefc979c181b54257637c9c16dd Mon Sep 17 00:00:00 2001 From: Tyler Doerksen Date: Thu, 12 Dec 2019 15:43:07 -0600 Subject: [PATCH 8/8] adding pull request validation --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 52e4598..c7c5db6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,6 @@ name: CI -on: [push] +on: [push, pull_request] jobs: build: