-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See CHANGELOG.md, pipeline changes & added tests
- Loading branch information
Showing
20 changed files
with
574 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: "Create GitHub release and publish to the PowerShell Gallery" | ||
name: "CI/CD Pipeline" | ||
|
||
on: | ||
push: | ||
|
@@ -7,6 +7,8 @@ on: | |
branches: | ||
- main | ||
- master | ||
schedule: | ||
- cron: '11 7 * * *' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
@@ -51,17 +53,24 @@ jobs: | |
Invoke-Build -File "custom.build.ps1" @Params -Task PostBuild | ||
shell: pwsh | ||
|
||
- name: Pester Tests | ||
if: hashFiles('tests/invoke.tests.ps1') != '' | ||
run: pwsh -File "tests/invoke.tests.ps1" | ||
|
||
- name: Custom pre-release tasks | ||
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | ||
run: Invoke-Build -File "custom.build.ps1" -ModuleName $env:GH_PROJECTNAME -Author $env:GH_USERNAME -Version $env:GitVersion_SemVer -NewRelease $true -Task PreRelease | ||
shell: pwsh | ||
|
||
- name: Publish to PowerShell Gallery | ||
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | ||
run: Invoke-Build -File "invoke.build.ps1" -ModuleName $env:GH_PROJECTNAME -Task "PublishModule" | ||
shell: pwsh | ||
env: | ||
PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }} | ||
|
||
- name: Create release | ||
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
|
@@ -74,6 +83,7 @@ jobs: | |
prerelease: false | ||
|
||
- name: Upload release asset | ||
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | ||
id: upload_release_asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
|
@@ -85,17 +95,20 @@ jobs: | |
asset_content_type: application/zip | ||
|
||
- name: Commit CHANGELOG.md and module manifest | ||
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "GitHub Action" | ||
git add CHANGELOG.md src/${GH_PROJECTNAME}.psd1 docs | ||
git commit -m "Released ${{ env.GitVersion_SemVer }}" | ||
- name: Push commit | ||
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Custom post-release tasks | ||
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | ||
run: Invoke-Build -File "custom.build.ps1" -ModuleName $env:GH_PROJECTNAME -Author $env:GH_USERNAME -Version $env:GitVersion_SemVer -NewRelease $true -Task PostRelease | ||
shell: pwsh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
BeforeAll { | ||
# Always use built code if running in a pipeline | ||
if ($env:USER -eq 'runner') { | ||
Import-Module "$PSScriptRoot/../../build/PSShlink/PSShlink.psd1" -Force | ||
} | ||
# Check if module is already imported, as it can be via VSCode task where you can choose what code base to test | ||
# and you might not want to cloober it with the non-built code | ||
elseif (-not (Get-Module PSShlink)) { | ||
Import-Module "$PSScriptRoot/../../src/PSShlink.psd1" -Force | ||
} | ||
} | ||
|
||
Describe "Get-ShlinkDomains" { | ||
It "Returns domains configured with Shlink" { | ||
$Params = @{ | ||
ShlinkServer = $env:ShlinkServer | ||
ShlinkApiKey = $env:ShlinkAPIKey | ConvertTo-SecureString | ||
ErrorAction = 'Stop' | ||
} | ||
$Object = Get-ShlinkDomains @Params | ||
$Object.data.domain | Should -Be 'psshlink.codaamok' | ||
$Object.data.isDefault | Should -BeTrue | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
BeforeAll { | ||
# Always use built code if running in a pipeline | ||
if ($env:USER -eq 'runner') { | ||
Import-Module "$PSScriptRoot/../../build/PSShlink/PSShlink.psd1" -Force | ||
} | ||
# Check if module is already imported, as it can be via VSCode task where you can choose what code base to test | ||
# and you might not want to cloober it with the non-built code | ||
elseif (-not (Get-Module PSShlink)) { | ||
Import-Module "$PSScriptRoot/../../src/PSShlink.psd1" -Force | ||
} | ||
} | ||
|
||
Describe "Get-ShlinkServer" { | ||
It "Returns Shlink instance information" { | ||
$Params = @{ | ||
ShlinkServer = $env:ShlinkServer | ||
ErrorAction = 'Stop' | ||
} | ||
$Object = Get-ShlinkServer @Params | ||
$Object.status | Should -Be 'Pass' | ||
[System.Version]$Object.version | Should -BeOfType [System.Version] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
BeforeAll { | ||
# Always use built code if running in a pipeline | ||
if ($env:USER -eq 'runner') { | ||
Import-Module "$PSScriptRoot/../../build/PSShlink/PSShlink.psd1" -Force | ||
} | ||
# Check if module is already imported, as it can be via VSCode task where you can choose what code base to test | ||
# and you might not want to cloober it with the non-built code | ||
elseif (-not (Get-Module PSShlink)) { | ||
Import-Module "$PSScriptRoot/../../src/PSShlink.psd1" -Force | ||
} | ||
} | ||
|
||
Describe "Get-ShlinkTags" { | ||
It "Returns all tags on the Shlink instance" { | ||
$Params = @{ | ||
ShlinkServer = $env:ShlinkServer | ||
ShlinkApiKey = $env:ShlinkAPIKey | ConvertTo-SecureString | ||
ErrorAction = 'Stop' | ||
} | ||
$Object = Get-ShlinkTags @Params | ||
$Object.tag | Should -Be 'psshlinktag1', 'psshlinktag2' | ||
$Object.shortUrlsCount | Should -Be '1','1' | ||
} | ||
|
||
It "Returns tags on Shlink instance using search term '<_>'" -ForEach 1,2 { | ||
$Params = @{ | ||
SearchTerm = $_ | ||
ShlinkServer = $env:ShlinkServer | ||
ShlinkApiKey = $env:ShlinkAPIKey | ConvertTo-SecureString | ||
ErrorAction = 'Stop' | ||
} | ||
$Object = Get-ShlinkTags @Params | ||
$Object.tag | Should -Be ('psshlinktag{0}' -f $_) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
BeforeAll { | ||
# Always use built code if running in a pipeline | ||
if ($env:USER -eq 'runner') { | ||
Import-Module "$PSScriptRoot/../../build/PSShlink/PSShlink.psd1" -Force | ||
} | ||
# Check if module is already imported, as it can be via VSCode task where you can choose what code base to test | ||
# and you might not want to cloober it with the non-built code | ||
elseif (-not (Get-Module PSShlink)) { | ||
Import-Module "$PSScriptRoot/../../src/PSShlink.psd1" -Force | ||
} | ||
} | ||
|
||
Describe "Get-ShlinkUrl" { | ||
It "Retrieve 'PSShlink-Test' short URL <type>" -ForEach @( | ||
@{ Type = 'exactly'; Parameter = 'ShortCode'; Value = 'PSShlink-Test' } | ||
@{ Type = 'vaguely'; Parameter = 'SearchTerm'; Value = 'test' } | ||
) { | ||
$Params = @{ | ||
$Parameter = $Value | ||
ShlinkServer = $env:ShlinkServer | ||
ShlinkApiKey = $env:ShlinkAPIKey | ConvertTo-SecureString | ||
ErrorAction = 'Stop' | ||
} | ||
$Object = Get-ShlinkUrl @Params | ||
$Object.shortCode | Should -Be 'PSShlink-Test' | ||
$Object.shortUrl | Should -Be ('{0}/PSShlink-Test' -f $env:ShlinkServer) | ||
$Object.tags | Should -Be 'PSShlinkTag1', 'PSShlinkTag2' | ||
$Object.longUrl | Should -Be 'https://google.co.uk' | ||
} | ||
} |
Oops, something went wrong.