chore(deps): update dependency coverlet.collector to v8 #102
Workflow file for this run
This file contains hidden or 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
| name: Jira | |
| on: | |
| pull_request: | |
| paths-ignore: ["*.md"] | |
| # Needed to trigger branch policies on merge queues (not considered pull requests) | |
| push: | |
| branches: | |
| - 'gh-readonly-queue/**' | |
| paths-ignore: ["*.md"] | |
| workflow_call: | |
| inputs: | |
| branch_name: | |
| description: 'The branch name to use for Jira (defaults to the triggering branch)' | |
| type: string | |
| required: false | |
| default: ${{ github.head_ref || github.ref_name }} | |
| is_CI: | |
| description: 'Whether the workflow runs in a test mode (skips certain steps)' | |
| type: boolean | |
| required: false | |
| default: false | |
| jobs: | |
| main: | |
| runs-on: [idp] | |
| permissions: | |
| id-token: write | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - id: get_client_id | |
| env: | |
| INFRA_CONFIG: ${{ vars.INFRA_CONFIG }} | |
| AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }} | |
| shell: pwsh | |
| run: | | |
| if ($env:AZURE_CLIENT_ID) { | |
| $ClientId = $env:AZURE_CLIENT_ID | |
| } elseif ($env:INFRA_CONFIG) { | |
| $ClientId = (ConvertFrom-Json $env:INFRA_CONFIG).repo_identity_client_id | |
| } else { | |
| Write-Error "Neither AZURE_CLIENT_ID nor INFRA_CONFIG is set. Cannot determine client id." | |
| exit 1 | |
| } | |
| echo "client_id=$ClientId" | |
| "client_id=$ClientId" >> $env:GITHUB_OUTPUT | |
| - name: Get JiraApiToken secret | |
| id: get_jira_api_secret | |
| uses: workleap/wl-reusable-workflows/retrieve-managed-secret@main | |
| with: | |
| azure-client-id: ${{ steps.get_client_id.outputs.client_id }} | |
| azure-tenant-id: ${{ vars.AZURE_TENANT_ID }} | |
| azure-subscription-id: ${{ vars.WORKLEAP_GLOBAL_KEYVAULT_SUBSCRIPTION_ID }} | |
| keyvault-name: ${{ vars.WORKLEAP_GLOBAL_KEYVAULT_NAME }} | |
| secret-name: "JiraApiToken" | |
| - name: Get JiraUsername secret | |
| id: get_jira_username_secret | |
| uses: workleap/wl-reusable-workflows/retrieve-managed-secret@main | |
| with: | |
| azure-client-id: ${{ steps.get_client_id.outputs.client_id }} | |
| azure-tenant-id: ${{ vars.AZURE_TENANT_ID }} | |
| azure-subscription-id: ${{ vars.WORKLEAP_GLOBAL_KEYVAULT_SUBSCRIPTION_ID }} | |
| keyvault-name: ${{ vars.WORKLEAP_GLOBAL_KEYVAULT_NAME }} | |
| secret-name: "JiraUsername" | |
| - name: Get branch name | |
| id: branch_name | |
| shell: pwsh | |
| run: | | |
| $BranchName = "${{ inputs.branch_name || github.head_ref || github.ref_name }}" | |
| Write-Host "Branch name: $BranchName" | |
| "branch_name=$BranchName" >> $env:GITHUB_OUTPUT | |
| - name: Extract Jira Issue | |
| id: extract_jira | |
| uses: workleap/wl-reusable-workflows/extract-jira-issue@main | |
| with: | |
| branch_name: ${{ steps.branch_name.outputs.branch_name }} | |
| - name: Check Jira Story | |
| id: check_jira | |
| shell: pwsh | |
| env: | |
| BranchName: "${{steps.branch_name.outputs.branch_name}}" | |
| BranchPattern: "${{steps.extract_jira.outputs.pattern}}" | |
| JiraMatches: "${{steps.extract_jira.outputs.matches}}" | |
| JiraIssueKeys: "${{steps.extract_jira.outputs.jira_issue_matches}}" | |
| run: | | |
| # Check if JiraPS module is already available | |
| $jiraPSModule = Get-Module -ListAvailable -Name JiraPS | |
| if ($jiraPSModule) { | |
| Write-Host "JiraPS module is already installed (version: $($jiraPSModule.Version))." | |
| } else { | |
| Write-Host "JiraPS module not found. Installing..." | |
| $maxRetries = 3 | |
| for ($attempt = 1; $attempt -le $maxRetries; $attempt++) { | |
| Write-Host "Installing JiraPS module (attempt $attempt of $maxRetries)..." | |
| try { | |
| Install-Module JiraPS -Scope CurrentUser -Force -ErrorAction Stop | |
| Write-Host "JiraPS module installed successfully." | |
| break | |
| } catch { | |
| $errorMessage = $_.Exception.Message | |
| Write-Warning "JiraPS installation failed (attempt $attempt): $errorMessage" | |
| if ($attempt -lt $maxRetries) { | |
| Write-Host "Retrying in 5 seconds..." | |
| Start-Sleep -Seconds 5 | |
| } else { | |
| # Add GitHub error annotation | |
| Write-Host "::error title=JiraPS Installation Failed::Failed to install JiraPS module after $maxRetries attempts. This is likely a transient error with PowerShell Gallery. Please re-run the workflow to retry." | |
| # Add Job Summary | |
| $jobSummary = "## ⚠️ JiraPS Module Installation Failed`n`n" | |
| $jobSummary += "The JiraPS PowerShell module failed to install after $maxRetries attempts.`n`n" | |
| $jobSummary += "**This is likely a transient error** caused by temporary issues with:`n" | |
| $jobSummary += "- PowerShell Gallery network connectivity`n" | |
| $jobSummary += "- Module repository availability`n" | |
| $jobSummary += "- Authentication or rate limiting`n`n" | |
| $jobSummary += "### Recommended Action`n" | |
| $jobSummary += "**Re-run this workflow** to retry the installation. The issue typically resolves itself on subsequent attempts.`n`n" | |
| $jobSummary += "### Error Details`n" | |
| $jobSummary += '```text' + "`n" | |
| $jobSummary += "$errorMessage`n" | |
| $jobSummary += '```' + "`n" | |
| $jobSummary | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append | |
| throw "Failed to install JiraPS module after $maxRetries attempts. Please re-run the workflow to retry." | |
| } | |
| } | |
| } | |
| } | |
| if ("$env:BranchName" -like "*renovate/*" -eq $True) | |
| { | |
| Write-Host "Skipping, renovate branch detected" | |
| return | |
| } | |
| if ("$env:BranchName" -like "copilot/*" -eq $True) | |
| { | |
| Write-Host "Skipping, copilot branch detected" | |
| return | |
| } | |
| if ("$env:BranchName" -like "claude/*" -eq $True) | |
| { | |
| Write-Host "Skipping, claude branch detected" | |
| return | |
| } | |
| if ("$env:BranchName" -like "gh-readonly-queue/*" -eq $True) | |
| { | |
| Write-Host "Skipping, GitHub merge queue branch detected" | |
| return | |
| } | |
| Set-JiraConfigServer -Server "${{ vars.JIRA_URL }}" | |
| if("$env:JiraMatches" -eq "false") | |
| { | |
| throw "Branch name '$env:BranchName' doesn't respect the required pattern $env:BranchPattern. A valid branch name example would be: feature/PRJ-123" | |
| } | |
| $PWord = ConvertTo-SecureString -String "${{ steps.get_jira_api_secret.outputs.secret }}" -AsPlainText -Force | |
| $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "${{ steps.get_jira_username_secret.outputs.secret }}", $PWord | |
| $issueKeys = $env:JiraIssueKeys | ConvertFrom-Json | |
| $found = $false | |
| foreach ($key in $issueKeys) { | |
| $key = $key.Trim() | |
| Write-Host "Retrieving Jira issue with number $key" | |
| try { | |
| Get-JiraIssue -Key $key -Credential $Credential -ErrorAction Stop | out-null | |
| Write-Host "Successfully retrieved Jira issue $key" | |
| $found = $true | |
| "jira_issue=$key" >> $env:GITHUB_OUTPUT | |
| break | |
| } | |
| catch { | |
| Write-Host "Failed to retrieve Jira issue $key : $_" | |
| } | |
| } | |
| if (-not $found) { | |
| throw "No valid Jira issue found for any of the keys: $env:JiraIssueKeys" | |
| } | |
| - name: Add Jira issue link | |
| shell: pwsh | |
| env: | |
| BranchName: "${{ steps.branch_name.outputs.branch_name }}" | |
| BranchPattern: "${{ steps.extract_jira.outputs.pattern }}" | |
| JiraMatches: "${{ steps.extract_jira.outputs.matches }}" | |
| JiraIssue: "${{ steps.check_jira.outputs.jira_issue }}" | |
| run: | | |
| # We don't want the Jira link to come from the test workflow since we're using a fixed branch name | |
| if ("${{ inputs.is_CI }}" -eq $true) { | |
| Write-Host 'Running in test mode, skipping adding Jira link to pull request description.' | |
| exit 0 | |
| } | |
| if (-not "${{ github.event.pull_request.number }}") { | |
| Write-Host 'No pull request context. Skipping adding Jira link to pull request description.' | |
| exit 0 | |
| } | |
| Write-Host 'Adding JIRA link to pull request description' | |
| $repo = "${{ github.repository }}" | |
| $prNumber = "${{ github.event.pull_request.number }}" | |
| # Not all valid branch names will match the pattern (e.g. renovate branches) | |
| if("$env:JiraMatches" -eq "true") { | |
| $jiraLinkUrl = "https://workleap.atlassian.net/browse/$env:JiraIssue" | |
| $jiraLinkDescription = "Jira issue link: [$env:JiraIssue]($jiraLinkUrl)" | |
| $token = "${{ github.token }}" | |
| $headers = @{ | |
| Authorization = "Bearer $token" | |
| "Accept" = "application/vnd.github.v3+json" | |
| } | |
| $prUrl = "https://api.github.com/repos/$repo/pulls/$prNumber" | |
| $pr = Invoke-RestMethod -Uri $prUrl -Headers $headers | |
| if ($null -ne $pr.body -and ($pr.body -match "$jiraLinkUrl")) { | |
| $newBody = $pr.body | |
| } else { | |
| $newBody = "$jiraLinkDescription`n`n$($pr.body)" | |
| } | |
| if ($newBody -ne $pr.body) { | |
| $body = @{ body = $newBody } | ConvertTo-Json | |
| Invoke-RestMethod -Uri $prUrl -Headers $headers -Method Patch -Body $body | |
| Write-Host 'Successfully added JIRA link to pull request description' | |
| } else { | |
| Write-Host 'JIRA link already present in pull request description' | |
| } | |
| } else { | |
| Write-Host "Branch name '$env:BranchName' does not match the Jira pattern $env:BranchPattern. Skipping JIRA link insertion." | |
| } |