Skip to content

Commit

Permalink
Merge branch 'AtlassianPS:master' into feature/IssueHistory
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekTieGuy authored Aug 5, 2023
2 parents fcf8392 + 109dc34 commit be9fefb
Show file tree
Hide file tree
Showing 12 changed files with 442 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
[*.{md,yml,yaml}]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
7 changes: 5 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# https://help.github.com/articles/about-codeowners/
.github/workflows @atlassianps/ci-managers
JiraPS.build.ps1 @atlassianps/ci-managers
PPSScriptAnalyzerSettings.psd1 @atlassianps/ci-managers
Tools/ @atlassianps/ci-managers

* @atlassianps/maintainers @atlassianps/reviewers
* @atlassianps/maintainers
71 changes: 70 additions & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@ on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
build_module:
name: Build Module
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup PowerShell module cache
id: cacher
uses: actions/cache@v3
with:
path: "~/.local/share/powershell/Modules"
key: ${{ runner.os }}-PSModules
- name: Setup
shell: pwsh
run: |
Expand All @@ -20,7 +29,7 @@ jobs:
shell: pwsh
run: |
Invoke-Build -Task Clean, Build
- name: Upload
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: Release
Expand All @@ -37,6 +46,12 @@ jobs:
with:
name: Release
path: ./Release/
- name: Setup PowerShell module cache
id: cacher
uses: actions/cache@v3
with:
path: "~/.local/share/powershell/Modules"
key: ${{ runner.os }}-PSModules
- name: Setup
shell: powershell
run: |
Expand All @@ -46,6 +61,12 @@ jobs:
shell: powershell
run: |
Invoke-Build -Task Test
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-Unit-Tests
path: Test*.xml
if: ${{ always() }}

test_on_windows_v7:
name: Test Module on Windows (PS v7)
Expand All @@ -58,6 +79,12 @@ jobs:
with:
name: Release
path: ./Release/
- name: Setup PowerShell module cache
id: cacher
uses: actions/cache@v3
with:
path: "~/.local/share/powershell/Modules"
key: ${{ runner.os }}-PSModules
- name: Setup
shell: pwsh
run: |
Expand All @@ -67,6 +94,12 @@ jobs:
shell: pwsh
run: |
Invoke-Build -Task Test
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-Unit-Tests
path: Test*.xml
if: ${{ always() }}

test_on_ubuntu:
name: Test Module on Ubuntu
Expand All @@ -79,6 +112,12 @@ jobs:
with:
name: Release
path: ./Release/
- name: Setup PowerShell module cache
id: cacher
uses: actions/cache@v3
with:
path: "~/.local/share/powershell/Modules"
key: ${{ runner.os }}-PSModules
- name: Setup
shell: pwsh
run: |
Expand All @@ -88,6 +127,12 @@ jobs:
shell: pwsh
run: |
Invoke-Build -Task Test
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-Unit-Tests
path: Test*.xml
if: ${{ always() }}

test_on_macos:
name: Test Module on macOS
Expand All @@ -100,6 +145,12 @@ jobs:
with:
name: Release
path: ./Release/
- name: Setup PowerShell module cache
id: cacher
uses: actions/cache@v3
with:
path: "~/.local/share/powershell/Modules"
key: ${{ runner.os }}-PSModules
- name: Setup
shell: pwsh
run: |
Expand All @@ -109,6 +160,12 @@ jobs:
shell: pwsh
run: |
Invoke-Build -Task Test
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-Unit-Tests
path: Test*.xml
if: ${{ always() }}

test_against_cloud:
env:
Expand All @@ -125,6 +182,12 @@ jobs:
with:
name: Release
path: ./Release/
- name: Setup PowerShell module cache
id: cacher
uses: actions/cache@v3
with:
path: "~/.local/share/powershell/Modules"
key: ${{ runner.os }}-PSModules
- name: Setup
shell: pwsh
run: |
Expand All @@ -135,3 +198,9 @@ jobs:
run: |
Invoke-Build -Task Test -Tag "Integration" -ExcludeTag ""
if: ${{ env.JiraURI != '' }}
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-Unit-Tests
path: Test*.xml
if: ${{ always() }}
16 changes: 16 additions & 0 deletions .github/workflows/pr_review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Refine PRs

on:
pull_request:
types: [opened]

jobs:
label_issue:
runs-on: ubuntu-latest
steps:
- name: "Add default reviewers to PR"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: |
gh pr edit $PR_URL --add-reviewer @atlassianps/reviewers
66 changes: 66 additions & 0 deletions JiraPS/Public/Get-JiraIssueWorklog.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
function Get-JiraIssueWorklog {
# .ExternalHelp ..\JiraPS-help.xml
[CmdletBinding()]
param(
[Parameter( Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName )]
[ValidateNotNullOrEmpty()]
[ValidateScript(
{
if (("JiraPS.Issue" -notin $_.PSObject.TypeNames) -and (($_ -isnot [String]))) {
$exception = ([System.ArgumentException]"Invalid Type for Parameter") #fix code highlighting]
$errorId = 'ParameterType.NotJiraIssue'
$errorCategory = 'InvalidArgument'
$errorTarget = $_
$errorItem = New-Object -TypeName System.Management.Automation.ErrorRecord $exception, $errorId, $errorCategory, $errorTarget
$errorItem.ErrorDetails = "Wrong object type provided for Issue. Expected [JiraPS.Issue] or [String], but was $($_.GetType().Name)"
$PSCmdlet.ThrowTerminatingError($errorItem)
<#
#ToDo:CustomClass
Once we have custom classes, this check can be done with Type declaration
#>
}
else {
return $true
}
}
)]
[Alias('Key')]
[Object]
$Issue,

[Parameter()]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential = [System.Management.Automation.PSCredential]::Empty
)

begin {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"
}

process {
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] ParameterSetName: $($PsCmdlet.ParameterSetName)"
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"

# Find the proper object for the Issue
$issueObj = Resolve-JiraIssueObject -InputObject $Issue -Credential $Credential

$parameter = @{
URI = "{0}/worklog" -f $issueObj.RestURL
Method = "GET"
GetParameter = @{
maxResults = $PageSize
}
OutputType = "JiraWorklogItem"
Paging = $true
Credential = $Credential
}

Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
Invoke-JiraMethod @parameter
}

end {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete"
}
}
3 changes: 2 additions & 1 deletion JiraPS/Public/Invoke-JiraMethod.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ function Invoke-JiraMethod {
"JiraComment",
"JiraIssue",
"JiraUser",
"JiraVersion"
"JiraVersion",
"JiraWorklogItem"
)]
[String]
$OutputType,
Expand Down
4 changes: 2 additions & 2 deletions JiraPS/Public/New-JiraSession.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function New-JiraSession {
[CmdletBinding()]
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseShouldProcessForStateChangingFunctions', '')]
param(
[Parameter( Mandatory )]
[Parameter( )]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential,
Expand All @@ -29,8 +29,8 @@ function New-JiraSession {
Method = "GET"
Headers = $Headers
StoreSession = $true
Credential = $Credential
}
if ($Credential) { $parameter.Add('Credential',$Credential) }
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
$result = Invoke-JiraMethod @parameter

Expand Down
Loading

0 comments on commit be9fefb

Please sign in to comment.