From f3c6c01e2b43f3ce4a3ead0dbe6e31fed98221bd Mon Sep 17 00:00:00 2001 From: Joel Timothy Oh Date: Sun, 19 May 2024 13:42:33 +0000 Subject: [PATCH] Test (integration): Add tests for generating release notes from all possible git ref types assigned to `$env:RELEASE_TAG_REF` --- .../PSRepositoryReleaseManager.Tests.ps1 | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/PSRepositoryReleaseManager/PSRepositoryReleaseManager.Tests.ps1 b/src/PSRepositoryReleaseManager/PSRepositoryReleaseManager.Tests.ps1 index 3abc4e2..393a055 100644 --- a/src/PSRepositoryReleaseManager/PSRepositoryReleaseManager.Tests.ps1 +++ b/src/PSRepositoryReleaseManager/PSRepositoryReleaseManager.Tests.ps1 @@ -1,7 +1,6 @@ Describe "PSRepositoryReleaseManager" -Tag 'Integration' { BeforeAll { $ErrorView = 'NormalView' - $env:RELEASE_TAG_REF = 'HEAD' $env:PROJECT_DIRECTORY = "$(git rev-parse --show-toplevel)" } BeforeEach { @@ -10,12 +9,44 @@ Describe "PSRepositoryReleaseManager" -Tag 'Integration' { $env:RELEASE_NOTES_VARIANT = $null $env:RELEASE_NOTES_PATH = $null } - It "Runs Invoke-Generate.ps1 with `$env:PROJECT_DIRECTORY `$env:RELEASE_TAG_REF" { + It "Runs Invoke-Generate.ps1 with `$env:PROJECT_DIRECTORY `$env:RELEASE_TAG_REF (HEAD)" { + $env:RELEASE_TAG_REF = 'HEAD' + + $stdout = ../src/scripts/ci/Invoke-Generate.ps1 + "Generate notes content:" | Write-Verbose + Get-Content -Path "$stdout" | Out-String -Stream | % { $_.Trim() } | ? { $_ } | Write-Host + } + It "Runs Invoke-Generate.ps1 with `$env:PROJECT_DIRECTORY `$env:RELEASE_TAG_REF (branch)" { + $env:RELEASE_TAG_REF = 'master' + git checkout -b 'master' 'HEAD' + + $stdout = ../src/scripts/ci/Invoke-Generate.ps1 + "Generate notes content:" | Write-Verbose + Get-Content -Path "$stdout" | Out-String -Stream | % { $_.Trim() } | ? { $_ } | Write-Host + } + It "Runs Invoke-Generate.ps1 with `$env:PROJECT_DIRECTORY `$env:RELEASE_TAG_REF (release tag)" { + $env:RELEASE_TAG_REF = git describe --tags --abbrev=0 + + $stdout = ../src/scripts/ci/Invoke-Generate.ps1 + "Generate notes content:" | Write-Verbose + Get-Content -Path "$stdout" | Out-String -Stream | % { $_.Trim() } | ? { $_ } | Write-Host + } + It "Runs Invoke-Generate.ps1 with `$env:PROJECT_DIRECTORY `$env:RELEASE_TAG_REF (remote branch)" { + $env:RELEASE_TAG_REF = 'origin/master' + + $stdout = ../src/scripts/ci/Invoke-Generate.ps1 + "Generate notes content:" | Write-Verbose + Get-Content -Path "$stdout" | Out-String -Stream | % { $_.Trim() } | ? { $_ } | Write-Host + } + It "Runs Invoke-Generate.ps1 with `$env:PROJECT_DIRECTORY `$env:RELEASE_TAG_REF (commit hash)" { + $env:RELEASE_TAG_REF = git rev-parse HEAD + $stdout = ../src/scripts/ci/Invoke-Generate.ps1 "Generate notes content:" | Write-Verbose Get-Content -Path "$stdout" | Out-String -Stream | % { $_.Trim() } | ? { $_ } | Write-Host } It "Runs Invoke-Generate.ps1 with `$env:PROJECT_DIRECTORY `$env:RELEASE_TAG_REF `$env:RELEASE_NOTES_VARIANT" { + $env:RELEASE_TAG_REF = 'HEAD' $env:RELEASE_NOTES_VARIANT = 'Changes-HashSubject-NoMerges' $stdout = ../src/scripts/ci/Invoke-Generate.ps1 @@ -23,6 +54,7 @@ Describe "PSRepositoryReleaseManager" -Tag 'Integration' { Get-Content -Path "$stdout" | Out-String -Stream | % { $_.Trim() } | ? { $_ } | Write-Host } It "Runs Invoke-Generate.ps1 with `$env:PROJECT_DIRECTORY `$env:RELEASE_TAG_REF `$env:RELEASE_NOTES_PATH (full)" { + $env:RELEASE_TAG_REF = 'HEAD' $env:RELEASE_NOTES_PATH = "$(git rev-parse --show-toplevel)/.release-notes.fullpath.md" $stdout = ../src/scripts/ci/Invoke-Generate.ps1 @@ -30,6 +62,7 @@ Describe "PSRepositoryReleaseManager" -Tag 'Integration' { Get-Content -Path "$stdout" | Out-String -Stream | % { $_.Trim() } | ? { $_ } | Write-Host } It "Runs Invoke-Generate.ps1 with `$env:PROJECT_DIRECTORY `$env:RELEASE_TAG_REF `$env:RELEASE_NOTES_PATH (relative)" { + $env:RELEASE_TAG_REF = 'HEAD' $env:RELEASE_NOTES_PATH = ".release-notes.relativepath.md" $stdout = ../src/scripts/ci/Invoke-Generate.ps1 @@ -37,6 +70,7 @@ Describe "PSRepositoryReleaseManager" -Tag 'Integration' { Get-Content -Path "$stdout" | Out-String -Stream | % { $_.Trim() } | ? { $_ } | Write-Host } It "Runs Invoke-Generate.ps1 with `$env:PROJECT_DIRECTORY `$env:RELEASE_TAG_REF `$env:RELEASE_NOTES_VARIANT `$env:RELEASE_NOTES_PATH (all variants)" { + $env:RELEASE_TAG_REF = 'HEAD' $ReleaseNotesVariant = Get-ChildItem "../src/PSRepositoryReleaseManager/generate/variants" | % { $_.BaseName } "Release notes variants:" | Write-Verbose $ReleaseNotesVariant | Write-Host