Skip to content

Commit

Permalink
Test (integration): Add tests for generating release notes from all p…
Browse files Browse the repository at this point in the history
…ossible git ref types assigned to `$env:RELEASE_TAG_REF`
  • Loading branch information
joeltimothyoh committed May 19, 2024
1 parent 9c47d0f commit f9e6a0b
Showing 1 changed file with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -10,33 +9,63 @@ 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
"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_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
"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_PATH (relative)" {
$env:RELEASE_TAG_REF = 'HEAD'
$env:RELEASE_NOTES_PATH = ".release-notes.relativepath.md"

$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_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
Expand Down

0 comments on commit f9e6a0b

Please sign in to comment.