Skip to content

Commit

Permalink
Merge pull request #13 from samsmithnz/docsUpdate
Browse files Browse the repository at this point in the history
Docs update
  • Loading branch information
samsmithnz authored Oct 11, 2022
2 parents bdd0686 + ccfec4b commit f9c5f6b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ A GitHub Action to roughly calculate DORA lead time for changes This is not mean
[![Current Release](https://img.shields.io/github/release/samsmithnz/lead-time-for-changes/all.svg)](https://github.com/samsmithnz/lead-time-for-changes/releases)

## Current Calculation
- Get the last 100 closed Pull Requests
- For each Pull Request, if it was merged in the last 30 days, calculate the time the PR was open, taking the merge time and either the first or last commit time (specified as a parameter), aggregating for an overall PR duration average.
- For each workflow, if it started in the last 30 days and was run on the target branch, calculate the workflow run time, aggregating for an overall workflow duration average
- Add the Pull Request and workflow durations to output the lead time for changes result.
- Then translate this result to friendly n days/weeks/months.

## Current Limitations
- Only looks at the last 100 closed Pull Requests and 100 completed workflows. If number of Pull Requests and/or deployments to the target branch is low, this will skew the result.

## Open questions

Expand Down
3 changes: 1 addition & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ runs:
shell: pwsh
run: |
$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
Write-Output $result >> $env:GITHUB_STEP_SUMMARY
4 changes: 2 additions & 2 deletions src/leadtimeforchanges.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function Main ([string] $ownerRepo,

#Get pull requests from the repo
#https://developer.GitHub.com/v3/pulls/#list-pull-requests
$uri = "https://api.github.com/repos/$owner/$repo/pulls?state=all&head=$branch&per_page=100";
$uri = "https://api.github.com/repos/$owner/$repo/pulls?state=all&head=$branch&per_page=100&state=closed";
if (!$authHeader)
{
#No authentication
Expand All @@ -69,7 +69,7 @@ function Main ([string] $ownerRepo,
Foreach ($pr in $prsResponse){

$mergedAt = $pr.merged_at
if ($pr.state -eq "closed" -and $mergedAt -ne $null -and $pr.merged_at -gt (Get-Date).AddDays(-$numberOfDays))
if ($mergedAt -ne $null -and $pr.merged_at -gt (Get-Date).AddDays(-$numberOfDays))
{
$prCounter++
$url2 = "https://api.github.com/repos/$owner/$repo/pulls/$($pr.number)/commits?per_page=100";
Expand Down

0 comments on commit f9c5f6b

Please sign in to comment.