From 3d1d7807513d762b710aee7129c61afeae228e35 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 10:22:13 +0000 Subject: [PATCH 01/21] Updated readme and output host --- README.md | 13 +++++++++++++ src/leadtimeforchanges.ps1 | 30 +++++++++++++----------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 9ffc2f1..9bd9710 100644 --- a/README.md +++ b/README.md @@ -89,3 +89,16 @@ Workflow average time duration 0.30224537037037 Rate limit consumption: 242 / 5000 Lead time for changes average over last 30 days, is 5.76 hours, with a DORA rating of 'Elite' ``` + +In the job summary, we show a badge with details: +> ![Lead time for changes](https://img.shields.io/badge/frequency-4.67%20times%20per%20week-green?logo=github&label=Lead%20time%20for%20changes) +> +> **Definition:** For the primary application or service, how often is it successfully deployed to production. +> +> **Results:** Deployment frequency is **4.67 times per week** with a **High** rating, over the last **30 days**. +> +> **Details**: +> - Repository: samsmithnz/deployment-frequency using main branch +> - Workflow(s) used: CI +> - Active days of deployment: 13 days +> --- \ No newline at end of file diff --git a/src/leadtimeforchanges.ps1 b/src/leadtimeforchanges.ps1 index 087b8cc..b8b0a99 100644 --- a/src/leadtimeforchanges.ps1 +++ b/src/leadtimeforchanges.ps1 @@ -30,17 +30,17 @@ function Main ([string] $ownerRepo, $ownerRepoArray = $ownerRepo -split '/' $owner = $ownerRepoArray[0] $repo = $ownerRepoArray[1] - Write-Output "Owner/Repo: $owner/$repo" $workflowsArray = $workflows -split ',' - Write-Output "Workflows: $($workflowsArray[0])" - Write-Output "Branch: $branch" $numberOfDays = $numberOfDays - Write-Output "Number of days: $numberOfDays" if ($commitCountingMethod -eq "") { $commitCountingMethod = "last" } - Write-Output "Commit counting method '$commitCountingMethod' being used" + Write-Host "Owner/Repo: $owner/$repo" + Write-Host "Number of days: $numberOfDays" + Write-Host "Workflows: $($workflowsArray[0])" + Write-Host "Branch: $branch" + Write-Host "Commit counting method '$commitCountingMethod' being used" #========================================== # Get authorization headers @@ -102,7 +102,7 @@ function Main ([string] $ownerRepo, { $prTimeDuration = New-TimeSpan –Start $startDate –End $mergedAt $totalPRHours += $prTimeDuration.TotalHours - #Write-Output "$($pr.number) time duration in hours: $($prTimeDuration.TotalHours)" + #Write-Host "$($pr.number) time duration in hours: $($prTimeDuration.TotalHours)" } } } @@ -131,17 +131,13 @@ function Main ([string] $ownerRepo, Foreach ($arrayItem in $workflowsArray){ if ($workflow.name -eq $arrayItem) { - #Write-Output "'$($workflow.name)' matched with $arrayItem" + #Write-Host "'$($workflow.name)' matched with $arrayItem" $result = $workflowIds.Add($workflow.id) if ($result -lt 0) { Write-Output "unexpected result" } } - else - { - #Write-Output "'$($workflow.name)' DID NOT match with $arrayItem" - } } } @@ -170,7 +166,7 @@ function Main ([string] $ownerRepo, #Count workflows that are completed, on the target branch, and were created within the day range we are looking at if ($run.head_branch -eq $branch -and $run.created_at -gt (Get-Date).AddDays(-$numberOfDays)) { - #Write-Output "Adding item with status $($run.status), branch $($run.head_branch), created at $($run.created_at), compared to $((Get-Date).AddDays(-$numberOfDays))" + #Write-Host "Adding item with status $($run.status), branch $($run.head_branch), created at $($run.created_at), compared to $((Get-Date).AddDays(-$numberOfDays))" $workflowCounter++ #calculate the workflow duration $workflowDuration = New-TimeSpan –Start $run.created_at –End $run.updated_at @@ -201,9 +197,9 @@ function Main ([string] $ownerRepo, } #Aggregate the PR and workflow processing times to calculate the average number of hours - Write-Output "PR average time duration $($totalPRHours / $prCounter)" + Write-Host "PR average time duration $($totalPRHours / $prCounter)" - Write-Output "Workflow average time duration $($totalAverageworkflowHours)" + Write-Host "Workflow average time duration $($totalAverageworkflowHours)" $leadTimeForChangesInHours = ($totalPRHours / $prCounter) + ($totalAverageworkflowHours) #========================================== @@ -217,7 +213,7 @@ function Main ([string] $ownerRepo, { $rateLimitResponse = Invoke-RestMethod -Uri $uri5 -ContentType application/json -Method Get -Headers @{Authorization=($authHeader["Authorization"])} -SkipHttpErrorCheck -StatusCodeVariable "HTTPStatus" } - Write-Output "Rate limit consumption: $($rateLimitResponse.rate.used) / $($rateLimitResponse.rate.limit)" + Write-Host "Rate limit consumption: $($rateLimitResponse.rate.used) / $($rateLimitResponse.rate.limit)" #========================================== #output result @@ -278,11 +274,11 @@ function Main ([string] $ownerRepo, } if ($leadTimeForChangesInHours -gt 0 -and $numberOfDays -gt 0) { - Write-Output "Lead time for changes average over last $numberOfDays days, is $displayMetric $displayUnit, with a DORA rating of '$rating'" + Write-Host "Lead time for changes average over last $numberOfDays days, is $displayMetric $displayUnit, with a DORA rating of '$rating'" } else { - Write-Output "Lead time for changes: no data to display for this workflow and time period" + Write-Host "Lead time for changes: no data to display for this workflow and time period" } } From cca0d9378dcb0f3f843e782f5f372ab95b9ad6e3 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 10:34:45 +0000 Subject: [PATCH 02/21] Initial markdown code added --- src/leadtimeforchanges.ps1 | 41 +++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/src/leadtimeforchanges.ps1 b/src/leadtimeforchanges.ps1 index b8b0a99..f23ad04 100644 --- a/src/leadtimeforchanges.ps1 +++ b/src/leadtimeforchanges.ps1 @@ -126,16 +126,20 @@ function Main ([string] $ownerRepo, #Extract workflow ids from the definitions, using the array of names. Number of Ids should == number of workflow names $workflowIds = [System.Collections.ArrayList]@() + $workflowNames = [System.Collections.ArrayList]@() Foreach ($workflow in $workflowsResponse.workflows){ Foreach ($arrayItem in $workflowsArray){ if ($workflow.name -eq $arrayItem) { - #Write-Host "'$($workflow.name)' matched with $arrayItem" - $result = $workflowIds.Add($workflow.id) - if ($result -lt 0) + #This looks odd: but assigning to a (throwaway) variable stops the index of the arraylist being output to the console. Using an arraylist over an array has advantages making this worth it for here + if (!$workflowIds.Contains($workflow.id)) { - Write-Output "unexpected result" + $result = $workflowIds.Add($workflow.id) + } + if (!$workflowNames.Contains($workflow.name)) + { + $result = $workflowNames.Add($workflow.name) } } } @@ -275,10 +279,13 @@ function Main ([string] $ownerRepo, if ($leadTimeForChangesInHours -gt 0 -and $numberOfDays -gt 0) { Write-Host "Lead time for changes average over last $numberOfDays days, is $displayMetric $displayUnit, with a DORA rating of '$rating'" + return Format-OutputMarkdown -workflowNames $workflowNames -displayMetric $displayMetric -displayUnit $displayUnit -repo $ownerRepo -branch $branch -numberOfDays $numberOfDays -color $color -rating $rating } else { - Write-Host "Lead time for changes: no data to display for this workflow and time period" + Write-Host "No lead time for changes to display for this workflow and time period" + return Format-NoOutputMarkdown -workflows $workflows -numberOfDays $numberOfDays + } } @@ -380,4 +387,28 @@ function Get-JwtToken([string] $appId, [string] $appInstallationId, [string] $ap return $tokenResponse.token } +# Format output for deployment frequency in markdown +function Format-OutputMarkdown([array] $workflowNames, [string] $rating, [string] $displayMetric, [string] $displayUnit, [string] $repo, [string] $branch, [string] $numberOfDays, [string] $numberOfUniqueDates, [string] $color) +{ + $encodedString = [uri]::EscapeUriString($displayMetric + " " + $displayUnit) + #double newline to start the line helps with formatting in GitHub logs + $markdown = "`n`n![Lead time for changes](https://img.shields.io/badge/frequency-" + $encodedString + "-" + $color + "?logo=github&label=Lead%20time%20for%20changes)`n" + + "**Definition:** For the primary application or service, how long does it take to go from code committed to code successfully running in production.`n" + + "**Results:** Lead time for changes is **$displayMetric $displayUnit** with a **$rating** rating, over the last **$numberOfDays days**.`n" + + "**Details**:`n" + + "- Repository: $repo using $branch branch`n" + + "- Workflow(s) used: $($workflowNames -join ", ")`n" + + "---" + return $markdown +} + +function Format-NoOutputMarkdown([string] $workflows, [string] $numberOfDays) +{ + #double newline to start the line helps with formatting in GitHub logs + $markdown = "`n`n![Lead time for changes](https://img.shields.io/badge/frequency-none-lightgrey?logo=github&label=Lead%20time%20for%20changes)`n`n" + + "No data to display for $ownerRepo over the last $numberOfDays days`n`n" + + "---" + return $markdown +} + main -ownerRepo $ownerRepo -workflows $workflows -branch $branch -numberOfDays $numberOfDays -commitCountingMethod $commitCountingMethod -patToken $patToken -actionsToken $actionsToken -appId $appId -appInstallationId $appInstallationId -appPrivateKey $appPrivateKey From 349a9bdb9699e44929f3b5e1636e63ad0a1da8a8 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 10:57:40 +0000 Subject: [PATCH 03/21] Adding action.yml code --- action.yml | 4 +++- src/leadtimeforchanges.ps1 | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index d4ad421..5999088 100644 --- a/action.yml +++ b/action.yml @@ -41,4 +41,6 @@ runs: - name: Run DORA lead time for changes shell: pwsh run: | - ${{ github.action_path }}/src/leadtimeforchanges.ps1 -ownerRepo "${{ inputs.owner-repo }}" -workflows "${{ inputs.workflows }}" -branch "${{ inputs.default-branch }}" -numberOfDays ${{ inputs.number-of-days }} -commitCountingMethod ${{ inputs.commit-counting-method }} -patToken "${{ inputs.pat-token }}" -actionsToken "${{ inputs.actions-token }}" -appId "${{ inputs.app-id }}" -appInstallationId "${{ inputs.app-install-id }}" -appPrivateKey "${{ inputs.app-private-key }}" + $result = ${{ github.action_path }}/src/leadtimeforchanges.ps1 -ownerRepo "${{ inputs.owner-repo }}" -workflows "${{ inputs.workflows }}" -branch "${{ inputs.default-branch }}" -numberOfDays ${{ inputs.number-of-days }} -commitCountingMethod ${{ inputs.commit-counting-method }} -patToken "${{ inputs.pat-token }}" -actionsToken "${{ inputs.actions-token }}" -appId "${{ inputs.app-id }}" -appInstallationId "${{ inputs.app-install-id }}" -appPrivateKey "${{ inputs.app-private-key }}" + #Write-Host "::set-output name=result::$result" + Write-Output $result >> $env:GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/src/leadtimeforchanges.ps1 b/src/leadtimeforchanges.ps1 index f23ad04..a7f9b00 100644 --- a/src/leadtimeforchanges.ps1 +++ b/src/leadtimeforchanges.ps1 @@ -279,12 +279,12 @@ function Main ([string] $ownerRepo, if ($leadTimeForChangesInHours -gt 0 -and $numberOfDays -gt 0) { Write-Host "Lead time for changes average over last $numberOfDays days, is $displayMetric $displayUnit, with a DORA rating of '$rating'" - return Format-OutputMarkdown -workflowNames $workflowNames -displayMetric $displayMetric -displayUnit $displayUnit -repo $ownerRepo -branch $branch -numberOfDays $numberOfDays -color $color -rating $rating + return GetFormattedMarkdown -workflowNames $workflowNames -displayMetric $displayMetric -displayUnit $displayUnit -repo $ownerRepo -branch $branch -numberOfDays $numberOfDays -color $color -rating $rating } else { Write-Host "No lead time for changes to display for this workflow and time period" - return Format-NoOutputMarkdown -workflows $workflows -numberOfDays $numberOfDays + return GetFormattedMarkdownForNoResult -workflows $workflows -numberOfDays $numberOfDays } } @@ -388,7 +388,7 @@ function Get-JwtToken([string] $appId, [string] $appInstallationId, [string] $ap } # Format output for deployment frequency in markdown -function Format-OutputMarkdown([array] $workflowNames, [string] $rating, [string] $displayMetric, [string] $displayUnit, [string] $repo, [string] $branch, [string] $numberOfDays, [string] $numberOfUniqueDates, [string] $color) +function GetFormattedMarkdown([array] $workflowNames, [string] $rating, [string] $displayMetric, [string] $displayUnit, [string] $repo, [string] $branch, [string] $numberOfDays, [string] $numberOfUniqueDates, [string] $color) { $encodedString = [uri]::EscapeUriString($displayMetric + " " + $displayUnit) #double newline to start the line helps with formatting in GitHub logs @@ -402,7 +402,7 @@ function Format-OutputMarkdown([array] $workflowNames, [string] $rating, [string return $markdown } -function Format-NoOutputMarkdown([string] $workflows, [string] $numberOfDays) +function GetFormattedMarkdownForNoResult([string] $workflows, [string] $numberOfDays) { #double newline to start the line helps with formatting in GitHub logs $markdown = "`n`n![Lead time for changes](https://img.shields.io/badge/frequency-none-lightgrey?logo=github&label=Lead%20time%20for%20changes)`n`n" + From 72748546aa42bae880face5495937900ebf62bcf Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 11:06:55 +0000 Subject: [PATCH 04/21] code gardening --- .github/workflows/workflow.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index bc17fa8..6767bbd 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -38,6 +38,8 @@ jobs: uses: actions/checkout@v3 with: ref: ${{ github.ref }} + + #basic tests - name: Test this repo uses: ./ # the ./ runs the action.yml in this repo with: @@ -56,6 +58,8 @@ jobs: owner-repo: 'samsmithnz/SamsFeatureFlags' commit-counting-method: 'first' pat-token: "${{ secrets.PATTOKEN }}" + + #authenication tests - name: Test elite repo, multiple workflows, with PAT Token uses: ./ with: From 4b0520625743ad12ca389f884cfe0cb29196baa9 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 12:13:38 +0000 Subject: [PATCH 05/21] Added missing colors --- src/leadtimeforchanges.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/leadtimeforchanges.ps1 b/src/leadtimeforchanges.ps1 index a7f9b00..55b464b 100644 --- a/src/leadtimeforchanges.ps1 +++ b/src/leadtimeforchanges.ps1 @@ -232,22 +232,27 @@ function Main ([string] $ownerRepo, if ($leadTimeForChangesInHours -le 0) { $rating = "None" + $color = "lightgrey" } elseif ($leadTimeForChangesInHours -ge $dailyDeployment) { $rating = "Elite" + $color = "green" } elseif ($leadTimeForChangesInHours -le $dailyDeployment -and $leadTimeForChangesInHours -ge $weeklyDeployment) { $rating = "High" + $color = "green" } elseif ($leadTimeForChangesInHours -le $weeklyDeployment -and $leadTimeForChangesInHours -ge $everySixMonthsDeployment) { $rating = "Medium" + $color = "yellow" } elseif ($leadTimeForChangesInHours -le $everySixMonthsDeployment) { $rating = "Low" + $color = "red" } #Calculate metric and unit @@ -285,7 +290,6 @@ function Main ([string] $ownerRepo, { Write-Host "No lead time for changes to display for this workflow and time period" return GetFormattedMarkdownForNoResult -workflows $workflows -numberOfDays $numberOfDays - } } From 141141eb9528d20657cc907f63c8cfda1649094f Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 12:23:58 +0000 Subject: [PATCH 06/21] code gardening --- src/leadtimeforchanges.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/leadtimeforchanges.ps1 b/src/leadtimeforchanges.ps1 index 55b464b..b1ee3e0 100644 --- a/src/leadtimeforchanges.ps1 +++ b/src/leadtimeforchanges.ps1 @@ -258,7 +258,7 @@ function Main ([string] $ownerRepo, #Calculate metric and unit if ($leadTimeForChangesInHours -gt $dailyDeployment) { - $displayMetric = [math]::Round($leadTimeForChangesInHours,2) + $displayMetric = [math]::Round($leadTimeForChangesInHours, 2) $displayUnit = "hours" } elseif ($leadTimeForChangesInHours -le $dailyDeployment -and $leadTimeForChangesInHours -ge $weeklyDeployment) @@ -268,17 +268,17 @@ function Main ([string] $ownerRepo, } elseif ($leadTimeForChangesInHours -lt $weeklyDeployment -and $leadTimeForChangesInHours -ge $monthlyDeployment) { - $displayMetric = [math]::Round($leadTimeForChangesInHours / 24,2) + $displayMetric = [math]::Round($leadTimeForChangesInHours / 24, 2) $displayUnit = "days" } elseif ($leadTimeForChangesInHours -lt $monthlyDeployment -and $leadTimeForChangesInHours -gt $yearlyDeployment) { - $displayMetric = [math]::Round($leadTimeForChangesInHours / 24 / 30,2) + $displayMetric = [math]::Round($leadTimeForChangesInHours / 24 / 30, 2) $displayUnit = "months" } elseif ($leadTimeForChangesInHours -le $yearlyDeployment) { - $displayMetric = [math]::Round($leadTimeForChangesInHours / 365,2) + $displayMetric = [math]::Round($leadTimeForChangesInHours / 365, 2) $displayUnit = "years" } if ($leadTimeForChangesInHours -gt 0 -and $numberOfDays -gt 0) From 49e797a10f41a07d3f2574370f0cea95fe042eeb Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 12:28:21 +0000 Subject: [PATCH 07/21] code gardening --- src/leadtimeforchanges.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/leadtimeforchanges.ps1 b/src/leadtimeforchanges.ps1 index b1ee3e0..73bb363 100644 --- a/src/leadtimeforchanges.ps1 +++ b/src/leadtimeforchanges.ps1 @@ -224,7 +224,7 @@ function Main ([string] $ownerRepo, $dailyDeployment = 1 $weeklyDeployment = 1 / 7 $monthlyDeployment = 1 / 30 - $everySixMonthsDeployment = 1 / (6 * 30) #//Every 6 months + $everySixMonthsDeployment = 1 / (6 * 30) #Every 6 months $yearlyDeployment = 1 / 365 #Calculate rating From f17ba807973ed74c6f8e95ae2024d1fe8e65794e Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 13:12:23 +0000 Subject: [PATCH 08/21] code gardening --- src/leadtimeforchanges.ps1 | 61 ++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/src/leadtimeforchanges.ps1 b/src/leadtimeforchanges.ps1 index 73bb363..96cb926 100644 --- a/src/leadtimeforchanges.ps1 +++ b/src/leadtimeforchanges.ps1 @@ -202,9 +202,9 @@ function Main ([string] $ownerRepo, #Aggregate the PR and workflow processing times to calculate the average number of hours Write-Host "PR average time duration $($totalPRHours / $prCounter)" - Write-Host "Workflow average time duration $($totalAverageworkflowHours)" $leadTimeForChangesInHours = ($totalPRHours / $prCounter) + ($totalAverageworkflowHours) + Write-Host "Lead time for changes in hours: $leadTimeForChangesInHours" #========================================== #Show current rate limit @@ -221,65 +221,56 @@ function Main ([string] $ownerRepo, #========================================== #output result - $dailyDeployment = 1 - $weeklyDeployment = 1 / 7 - $monthlyDeployment = 1 / 30 - $everySixMonthsDeployment = 1 / (6 * 30) #Every 6 months - $yearlyDeployment = 1 / 365 + $dailyDeployment = 24 + $weeklyDeployment = 24 * 7 + $monthlyDeployment = 24 * 30 + $everySixMonthsDeployment = 24 * 30 * 6 #Every 6 months + $leadTimeForChangesInHours = 24 + Write-Host "Lead time for changes in hours: $leadTimeForChangesInHours" + - #Calculate rating - $rating = "" + #Calculate rating, metric and unit if ($leadTimeForChangesInHours -le 0) { $rating = "None" $color = "lightgrey" + $displayMetric = 0 + $displayUnit = "hours" } - elseif ($leadTimeForChangesInHours -ge $dailyDeployment) + elseif ($leadTimeForChangesInHours -lt $dailyDeployment) { $rating = "Elite" $color = "green" - } - elseif ($leadTimeForChangesInHours -le $dailyDeployment -and $leadTimeForChangesInHours -ge $weeklyDeployment) - { - $rating = "High" - $color = "green" - } - elseif ($leadTimeForChangesInHours -le $weeklyDeployment -and $leadTimeForChangesInHours -ge $everySixMonthsDeployment) - { - $rating = "Medium" - $color = "yellow" - } - elseif ($leadTimeForChangesInHours -le $everySixMonthsDeployment) - { - $rating = "Low" - $color = "red" - } - - #Calculate metric and unit - if ($leadTimeForChangesInHours -gt $dailyDeployment) - { $displayMetric = [math]::Round($leadTimeForChangesInHours, 2) $displayUnit = "hours" } - elseif ($leadTimeForChangesInHours -le $dailyDeployment -and $leadTimeForChangesInHours -ge $weeklyDeployment) + elseif ($leadTimeForChangesInHours -ge $dailyDeployment -and $leadTimeForChangesInHours -le $weeklyDeployment) { + $rating = "Elite" + $color = "green" $displayMetric = [math]::Round($leadTimeForChangesInHours / 24, 2) $displayUnit = "days" } - elseif ($leadTimeForChangesInHours -lt $weeklyDeployment -and $leadTimeForChangesInHours -ge $monthlyDeployment) + elseif ($leadTimeForChangesInHours -gt $weeklyDeployment -and $leadTimeForChangesInHours -le $monthlyDeployment) { + $rating = "High" + $color = "green" $displayMetric = [math]::Round($leadTimeForChangesInHours / 24, 2) $displayUnit = "days" } - elseif ($leadTimeForChangesInHours -lt $monthlyDeployment -and $leadTimeForChangesInHours -gt $yearlyDeployment) + elseif ($leadTimeForChangesInHours -gt $monthlyDeployment -and $leadTimeForChangesInHours -le $everySixMonthsDeployment) { + $rating = "Medium" + $color = "yellow" $displayMetric = [math]::Round($leadTimeForChangesInHours / 24 / 30, 2) $displayUnit = "months" } - elseif ($leadTimeForChangesInHours -le $yearlyDeployment) + elseif ($leadTimeForChangesInHours -gt $everySixMonthsDeployment) { - $displayMetric = [math]::Round($leadTimeForChangesInHours / 365, 2) - $displayUnit = "years" + $rating = "Low" + $color = "red" + $displayMetric = [math]::Round($leadTimeForChangesInHours / 24 / 30, 2) + $displayUnit = "months" } if ($leadTimeForChangesInHours -gt 0 -and $numberOfDays -gt 0) { From 59672c105d659d5ab8a5484712bcb79e4aee83b7 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 13:15:46 +0000 Subject: [PATCH 09/21] refined formula to be more accurate --- src/leadtimeforchanges.ps1 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/leadtimeforchanges.ps1 b/src/leadtimeforchanges.ps1 index 96cb926..ba3d56a 100644 --- a/src/leadtimeforchanges.ps1 +++ b/src/leadtimeforchanges.ps1 @@ -225,9 +225,6 @@ function Main ([string] $ownerRepo, $weeklyDeployment = 24 * 7 $monthlyDeployment = 24 * 30 $everySixMonthsDeployment = 24 * 30 * 6 #Every 6 months - $leadTimeForChangesInHours = 24 - Write-Host "Lead time for changes in hours: $leadTimeForChangesInHours" - #Calculate rating, metric and unit if ($leadTimeForChangesInHours -le 0) @@ -237,16 +234,16 @@ function Main ([string] $ownerRepo, $displayMetric = 0 $displayUnit = "hours" } - elseif ($leadTimeForChangesInHours -lt $dailyDeployment) + elseif ($leadTimeForChangesInHours -le $dailyDeployment) { $rating = "Elite" $color = "green" $displayMetric = [math]::Round($leadTimeForChangesInHours, 2) $displayUnit = "hours" } - elseif ($leadTimeForChangesInHours -ge $dailyDeployment -and $leadTimeForChangesInHours -le $weeklyDeployment) + elseif ($leadTimeForChangesInHours -gt $dailyDeployment -and $leadTimeForChangesInHours -le $weeklyDeployment) { - $rating = "Elite" + $rating = "High" $color = "green" $displayMetric = [math]::Round($leadTimeForChangesInHours / 24, 2) $displayUnit = "days" From 867906c0aa5d9f643a578aeee792a998a141e3b3 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 13:17:34 +0000 Subject: [PATCH 10/21] added minutes! --- src/leadtimeforchanges.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/leadtimeforchanges.ps1 b/src/leadtimeforchanges.ps1 index ba3d56a..d486032 100644 --- a/src/leadtimeforchanges.ps1 +++ b/src/leadtimeforchanges.ps1 @@ -234,6 +234,13 @@ function Main ([string] $ownerRepo, $displayMetric = 0 $displayUnit = "hours" } + elseif ($leadTimeForChangesInHours -lt 1) + { + $rating = "Elite" + $color = "green" + $displayMetric = [math]::Round($leadTimeForChangesInHours * 60, 2) + $displayUnit = "minutes" + } elseif ($leadTimeForChangesInHours -le $dailyDeployment) { $rating = "Elite" From fb5312f1fb1bd0d155bacd40a54a9fa706836ce9 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 13:19:35 +0000 Subject: [PATCH 11/21] updated readme --- README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9bd9710..ee663b1 100644 --- a/README.md +++ b/README.md @@ -91,14 +91,21 @@ Lead time for changes average over last 30 days, is 5.76 hours, with a DORA rati ``` In the job summary, we show a badge with details: -> ![Lead time for changes](https://img.shields.io/badge/frequency-4.67%20times%20per%20week-green?logo=github&label=Lead%20time%20for%20changes) +> ![Lead time for changes](https://img.shields.io/badge/frequency-5.61%20hours-green?logo=github&label=Lead%20time%20for%20changes) > -> **Definition:** For the primary application or service, how often is it successfully deployed to production. +> **Definition:** For the primary application or service, how long does it take to go from code committed to code successfully running in production. > -> **Results:** Deployment frequency is **4.67 times per week** with a **High** rating, over the last **30 days**. +> **Results:** Lead time for changes is **5.61 hours** with a **Elite** rating, over the last **30 days**. > > **Details**: > - Repository: samsmithnz/deployment-frequency using main branch > - Workflow(s) used: CI -> - Active days of deployment: 13 days -> --- \ No newline at end of file +> --- + + +![Lead time for changes](https://img.shields.io/badge/frequency-5.61%20hours-green?logo=github&label=Lead%20time%20for%20changes) +**Definition:** For the primary application or service, how long does it take to go from code committed to code successfully running in production. +**Results:** Lead time for changes is **5.61 hours** with a **Elite** rating, over the last **30 days**. +**Details**: +- Repository: samsmithnz/SamsFeatureFlags using main branch +- Workflow(s) used: Feature Flags CI/CD \ No newline at end of file From d4e78fea5ef19c67bcbf110009bf23d02ba6f92d Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 13:23:10 +0000 Subject: [PATCH 12/21] fixed readme --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index ee663b1..43f36c5 100644 --- a/README.md +++ b/README.md @@ -101,11 +101,3 @@ In the job summary, we show a badge with details: > - Repository: samsmithnz/deployment-frequency using main branch > - Workflow(s) used: CI > --- - - -![Lead time for changes](https://img.shields.io/badge/frequency-5.61%20hours-green?logo=github&label=Lead%20time%20for%20changes) -**Definition:** For the primary application or service, how long does it take to go from code committed to code successfully running in production. -**Results:** Lead time for changes is **5.61 hours** with a **Elite** rating, over the last **30 days**. -**Details**: -- Repository: samsmithnz/SamsFeatureFlags using main branch -- Workflow(s) used: Feature Flags CI/CD \ No newline at end of file From a659e5659b4880b9ba7e2cea8949ee65f9f9f742 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 13:23:47 +0000 Subject: [PATCH 13/21] updated readme --- README.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 43f36c5..b189c28 100644 --- a/README.md +++ b/README.md @@ -91,13 +91,11 @@ Lead time for changes average over last 30 days, is 5.76 hours, with a DORA rati ``` In the job summary, we show a badge with details: -> ![Lead time for changes](https://img.shields.io/badge/frequency-5.61%20hours-green?logo=github&label=Lead%20time%20for%20changes) -> -> **Definition:** For the primary application or service, how long does it take to go from code committed to code successfully running in production. -> -> **Results:** Lead time for changes is **5.61 hours** with a **Elite** rating, over the last **30 days**. -> -> **Details**: -> - Repository: samsmithnz/deployment-frequency using main branch -> - Workflow(s) used: CI -> --- + ![Lead time for changes](https://img.shields.io/badge/frequency-5.61%20hours-green?logo=github&label=Lead%20time%20for%20changes) + + **Definition:** For the primary application or service, how long does it take to go from code committed to code successfully running in production. + **Results:** Lead time for changes is **5.61 hours** with a **Elite** rating, over the last **30 days**. + **Details**: + - Repository: samsmithnz/deployment-frequency using main branch + - Workflow(s) used: CI + --- From 50e8398db92d3434fcd11f259d067ec38ff40981 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 13:24:11 +0000 Subject: [PATCH 14/21] updated readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b189c28..41efb11 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ Lead time for changes average over last 30 days, is 5.76 hours, with a DORA rati ``` In the job summary, we show a badge with details: + ![Lead time for changes](https://img.shields.io/badge/frequency-5.61%20hours-green?logo=github&label=Lead%20time%20for%20changes) **Definition:** For the primary application or service, how long does it take to go from code committed to code successfully running in production. From 9e219ab36751369fed96880c20bff352218196ff Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 13:24:29 +0000 Subject: [PATCH 15/21] updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 41efb11..aae8bc0 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Lead time for changes average over last 30 days, is 5.76 hours, with a DORA rati ``` In the job summary, we show a badge with details: - + --- ![Lead time for changes](https://img.shields.io/badge/frequency-5.61%20hours-green?logo=github&label=Lead%20time%20for%20changes) **Definition:** For the primary application or service, how long does it take to go from code committed to code successfully running in production. From 13aeb86d1ec2b27c5549377609d8bfe86cfda7d1 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 13:25:15 +0000 Subject: [PATCH 16/21] updated readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index aae8bc0..1b5d3f9 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,9 @@ In the job summary, we show a badge with details: ![Lead time for changes](https://img.shields.io/badge/frequency-5.61%20hours-green?logo=github&label=Lead%20time%20for%20changes) **Definition:** For the primary application or service, how long does it take to go from code committed to code successfully running in production. + **Results:** Lead time for changes is **5.61 hours** with a **Elite** rating, over the last **30 days**. + **Details**: - Repository: samsmithnz/deployment-frequency using main branch - Workflow(s) used: CI From f5ab11c1df032a3d3ec51bfd74af439398ed8eb0 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 13:25:44 +0000 Subject: [PATCH 17/21] updated readme --- README.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1b5d3f9..e649efe 100644 --- a/README.md +++ b/README.md @@ -92,12 +92,9 @@ Lead time for changes average over last 30 days, is 5.76 hours, with a DORA rati In the job summary, we show a badge with details: --- - ![Lead time for changes](https://img.shields.io/badge/frequency-5.61%20hours-green?logo=github&label=Lead%20time%20for%20changes) - - **Definition:** For the primary application or service, how long does it take to go from code committed to code successfully running in production. - - **Results:** Lead time for changes is **5.61 hours** with a **Elite** rating, over the last **30 days**. - + ![Lead time for changes](https://img.shields.io/badge/frequency-5.61%20hours-green?logo=github&label=Lead%20time%20for%20changes)
+ **Definition:** For the primary application or service, how long does it take to go from code committed to code successfully running in production.
+ **Results:** Lead time for changes is **5.61 hours** with a **Elite** rating, over the last **30 days**.
**Details**: - Repository: samsmithnz/deployment-frequency using main branch - Workflow(s) used: CI From b1f6b9a946051571a6f3663fd50681b6b6a03d7e Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 13:26:23 +0000 Subject: [PATCH 18/21] updated version --- GitVersion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GitVersion.yml b/GitVersion.yml index 45f155b..4c817b9 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1 +1 @@ -next-version: 0.9.0 +next-version: 1.0.0 From 8a64a0a09c6b58f9a96bc1457d73891310808be9 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 13:31:33 +0000 Subject: [PATCH 19/21] code gardening --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e649efe..febab49 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ Lead time for changes average over last 30 days, is 5.76 hours, with a DORA rati ``` In the job summary, we show a badge with details: + --- ![Lead time for changes](https://img.shields.io/badge/frequency-5.61%20hours-green?logo=github&label=Lead%20time%20for%20changes)
**Definition:** For the primary application or service, how long does it take to go from code committed to code successfully running in production.
From f31f8e8134779ca076aaa55b03827030987fd2ed Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 13:33:27 +0000 Subject: [PATCH 20/21] updated image for test --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 6767bbd..792dd6d 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -9,7 +9,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 outputs: # https://stackoverflow.com/questions/59175332/using-output-from-a-previous-job-in-a-new-one-in-a-github-action Version: ${{ steps.gitversion.outputs.SemVer }} CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }} From 274974cf26932546ad095f4c7e38c4e027b1fd45 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Mon, 10 Oct 2022 13:35:37 +0000 Subject: [PATCH 21/21] updated runner image --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 792dd6d..6767bbd 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -9,7 +9,7 @@ on: jobs: build: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest outputs: # https://stackoverflow.com/questions/59175332/using-output-from-a-previous-job-in-a-new-one-in-a-github-action Version: ${{ steps.gitversion.outputs.SemVer }} CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}