1.1.4 • Published 12 months ago

forke v1.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Forke

Forke is a simple CLI tool designed to measure development productivity from GitHub info.

Install

# Install
npm install -g forke

# This npm requires GITHUB_TOKEN, so please set it in the environment variable in any way.
export GITHUB_TOKEN='...'

Concepts

This tool is designed to measure Four Keys, a development productivity indicator.

Measuring the Four Keys is not enough; it is important to link the results of the measurement to improvements. For this reason, a stat command is provided to retrieve the indicators and a list command to output the original data of the indicators. The user of the tool is expected to see from the results of the list command which work of the development team is the bottleneck when each indicator is bad.

Lead time for changes & Deployment frequency

[BaseBranch]                                                    to LeadTimeBranch |  to DeployBranch |
|---------------------------------- lead time ------------------------------------|--   No Stat    --|
|-- timeFromCommitToOpen --|-- timeFromOpenToReview --|-- timeFromReviewToMerge --|------------------|
------------------------------------------------------------------------------------------------------
^                          ^                          ^                           ^                  ^
first commit        create PullRequest            first review              merge PullRequest       release
  • Deployment frequency = Number of PullRequests targeting DeployBranch
  • Lead time for changes = timeFromCommitToOpen + timeFromOpenToReview + timeFromReviewToMerge.
    • As shown in the figure, the time between the merge and the deployment is not captured by Forke.
    • As the deployment process is heavily influenced by the business side, I have decided that it is not possible to drill down from the GitHub data and have used this specification, but I may make it possible to obtain this information in the future.

Change failure rate & Time to restore service

  • Change failure rate = (Number of PullRequests targeting LeadTimeBranch and head is hotfixBranch) / (Number of PullRequests targeting LeadTimeBranch)
  • Time to restore service = Average(Lead time of PullRequests targeting LeadTimeBranch and head is hotfixBranch)
    • The Lead   time calculation method is the same as for calculating lead time for changes.

Usage

List PullRequests

List merged pull requests that match the search conditions are output to standard output.

npx forke list --query ...

Result

NameDescription
titleThe title of the pull request.
urlThe URL of the pull request.
repositoryThe repository's owner and name, separated by a slash (ex: IkumaTadokoro/Forke).
authorPull Request's author name.
baseRefNameThe name of the base branch for the pull request.
headRefNameThe name of the head branch for the pull request.
labelsThe labels array associated with the pull request.
isDraftWhether the pull request is a draft or not.
isReadByViewerWhether the pull request has been read by the viewer.
isForcePushedWhether the pull request has been force pushed.
stateThe state of the pull request ("OPEN", "MERGED", "CLOSED").
additionsThe number of lines added in the pull request.
deletionsThe number of lines deleted in the pull request.
changedFileCountThe number of files changed in the pull request.
firstCommitUrlThe url of the first commit associated with the pull request; if it has been force pushed, it refers to the commit before it was force pushed, not the first commit currently associated with it.
firstCommitAuthoredDateThe authored date of the first commit associated with the pull request.
firstCommitCommittedDateThe committed date of the first commit associated with the pull request.
firstReviewedAtTime the pull request was first reviewed.
reviewersReviewer names (Array).
totalCommentsCountThe total number of comments on the pull request.
createdAtThe creation date of the pull request.
updatedAtThe last update date of the pull request.
publishedAtThe publication date of the pull request.
closedAtThe date when the pull request was closed.
mergedAtThe date when the pull request was merged.
timeFromCommitToOpenThe lead time between firstCommitAuthoredDate and pullRequest createdAt. The units are those specified in the timeunit option.
timeFromOpenToReviewThe lead time between pullRequest createdAt and firstReviewedAt. The units are those specified in the timeunit option.
timeFromReviewToMergeThe lead time between firstReviewedAt and pullRequest mergedAt. The units are those specified in the timeunit option.
leadTimeTotal of timeFromCommitToOpen, timeFromOpenToReview and timeFromReviewToMerge.

Options

The following options can be specified.

# ex)
npx forke list -f 2023-04-01T00:00:00+09:00 -q 'base:main base:release' --format json --timeunit hour
LongAliasChoicesDefaultDescription
fromf(any string)*Starting point of the PullRequest search condition(mergedAt).
tot(any string)*End point of the PullRequest search condition(mergedAt)
queryq(any string)-Search query. Internally is:pr is:merged merged:{from}..{to} is specified, this option allows additional refinement criteria to be specified.  See here for options that can be specified.
timezone-UTC, Asia/TokyoAsia/TokyoSpecifies in which time zone the acquisition results are displayed.
format-csv, csv-no-header, jsoncsvResult format.
timeunit-minute, hour, secondminuteUnit for calculating lead time.
orderoasc, decascAscending or descending result order of MergedAt.

