{"id":14260946,"url":"https://github.com/fchimpan/gh-workflow-stats","last_synced_at":"2026-03-11T18:02:56.032Z","repository":{"id":227174901,"uuid":"730047563","full_name":"fchimpan/gh-workflow-stats","owner":"fchimpan","description":"A GitHub CLI extension to calculate the success rate and execution time of workflows and jobs.","archived":false,"fork":false,"pushed_at":"2024-11-27T22:31:57.000Z","size":9250,"stargazers_count":85,"open_issues_count":6,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-09T12:45:29.218Z","etag":null,"topics":["actions","ci","cli","gh-extension","github","github-actions","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fchimpan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-12-11T04:54:24.000Z","updated_at":"2024-11-11T08:12:49.000Z","dependencies_parsed_at":"2024-04-19T11:31:37.048Z","dependency_job_id":null,"html_url":"https://github.com/fchimpan/gh-workflow-stats","commit_stats":null,"previous_names":["fchimpan/gh-workflow-stats"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fchimpan%2Fgh-workflow-stats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fchimpan%2Fgh-workflow-stats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fchimpan%2Fgh-workflow-stats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fchimpan%2Fgh-workflow-stats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fchimpan","download_url":"https://codeload.github.com/fchimpan/gh-workflow-stats/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229754470,"owners_count":18119124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","ci","cli","gh-extension","github","github-actions","golang"],"created_at":"2024-08-22T13:00:40.151Z","updated_at":"2025-12-15T18:26:31.830Z","avatar_url":"https://github.com/fchimpan.png","language":"Go","readme":"# GitHub Actions workflow stats\n\n✨ A GitHub CLI extension to calculate the success rate and execution time of workflows and jobs.\n\n![demo.gif](./images/demo.gif)\n\n## Features\n\n- **Workflow Run Analysis**\n  - Calculate the success rate and execution time of workflow runs\n  - Average, median, minimum, and maximum execution time of successful runs\n  - Detailed statistics for each run (Run ID, Actor, Started At, Duration, HTML URL)\n  - Fetch workflow runs and workflow run attempts\n  - Rate of success, failure, and others outcomes\n  \n- **Workflow Job Analysis**\n  - Calculate the success rate and execution time of workflow job steps\n  - Average, median, minimum, and maximum execution time of successful jobs\n  - Detailed statistics for each job and step\n  - Step-level analysis (Step name, Step number, Runs count, Conclusion, Rate, Execution duration, Failure HTML URL)\n  - Most failed steps identification\n  - Most time-consuming steps analysis\n\n- **Advanced Features**\n  - Support for composite actions and reusable workflows\n  - Multiple output formats (human-readable and JSON)\n  - Comprehensive filtering options (actor, branch, event, status, date range)\n  - Debug and verbose logging modes\n  - GitHub Enterprise Server support\n\n\n## Installation\n\nYou can install it using the gh cli extension.\n\n```\ngh extensions install fchimpan/gh-workflow-stats\n```\n\n## Quick Start\n\nIf you want to get the success rate and execution time of a workflow:\n\n```sh\n$ gh workflow-stats -o $OWNER -r $REPO -f ci.yaml\n```\n\nIf you want to get the success rate and execution time of a workflow job in JSON format:\n\n```sh\n$ gh workflow-stats jobs -o $OWNER -r $REPO -f ci.yaml --json\n```\n\nIf you want to debug issues or see detailed operation logs:\n\n```sh\n# With verbose logging\n$ gh workflow-stats -o $OWNER -r $REPO -f ci.yaml --verbose\n\n# With debug logging\n$ gh workflow-stats -o $OWNER -r $REPO -f ci.yaml --debug\n```\n\n## Usage\n\n```sh\n$ gh workflow-stats -h\nGet workflow runs stats. Retrieve the success rate and execution time of workflows.\n\nUsage:\n  workflow-stats [flags]\n  workflow-stats [command]\n\nExamples:\n$ gh workflow-stats --org $OWNER --repo $REPO -f ci.yaml\n\nAvailable Commands:\n  completion  Generate the autocompletion script for the specified shell\n  help        Help about any command\n  jobs        Fetch workflow jobs stats. Retrieve the steps and jobs success rate.\n\nFlags:\n  -a, --actor string            Workflow run actor\n  -A, --all                     Target all workflows in the repository. If specified, default fetches of 100 workflow runs is overridden to all workflow runs. Note the GitHub API rate limit.\n  -b, --branch string           Workflow run branch. Returns workflow runs associated with a branch. Use the name of the branch of the push.\n  -C, --check-suite-id int      Workflow run check suite ID\n  -c, --created string          Workflow run createdAt. Returns workflow runs created within the given date-time range.\n                                 For more information on the syntax, see https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#query-for-dates\n  -d, --debug                   Enable debug mode with detailed logging\n  -e, --event string            Workflow run event. e.g. push, pull_request, pull_request_target, etc.\n                                 See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows\n  -x, --exclude-pull-requests   Workflow run exclude pull requests\n  -f, --file string             The name of the workflow file. e.g. ci.yaml. You can also pass the workflow id as a integer.\n  -S, --head-sha string         Workflow run head SHA\n  -h, --help                    help for workflow-stats\n  -H, --host string             GitHub host. If not specified, default is github.com. If you want to use GitHub Enterprise Server, specify your GitHub Enterprise Server host. (default \"github.com\")\n  -i, --id int                  The ID of the workflow. You can also pass the workflow file name as a string. (default -1)\n      --json                    Output as JSON\n  -o, --org string              GitHub organization\n  -r, --repo string             GitHub repository\n  -s, --status strings          Workflow run status. e.g. completed, in_progress, queued, etc.\n                                 Multiple values can be provided separated by a comma. For a full list of supported values see https://docs.github.com/en/rest/reference/actions#list-workflow-runs-for-a-repository\n  -v, --verbose                 Enable verbose logging (info level)\n\nUse \"workflow-stats [command] --help\" for more information about a command.\n```\n\n### Fetch workflow ID\n\nFor the `--id` flag, you can list the workflow IDs with the standard `gh` CLI: `gh workflow list`, e.g.:\n```\nNAME                             STATE   ID\nAAAA                             active  123456\nBBBB                             active  543112\n```\n\n### Fetch all workflow runs\n\nBy default, `workflow-stats` and `workflow-stats jobs` commands will return **100** workflow runs.\nIf you want to get all workflow runs, you can use the `--all` flag.\nHowever, GitHub API has a rate limit, so please combine other parameters as appropriate to reduce the number of API requests.\n\n```sh\n# Get executed at 2022-01-01 or later and actor is $ACTOR\n$ gh workflow-stats -o $OWNER -r $REPO -f ci.yaml -A -c \"\u003e2024-01-01\" -a $ACTOR\n```\n\nMore details on API rate limits can be found in the [GitHub API documentation](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28).\n\n### Debug and Logging\n\nYou can control the level of logging output using debug flags:\n\n```sh\n# Normal mode - clean output with no logs\n$ gh workflow-stats -o $OWNER -r $REPO -f ci.yaml\n\n# Verbose mode - show informational logs to stderr\n$ gh workflow-stats -o $OWNER -r $REPO -f ci.yaml --verbose\n\n# Debug mode - show detailed debug logs to stderr\n$ gh workflow-stats -o $OWNER -r $REPO -f ci.yaml --debug\n```\n\n**Note**: Logs are always output to stderr to avoid interfering with the main output. When using `--json` flag, logs are automatically disabled to ensure clean JSON output.\n\n### GitHub Enterprise Server\n\nIf you want to use GitHub Enterprise Server, you can use the `--host` flag or set the `GH_HOST` environment variable.\nHost name is `http(s)://[your-github-host]/api/v3/`\n\n```sh\n$ export GH_HOST=\"your-github-host\"\n$ gh workflow-stats -o $OWNER -r $REPO -f ci.yaml\n# or\n$ gh workflow-stats -o $OWNER -r $REPO -f ci.yaml --host=\"your-github-host\"\n```\n\n### How it works\nThis tool retrieves workflow execution statistics using the GitHub API. For more details on the parameters, please refer to the GitHub API reference.\n- [Workflow runs](https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-workflow)\n- [Workflow jobs](https://docs.github.com/en/rest/actions/workflow-jobs?apiVersion=2022-11-28#get-a-job-for-a-workflow-run)\n\n## Rate Limiting\n\nGitHub imposes a [primary rate limit](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#about-primary-rate-limits) and a [secondary rate limit](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#about-secondary-rate-limits) on all API clients.\n\nWhen you reach the primary rate limit, results are calculated based on successful fetches.\nIn the secondary rate limit, this tool handles requests in a round-tripper to avoid the rate limit. Therefore, the execution time may be longer.\n\nFor large repositories with many workflow runs, consider using filtering options (`--created`, `--actor`, `--branch`, etc.) to reduce the dataset size.\n\n## Standard Output\n\n[Sample output](./sample/std-output.txt)\n\n### 🏃 Total runs\n\n`Total runs` is the total number of workflow runs that `status` is `completed`. It includes `success`, `failure`, and `others` outcomes. `Others` outcomes include `cancelled`, `skipped`, etc.\n\n**`Total runs` includes the results of attempts other than the latest.**\nThis means that for a workflow that succeeds on the third attempt, the results of the first and second workflow executions are also included in the calculation.\n\n### ⏰ Workflow run execution time stats\n\n`Workflow run execution time stats` is the average execution time of workflows with **`success` conclusion and `completed` status**.\n\n### 📈 Top 3 jobs with the highest failure counts (failure runs / total runs)\n\n`Top 3 jobs with the highest failure counts` is the top 3 jobs with the highest failure counts. It is **not** failure rate.\nInstead of using the success rate, the tool displays jobs based on the number of failures, as jobs with fewer executions but a high failure rate would otherwise be ranked higher.\n\n The number of jobs displayed can be changed with a command-line argument `-n`.\n\n\n### 📊 Top 3 jobs with the longest execution average duration\n\n`Top 3 jobs with the longest execution average duration` is the top 3 jobs with the longest execution average duration.\n\nThe number of jobs displayed can be changed with a command-line argument `-n`.\n\n## JSON Schema Overview\n\nIf you use `--json` flag, the output will be a JSON object with the following structure. You can see sample output in [json-output.json](./sample/json-output.json).\n\n### Workflow runs\n\n| Field Name                    | Type             | Description                                                     |\n| ----------------------------- | ---------------- | --------------------------------------------------------------- |\n| `workflow_runs_stats_summary` | Object           | An object containing a summary of statistics for workflow runs. |\n| `workflow_jobs_stats_summary` | Array of objects | An array containing the summary statistics for workflow jobs.   |\n\n#### `workflow_runs_stats_summary` Object\n\n| Field Name                 | Type    | Description                                                         |\n| -------------------------- | ------- | ------------------------------------------------------------------- |\n| `total_runs_count`         | Integer | The total number of workflow runs.                                  |\n| `name`                     | String  | The name of the workflow.                                           |\n| `rate`                     | Object  | An object containing rates of success, failure, and other outcomes. |\n| `execution_duration_stats` | Object  | An object containing statistics on execution durations.             |\n| `conclusions`              | Object  | An object containing detailed information for each conclusion type. |\n\n##### `rate` Object\n\n| Field Name     | Type  | Description                                                     |\n| -------------- | ----- | --------------------------------------------------------------- |\n| `success_rate` | Float | The rate of success executions.                                 |\n| `failure_rate` | Float | The rate of failed executions.                                  |\n| `others_rate`  | Float | The rate of others outcomes. e.g., `cancelled`, `skipped`, etc. |\n\n##### `execution_duration_stats` Object\n\n`execution_duration_stats` is the average execution time of workflows with `success` conclusion and `completed` status.\nIn `post steps`, the execution time may be incorrect because GitHub API does not provide the duration of the workflow run.\n\n| Field Name | Type  | Description                            |\n| ---------- | ----- | -------------------------------------- |\n| `min`      | Float | Minimum execution time in seconds.     |\n| `max`      | Float | Maximum execution time in seconds.     |\n| `avg`      | Float | Average execution time in seconds.     |\n| `med`      | Float | Median execution time in seconds.      |\n| `std`      | Float | Standard deviation of execution times. |\n\n##### `conclusions` Object\n\n| Key       | Description                                                                                                                                                                                                                                                         |\n| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `failure` | Statistics for executions concluded as `failure`.                                                                                                                                                                                                                   |\n| `others`  | Statistics for executions that do not fit into the typical success/failure categories. e.g `cancelled`, `skipped`, etc. More details in [GitHub API documentation](https://docs.github.com/en/enterprise-server@3.10/graphql/reference/enums#checkconclusionstate). |\n| `success` | Statistics for executions concluded as `success`.                                                                                                                                                                                                                   |\n\n##### Conclusion Objects (`failure`, `others`, `success`)\n\n| Field Name      | Type    | Description                              |\n| --------------- | ------- | ---------------------------------------- |\n| `runs_count`    | Integer | The number of runs with this conclusion. |\n| `workflow_runs` | Array   | An array of objects detailing each run.  |\n\n##### `workflow_runs` Objects\n\n| Field Name       | Type     | Description                                                                                                                                                           |\n| ---------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `id`             | Integer  | The ID of the run.                                                                                                                                                    |\n| `status`         | String   | The status of the run (e.g., `completed`, `queued`).                                                                                                                  |\n| `conclusion`     | String   | The conclusion of the run (e.g., `success`, `failure`).                                                                                                               |\n| `actor`          | String   | The actor who initiated the run.                                                                                                                                      |\n| `run_attempt`    | Integer  | The attempt number of the run.                                                                                                                                        |\n| `html_url`       | String   | The HTML URL to the run on GitHub.                                                                                                                                    |\n| `jobs_url`       | String   | The URL to the jobs of the run.                                                                                                                                       |\n| `logs_url`       | String   | The URL to the logs of the run.                                                                                                                                       |\n| `run_started_at` | DateTime | The start time of the run.                                                                                                                                            |\n| `duration`       | Integer  | The duration of the run in seconds. Duration defined as `RunUpdatedAt` - `RunStartedAt`. **Note**: GitHub API is not provide duration. Thus, this may be not correct. |\n\n\n### Workflow Jobs Object\n\nEach object in the `workflow_jobs_stats_summary` array contains the following fields:\n\n| Field Name                 | Type             | Description                                                                                                                                                                              |\n| -------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `name`                     | String           | The name of the workflow job.                                                                                                                                                            |\n| `total_runs_count`         | Integer          | The total number of runs for this job.                                                                                                                                                   |\n| `rate`                     | Object           | An object containing the rates of success, failure, and others.                                                                                                                          |\n| `conclusions`              | Object           | An object containing the count of runs concluded as failure, success or others.                                                                                                          |\n| `execution_duration_stats` | Object           | An object with statistics about the execution duration. Duration defined as `GetStartedAt` - `CompletedAt`. **Note**: GitHub API is not provide duration. Thus, this may be not correct. |\n| `steps_summary`            | Array of objects | An array with summary statistics for each step of the job.                                                                                                                               |\n\n### Steps Summary Object\n\nEach object in the `steps_summary` array includes:\n\n| Field Name                 | Type    | Description                                                                                                                                                                                           |\n| -------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `name`                     | String  | The name of the step.                                                                                                                                                                                 |\n| `number`                   | Integer | The step number in the job's sequence.                                                                                                                                                                |\n| `runs_count`               | Integer | The number of times this step was run.                                                                                                                                                                |\n| `conclusion`               | Object  | An object containing the count of success, failure and others.                                                                                                                                        |\n| `rate`                     | Object  | An object containing the success rate, failure rate, and others rate for the step.                                                                                                                    |\n| `execution_duration_stats` | Object  | An object with statistics about the execution duration for the step. Duration defined as `GetStartedAt` - `CompletedAt`. **Note**: GitHub API is not provide duration. Thus, this may be not correct. |\n| `failure_html_url`         | Array   | An array of URLs to logs of the failed runs, if any.                                                                                                                                                  |\n\n#### Conclusion Object for Step\n\n| Key       | Description                                                                                                             |\n| --------- | ----------------------------------------------------------------------------------------------------------------------- |\n| `failure` | Statistics for executions concluded as `failure`.                                                                       |\n| `others`  | Statistics for executions that do not fit into the typical success/failure categories. e.g `cancelled`, `skipped`, etc. |\n| `success` | Statistics for executions concluded as `success`.                                                                       |\n\n\n### Sample JSON Output\n\n[Sample output](./sample/json-output.json)\n\n```json\n{\n\"workflow_runs_stats_summary\": {\n  \"total_runs_count\": 100,\n  \"name\": \"Tests\",\n  \"rate\": {\n    \"success_rate\": 0.79,\n    \"failure_rate\": 0.14,\n    \"others_rate\": 0.06999999999999995\n  },\n  \"execution_duration_stats\": {\n    \"min\": 365,\n    \"max\": 1080,\n    \"avg\": 505.54430379746833,\n    \"med\": 464,\n    \"std\": 120.8452088122228\n  },\n  \"conclusions\": {\n    \"failure\": {\n      \"runs_count\": 14,\n      \"workflow_runs\": [\n        {\n          \"id\": 8178615249,\n          \"status\": \"completed\",\n          \"conclusion\": \"failure\",\n          \"actor\": \"XXX\",\n          \"run_attempt\": 1,\n          \"html_url\": \"https://github.com/xxx/xxx/actions/runs/8178615249\",\n          \"run_started_at\": \"2024-03-06T20:53:43Z\",\n          \"duration\": 0\n        },\n        ...\n      ]\n    },\n}\n},\n\"workflow_jobs_stats_summary\": [\n  {\n    \"name\": \"build (ubuntu-latest)\",\n    \"total_runs_count\": 93,\n    \"rate\": {\n      \"success_rate\": 0.8494623655913979,\n      \"failure_rate\": 0.15053763440860216,\n      \"others_rate\": 0\n    },\n    \"conclusions\": {\n      \"failure\": 14,\n      \"success\": 79\n    },\n    \"execution_duration_stats\": {\n      \"min\": 166,\n      \"max\": 225,\n      \"avg\": 185.2405063291139,\n      \"med\": 178,\n      \"std\": 15.9367541045597\n    },\n    \"steps_summary\": [\n      {\n        \"name\": \"Set up job\",\n        \"number\": 1,\n        \"runs_count\": 93,\n        \"conclusion\": {\n          \"success\": 93\n        },\n        \"rate\": {\n          \"success_rate\": 1,\n          \"failure_rate\": 0,\n          \"others_rate\": 0\n        },\n        \"execution_duration_stats\": {\n          \"min\": 0,\n          \"max\": 3,\n          \"avg\": 1.3225806451612903,\n          \"med\": 1,\n          \"std\": 0.6584649846191345\n        },\n        \"failure_html_url\": []\n      },\n      ...\n    ]\n  },\n  ...\n]\n}\n```\n\n","funding_links":[],"categories":["🧩 Categories","cli"],"sub_categories":["Automation / DevOps"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffchimpan%2Fgh-workflow-stats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffchimpan%2Fgh-workflow-stats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffchimpan%2Fgh-workflow-stats/lists"}