Create Stats

Output statistics from pull requests that match the specified conditions.

npx forke stat --query ...

Result

NameDescription
fromStarting period of the measurement; value specified in the from option.
toEnd period of the measurement, the value specified in the to option.
deployCountThe number of pull requests for the deploy target branch.
leadTimeTargetCountThe number of pull requests for the lead time target branch.
hotfixCountThe number of pull requests for the hotfix target branch.
totalAdditionsThe total number of lines added across all pull requests.
averageAdditionsThe average number of lines added per pull request.
medianAdditionsThe median number of lines added per pull request.
totalDeletionsThe total number of lines deleted across all pull requests.
averageDeletionsThe average number of lines deleted per pull request.
medianDeletionsThe median number of lines deleted per pull request.
totalDiffsThe total number of line differences (additions and deletions) across all pull requests.
averageDiffsThe average number of line differences (additions and deletions) per pull request.
totalChangedFilesThe total number of files changed across all pull requests.
averageChangedFilesThe average number of files changed per pull request.
medianChangedFilesThe median number of files changed per pull request.
totalCommentsThe total number of comments across all pull requests.
averageCommentsThe average number of comments per pull request.
medianCommentsThe median number of comments per pull request.
totalLeadTimeThe total lead time across all pull requests.
averageLeadTimeThe average lead time per pull request.
medianLeadTimeThe median lead time per pull request.
totalTimeFromCommitToOpenThe total time from commit to open across all pull requests.
averageTimeFromCommitToOpenThe average time from commit to open per pull request.
medianTimeFromCommitToOpenThe median time from commit to open per pull request.
totalTimeFromOpenToReviewThe total time from open to review across all pull requests.
averageTimeFromOpenToReviewThe average time from open to review per pull request.
medianTimeFromOpenToReviewThe median time from open to review per pull request.
totalTimeFromReviewToMergeThe total time from review to merge across all pull requests.
averageTimeFromReviewToMergeThe average time from review to merge per pull request.
medianTimeFromReviewToMergeThe median time from review to merge per pull request.
changeFailureRateThe ratio of hotfix pull requests to lead time target branch pull requests.
meanTimeToRepairThe average lead time for hotfix pull requests.

Options

The following options can be specified.

# ex)
npx forke stat -f 2023-04-01T00:00:00+09:00 -q 'base:main base:release' --format json --timeunit hour --deployBranch release
LongAliasChoicesDefaultDescription
fromf(any string)*Starting point of the PullRequest search condition(mergedAt).
tot(any string)*End point of the PullRequest search condition(mergedAt).
queryq(any string)-Search query. Internally is:pr is:merged merged:{from}..{to} is specified, this option allows additional refinement criteria to be specified. See here for options that can be specified.
timezone-UTC, Asia/TokyoAsia/TokyoSpecifies in which time zone the acquisition results are displayed.
format-csv, csv-no-header, jsoncsvResult format.
timeunit-minute, hour, secondminuteUnit for calculating lead time.
deployBranch-RegExp^(main \| master)$Target branch name for deploy.
leadTimeBranch-RegExp^(main \| master)$Target branch name for lead time.
hotfixBranch-RegExphotfixTarget branch name for hotfix.

Contribution

Issues

The following Issue is accepted (English or Japanese).

  • Questions about features
  • Report errors or problems
  • Propose additions or improvements to feature

Please click here to issue.

How to send Pull Request

  1. Fork the repository
  2. Create a branch
  3. Add or modify feature
  4. Run unit test
  5. Check the feature in your terminal
  6. Commit Changes
  7. Push branch
  8. Create Pull Request

How to set up a Local Development Environment

First, clone the forked repository locally.

git clone git@github.com:IkumaTadokoro/forke.git

Install dependencies.

npm i

(Option) Setup envfile for debug. When the configuration is complete, the script can be executed in npm run dev -- <command> <options>.

cp .env.sample .env
# Set your secrets in .env.

That's it. Happy coding :+1:

License

Forke is available under the MIT License.

1.1.4

12 months ago

1.1.3

12 months ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.0

1 year ago