fastlane-plugin-circle_ci 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +272 -3
  3. data/lib/fastlane/plugin/circle_ci/actions/circleci_add_context_env_var.rb +117 -0
  4. data/lib/fastlane/plugin/circle_ci/actions/circleci_add_project_collaborator.rb +109 -0
  5. data/lib/fastlane/plugin/circle_ci/actions/circleci_approve_job.rb +95 -0
  6. data/lib/fastlane/plugin/circle_ci/actions/circleci_cancel_job.rb +96 -0
  7. data/lib/fastlane/plugin/circle_ci/actions/circleci_cancel_workflow.rb +85 -0
  8. data/lib/fastlane/plugin/circle_ci/actions/circleci_continue_pipeline.rb +104 -0
  9. data/lib/fastlane/plugin/circle_ci/actions/circleci_create_checkout_key.rb +110 -0
  10. data/lib/fastlane/plugin/circle_ci/actions/circleci_create_pipeline_definition.rb +126 -0
  11. data/lib/fastlane/plugin/circle_ci/actions/circleci_create_pipeline_definition_trigger.rb +133 -0
  12. data/lib/fastlane/plugin/circle_ci/actions/circleci_create_pipeline_schedule.rb +160 -0
  13. data/lib/fastlane/plugin/circle_ci/actions/circleci_create_project.rb +105 -0
  14. data/lib/fastlane/plugin/circle_ci/actions/circleci_create_webhook.rb +155 -0
  15. data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_checkout_key.rb +93 -0
  16. data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_context_env_var.rb +110 -0
  17. data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_env_var.rb +86 -0
  18. data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_pipeline_definition.rb +91 -0
  19. data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_pipeline_schedule.rb +95 -0
  20. data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_trigger.rb +92 -0
  21. data/lib/fastlane/plugin/circle_ci/actions/circleci_delete_webhook.rb +86 -0
  22. data/lib/fastlane/plugin/circle_ci/actions/circleci_download_artifact.rb +119 -0
  23. data/lib/fastlane/plugin/circle_ci/actions/circleci_download_workflow_artifacts.rb +400 -0
  24. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_checkout_key.rb +101 -0
  25. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_checkout_keys.rb +96 -0
  26. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_context_env_vars.rb +114 -0
  27. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_env_vars.rb +95 -0
  28. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_flaky_tests.rb +99 -0
  29. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_job_artifacts.rb +111 -0
  30. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_job_details.rb +110 -0
  31. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_job_tests.rb +111 -0
  32. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_job_timeseries.rb +131 -0
  33. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_my_pipelines.rb +100 -0
  34. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_org_summary.rb +113 -0
  35. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline.rb +104 -0
  36. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_by_number.rb +105 -0
  37. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_config.rb +92 -0
  38. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_definition.rb +99 -0
  39. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_definitions.rb +94 -0
  40. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_values.rb +91 -0
  41. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_pipeline_workflows.rb +108 -0
  42. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_project_branches.rb +105 -0
  43. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_project_config.rb +104 -0
  44. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_project_workflow_metrics.rb +121 -0
  45. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_trigger.rb +99 -0
  46. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_user_info.rb +83 -0
  47. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow.rb +121 -0
  48. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_insights.rb +157 -0
  49. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_job_metrics.rb +123 -0
  50. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_jobs.rb +109 -0
  51. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_runs.rb +129 -0
  52. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_summary.rb +118 -0
  53. data/lib/fastlane/plugin/circle_ci/actions/circleci_get_workflow_test_metrics.rb +115 -0
  54. data/lib/fastlane/plugin/circle_ci/actions/circleci_list_all_pipelines.rb +94 -0
  55. data/lib/fastlane/plugin/circle_ci/actions/circleci_list_contexts.rb +132 -0
  56. data/lib/fastlane/plugin/circle_ci/actions/circleci_list_pipeline_definition_triggers.rb +101 -0
  57. data/lib/fastlane/plugin/circle_ci/actions/circleci_list_pipeline_schedules.rb +99 -0
  58. data/lib/fastlane/plugin/circle_ci/actions/circleci_list_projects.rb +89 -0
  59. data/lib/fastlane/plugin/circle_ci/actions/circleci_list_webhooks.rb +111 -0
  60. data/lib/fastlane/plugin/circle_ci/actions/circleci_rerun_workflow.rb +101 -0
  61. data/lib/fastlane/plugin/circle_ci/actions/circleci_set_env_var.rb +102 -0
  62. data/lib/fastlane/plugin/circle_ci/actions/circleci_trigger_pipeline.rb +130 -0
  63. data/lib/fastlane/plugin/circle_ci/actions/circleci_update_pipeline_definition.rb +127 -0
  64. data/lib/fastlane/plugin/circle_ci/actions/circleci_update_pipeline_schedule.rb +134 -0
  65. data/lib/fastlane/plugin/circle_ci/actions/circleci_update_trigger.rb +114 -0
  66. data/lib/fastlane/plugin/circle_ci/actions/circleci_wait_for_pipeline.rb +152 -0
  67. data/lib/fastlane/plugin/circle_ci/helper/circle_ci_helper.rb +102 -1
  68. data/lib/fastlane/plugin/circle_ci/version.rb +1 -1
  69. metadata +99 -7
@@ -0,0 +1,121 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/circle_ci_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ CIRCLECI_PROJECT_WORKFLOW_METRICS = :CIRCLECI_PROJECT_WORKFLOW_METRICS
8
+ end
9
+
10
+ class CircleciGetProjectWorkflowMetricsAction < Action
11
+ def self.run(params)
12
+ UI.message("Getting workflow metrics for CircleCI project via Insights API v2...")
13
+
14
+ api_token = params[:api_token]
15
+ project_slug = params[:project_slug]
16
+
17
+ # Build query parameters
18
+ query_params = {}
19
+ query_params["branch"] = params[:branch] if params[:branch]
20
+ query_params["reporting-window"] = params[:reporting_window] if params[:reporting_window]
21
+ query_params["workflow-name"] = params[:workflow_name] if params[:workflow_name]
22
+ query_params["page-token"] = params[:page_token] if params[:page_token]
23
+
24
+ # Make API request
25
+ result = Helper::CircleCiHelper.get_v2("insights/#{project_slug}/workflows", api_token, query_params)
26
+
27
+ # Store values in lane context
28
+ Actions.lane_context[SharedValues::CIRCLECI_PROJECT_WORKFLOW_METRICS] = result
29
+
30
+ UI.success("Successfully retrieved workflow metrics for project #{project_slug}")
31
+
32
+ return result
33
+ end
34
+
35
+ def self.description
36
+ "Gets summary metrics for a project's workflows using Insights API v2"
37
+ end
38
+
39
+ def self.details
40
+ "This action retrieves summary metrics for a project's workflows using the CircleCI Insights API v2. Workflow runs going back at most 90 days are included in the aggregation window. Metrics are refreshed daily, and thus may not include executions from the last 24 hours."
41
+ end
42
+
43
+ def self.available_options
44
+ [
45
+ FastlaneCore::ConfigItem.new(key: :api_token,
46
+ env_name: "CIRCLE_CI_API_TOKEN",
47
+ description: "API Token for CircleCI API",
48
+ sensitive: true,
49
+ code_gen_sensitive: true,
50
+ is_string: true,
51
+ default_value: ENV["CIRCLE_CI_API_TOKEN"],
52
+ default_value_dynamic: true,
53
+ optional: false),
54
+ FastlaneCore::ConfigItem.new(key: :project_slug,
55
+ env_name: "CIRCLE_CI_PROJECT_SLUG",
56
+ description: "Project slug in the form of :vcs-type/:org-name/:project-name (e.g. github/myorg/myrepo)",
57
+ is_string: true,
58
+ default_value: ENV["CIRCLE_CI_PROJECT_SLUG"],
59
+ default_value_dynamic: true,
60
+ optional: false),
61
+ FastlaneCore::ConfigItem.new(key: :branch,
62
+ description: "The name of a branch to filter for",
63
+ is_string: true,
64
+ optional: true),
65
+ FastlaneCore::ConfigItem.new(key: :reporting_window,
66
+ description: "The time window used to calculate summary metrics (last-24-hours, last-7-days, last-90-days, etc.)",
67
+ is_string: true,
68
+ optional: true),
69
+ FastlaneCore::ConfigItem.new(key: :workflow_name,
70
+ description: "The name of a workflow to filter for",
71
+ is_string: true,
72
+ optional: true),
73
+ FastlaneCore::ConfigItem.new(key: :page_token,
74
+ description: "A token to retrieve the next page of results",
75
+ is_string: true,
76
+ optional: true)
77
+ ]
78
+ end
79
+
80
+ def self.output
81
+ [
82
+ ['CIRCLECI_PROJECT_WORKFLOW_METRICS', 'A hash containing workflow metrics for the project']
83
+ ]
84
+ end
85
+
86
+ def self.return_value
87
+ "Returns a hash containing workflow metrics for the project."
88
+ end
89
+
90
+ def self.authors
91
+ ["crazymanish", "copilot"]
92
+ end
93
+
94
+ def self.example_code
95
+ [
96
+ 'circleci_get_project_workflow_metrics(
97
+ project_slug: "gh/MyOrg/my-project"
98
+ )',
99
+ 'metrics = circleci_get_project_workflow_metrics(
100
+ project_slug: "gh/MyOrg/my-project",
101
+ branch: "main",
102
+ reporting_window: "last-30-days"
103
+ )
104
+
105
+ # Access the workflow metrics
106
+ metrics["items"].each do |workflow|
107
+ UI.message("Workflow: #{workflow["name"]}, Success Rate: #{workflow["success_rate"]}")
108
+ end'
109
+ ]
110
+ end
111
+
112
+ def self.is_supported?(platform)
113
+ true
114
+ end
115
+
116
+ def self.category
117
+ :ci
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,99 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/circle_ci_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ CIRCLECI_TRIGGER_INFO = :CIRCLECI_TRIGGER_INFO
8
+ end
9
+
10
+ class CircleciGetTriggerAction < Action
11
+ def self.run(params)
12
+ UI.message("Getting CircleCI trigger information via API v2...")
13
+
14
+ api_token = params[:api_token]
15
+ project_id = params[:project_id]
16
+ trigger_id = params[:trigger_id]
17
+
18
+ # Make API request
19
+ result = Helper::CircleCiHelper.get_v2("projects/#{project_id}/triggers/#{trigger_id}", api_token)
20
+
21
+ # Store values in lane context
22
+ Actions.lane_context[SharedValues::CIRCLECI_TRIGGER_INFO] = result
23
+
24
+ UI.success("Successfully retrieved trigger information")
25
+
26
+ return result
27
+ end
28
+
29
+ def self.description
30
+ "Gets information about a specific trigger using CircleCI API v2"
31
+ end
32
+
33
+ def self.details
34
+ "This action retrieves detailed information about a specific trigger using the CircleCI API v2."
35
+ end
36
+
37
+ def self.available_options
38
+ [
39
+ FastlaneCore::ConfigItem.new(key: :api_token,
40
+ env_name: "CIRCLE_CI_API_TOKEN",
41
+ description: "API Token for CircleCI API",
42
+ sensitive: true,
43
+ code_gen_sensitive: true,
44
+ is_string: true,
45
+ default_value: ENV["CIRCLE_CI_API_TOKEN"],
46
+ default_value_dynamic: true,
47
+ optional: false),
48
+ FastlaneCore::ConfigItem.new(key: :project_id,
49
+ env_name: "CIRCLE_CI_PROJECT_ID",
50
+ description: "The ID of the CircleCI project",
51
+ is_string: true,
52
+ optional: false),
53
+ FastlaneCore::ConfigItem.new(key: :trigger_id,
54
+ description: "The ID of the trigger to retrieve",
55
+ is_string: true,
56
+ optional: false)
57
+ ]
58
+ end
59
+
60
+ def self.output
61
+ [
62
+ ['CIRCLECI_TRIGGER_INFO', 'A hash containing the trigger information']
63
+ ]
64
+ end
65
+
66
+ def self.return_value
67
+ "Returns a hash containing detailed information about the trigger."
68
+ end
69
+
70
+ def self.authors
71
+ ["crazymanish", "copilot"]
72
+ end
73
+
74
+ def self.example_code
75
+ [
76
+ 'circleci_get_trigger(
77
+ project_id: "01234567-89ab-cdef-0123-456789abcdef",
78
+ trigger_id: "fedcba98-7654-3210-fedc-ba9876543210"
79
+ )',
80
+ 'trigger_info = circleci_get_trigger(
81
+ project_id: "01234567-89ab-cdef-0123-456789abcdef",
82
+ trigger_id: "fedcba98-7654-3210-fedc-ba9876543210"
83
+ )
84
+
85
+ # Use the trigger information
86
+ UI.message("Trigger type: #{trigger_info["type"]}, Description: #{trigger_info["description"]}")'
87
+ ]
88
+ end
89
+
90
+ def self.is_supported?(platform)
91
+ true
92
+ end
93
+
94
+ def self.category
95
+ :ci
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,83 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/circle_ci_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ CIRCLECI_USER_INFO = :CIRCLECI_USER_INFO
8
+ end
9
+
10
+ class CircleciGetUserInfoAction < Action
11
+ def self.run(params)
12
+ UI.message("Getting CircleCI user information via API v2...")
13
+
14
+ api_token = params[:api_token]
15
+
16
+ # Make API request
17
+ result = Helper::CircleCiHelper.get_v2("me", api_token)
18
+
19
+ # Store values in lane context
20
+ Actions.lane_context[SharedValues::CIRCLECI_USER_INFO] = result
21
+
22
+ UI.success("Successfully retrieved user information for #{result["name"] || result["login"]}")
23
+
24
+ return result
25
+ end
26
+
27
+ def self.description
28
+ "Gets information about the authenticated CircleCI user using API v2"
29
+ end
30
+
31
+ def self.details
32
+ "This action retrieves information about the currently authenticated CircleCI user using the CircleCI API v2. This includes details such as name, login, and ID."
33
+ end
34
+
35
+ def self.available_options
36
+ [
37
+ FastlaneCore::ConfigItem.new(key: :api_token,
38
+ env_name: "CIRCLE_CI_API_TOKEN",
39
+ description: "API Token for CircleCI API",
40
+ sensitive: true,
41
+ code_gen_sensitive: true,
42
+ is_string: true,
43
+ default_value: ENV["CIRCLE_CI_API_TOKEN"],
44
+ default_value_dynamic: true,
45
+ optional: false)
46
+ ]
47
+ end
48
+
49
+ def self.output
50
+ [
51
+ ['CIRCLECI_USER_INFO', 'A hash containing the user information']
52
+ ]
53
+ end
54
+
55
+ def self.return_value
56
+ "Returns a hash containing user information including name, login, and ID."
57
+ end
58
+
59
+ def self.authors
60
+ ["crazymanish", "copilot"]
61
+ end
62
+
63
+ def self.example_code
64
+ [
65
+ 'circleci_get_user_info',
66
+ 'user_info = circleci_get_user_info
67
+
68
+ # Display user details
69
+ puts "User: #{user_info["name"] || user_info["login"]}"
70
+ puts "ID: #{user_info["id"]}"'
71
+ ]
72
+ end
73
+
74
+ def self.is_supported?(platform)
75
+ true
76
+ end
77
+
78
+ def self.category
79
+ :ci
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,121 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/circle_ci_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ CIRCLECI_WORKFLOW = :CIRCLECI_WORKFLOW
8
+ end
9
+
10
+ class CircleciGetWorkflowAction < Action
11
+ def self.run(params)
12
+ UI.message("Getting CircleCI workflow via API v2...")
13
+
14
+ api_token = params[:api_token]
15
+ workflow_id = params[:workflow_id]
16
+
17
+ # Make API request
18
+ result = Helper::CircleCiHelper.get_v2("workflow/#{workflow_id}", api_token)
19
+
20
+ # Store values in lane context
21
+ Actions.lane_context[SharedValues::CIRCLECI_WORKFLOW] = result
22
+
23
+ UI.success("Successfully retrieved workflow #{workflow_id}")
24
+
25
+ return result
26
+ end
27
+
28
+ def self.description
29
+ "Gets information about a CircleCI workflow using API v2"
30
+ end
31
+
32
+ def self.details
33
+ "This action retrieves detailed information about a specific CircleCI workflow using the CircleCI API v2, including status, created timestamp, pipeline ID, and project data."
34
+ end
35
+
36
+ def self.available_options
37
+ [
38
+ FastlaneCore::ConfigItem.new(key: :api_token,
39
+ env_name: "CIRCLE_CI_API_TOKEN",
40
+ description: "API Token for CircleCI API",
41
+ sensitive: true,
42
+ code_gen_sensitive: true,
43
+ is_string: true,
44
+ default_value: ENV["CIRCLE_CI_API_TOKEN"],
45
+ default_value_dynamic: true,
46
+ optional: false),
47
+ FastlaneCore::ConfigItem.new(key: :workflow_id,
48
+ env_name: "CIRCLE_CI_WORKFLOW_ID",
49
+ description: "The ID of the workflow to get information for",
50
+ is_string: true,
51
+ optional: false)
52
+ ]
53
+ end
54
+
55
+ def self.output
56
+ [
57
+ ['CIRCLECI_WORKFLOW', 'A hash containing the workflow details']
58
+ ]
59
+ end
60
+
61
+ def self.return_value
62
+ "Returns a hash containing detailed workflow information including status, created timestamp, and pipeline ID."
63
+ end
64
+
65
+ def self.authors
66
+ ["crazymanish", "copilot"]
67
+ end
68
+
69
+ def self.example_code
70
+ [
71
+ 'circleci_get_workflow(
72
+ workflow_id: "workflow-uuid"
73
+ )',
74
+ 'workflow = circleci_get_workflow(
75
+ workflow_id: "workflow-uuid"
76
+ )
77
+
78
+ # Print workflow details
79
+ puts "Workflow name: #{workflow["name"]}"
80
+ puts "Status: #{workflow["status"]}"
81
+ puts "Created at: #{workflow["created_at"]}"
82
+
83
+ case workflow["status"]
84
+ when "success"
85
+ UI.success("Workflow completed successfully")
86
+ when "running"
87
+ UI.important("Workflow is still running")
88
+
89
+ # Get workflow jobs
90
+ jobs = circleci_get_workflow_jobs(
91
+ workflow_id: workflow["id"]
92
+ )
93
+
94
+ running_jobs = jobs.select { |j| j["status"] == "running" }
95
+ UI.message("There are #{running_jobs.count} jobs still running")
96
+ when "failed"
97
+ UI.error("Workflow failed")
98
+
99
+ # Get workflow jobs to find failure
100
+ jobs = circleci_get_workflow_jobs(
101
+ workflow_id: workflow["id"]
102
+ )
103
+
104
+ failed_jobs = jobs.select { |j| j["status"] == "failed" }
105
+ failed_jobs.each do |job|
106
+ UI.error("Job #{job["name"]} failed")
107
+ end
108
+ end'
109
+ ]
110
+ end
111
+
112
+ def self.is_supported?(platform)
113
+ true
114
+ end
115
+
116
+ def self.category
117
+ :ci
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,157 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/circle_ci_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ CIRCLECI_WORKFLOW_INSIGHTS = :CIRCLECI_WORKFLOW_INSIGHTS
8
+ end
9
+
10
+ class CircleciGetWorkflowInsightsAction < Action
11
+ def self.run(params)
12
+ UI.message("Getting CircleCI workflow insights via API v2...")
13
+
14
+ api_token = params[:api_token]
15
+ project_slug = params[:project_slug]
16
+ workflow_name = params[:workflow_name]
17
+
18
+ # Construct query parameters
19
+ query_params = []
20
+
21
+ # Add optional parameters if provided
22
+ query_params << "branches=#{params[:branches].join(',')}" if params[:branches]
23
+ query_params << "branch=#{params[:branch]}" if params[:branch]
24
+ query_params << "start-date=#{params[:start_date]}" if params[:start_date]
25
+ query_params << "end-date=#{params[:end_date]}" if params[:end_date]
26
+
27
+ # Construct the query string
28
+ query_string = query_params.empty? ? "" : "?#{query_params.join('&')}"
29
+
30
+ # Make API request
31
+ endpoint = "insights/#{project_slug}/workflows/#{workflow_name}#{query_string}"
32
+ result = Helper::CircleCiHelper.get_v2(endpoint, api_token)
33
+
34
+ # Store values in lane context
35
+ Actions.lane_context[SharedValues::CIRCLECI_WORKFLOW_INSIGHTS] = result
36
+
37
+ UI.success("Successfully retrieved workflow insights for #{workflow_name}")
38
+
39
+ return result
40
+ end
41
+
42
+ def self.description
43
+ "Gets workflow insights data from CircleCI using API v2"
44
+ end
45
+
46
+ def self.details
47
+ "This action retrieves detailed insights and metrics for a specific workflow in a project using the CircleCI API v2. " +
48
+ "The data includes success rates, duration metrics, and historical trends for the specified workflow."
49
+ end
50
+
51
+ def self.available_options
52
+ [
53
+ FastlaneCore::ConfigItem.new(key: :api_token,
54
+ env_name: "CIRCLE_CI_API_TOKEN",
55
+ description: "API Token for CircleCI API",
56
+ sensitive: true,
57
+ code_gen_sensitive: true,
58
+ is_string: true,
59
+ default_value: ENV["CIRCLE_CI_API_TOKEN"],
60
+ default_value_dynamic: true,
61
+ optional: false),
62
+ FastlaneCore::ConfigItem.new(key: :project_slug,
63
+ env_name: "CIRCLE_CI_PROJECT_SLUG",
64
+ description: "Project slug in the form of :vcs-type/:org-name/:project-name (e.g. github/myorg/myrepo)",
65
+ is_string: true,
66
+ default_value: ENV["CIRCLE_CI_PROJECT_SLUG"],
67
+ default_value_dynamic: true,
68
+ optional: false),
69
+ FastlaneCore::ConfigItem.new(key: :workflow_name,
70
+ env_name: "CIRCLE_CI_WORKFLOW_NAME",
71
+ description: "The name of the workflow to get insights for",
72
+ is_string: true,
73
+ optional: false),
74
+ FastlaneCore::ConfigItem.new(key: :branches,
75
+ env_name: "CIRCLE_CI_BRANCHES",
76
+ description: "The names of branches to include in the results (array)",
77
+ is_string: false,
78
+ type: Array,
79
+ optional: true),
80
+ FastlaneCore::ConfigItem.new(key: :branch,
81
+ env_name: "CIRCLE_CI_BRANCH",
82
+ description: "The name of a specific branch to filter results",
83
+ is_string: true,
84
+ optional: true),
85
+ FastlaneCore::ConfigItem.new(key: :start_date,
86
+ env_name: "CIRCLE_CI_START_DATE",
87
+ description: "The start date for the report in YYYY-MM-DD format",
88
+ is_string: true,
89
+ optional: true),
90
+ FastlaneCore::ConfigItem.new(key: :end_date,
91
+ env_name: "CIRCLE_CI_END_DATE",
92
+ description: "The end date for the report in YYYY-MM-DD format",
93
+ is_string: true,
94
+ optional: true)
95
+ ]
96
+ end
97
+
98
+ def self.output
99
+ [
100
+ ['CIRCLECI_WORKFLOW_INSIGHTS', 'A hash containing the workflow insights data']
101
+ ]
102
+ end
103
+
104
+ def self.return_value
105
+ "Returns a hash containing workflow insights data including metrics, durations, and trends."
106
+ end
107
+
108
+ def self.authors
109
+ ["crazymanish", "copilot"]
110
+ end
111
+
112
+ def self.example_code
113
+ [
114
+ 'circleci_get_workflow_insights(
115
+ project_slug: "github/myorg/myrepo",
116
+ workflow_name: "build-test-deploy"
117
+ )',
118
+ '# Get workflow insights for a specific date range and branch
119
+ insights = circleci_get_workflow_insights(
120
+ project_slug: "github/myorg/myrepo",
121
+ workflow_name: "build-test-deploy",
122
+ branch: "main",
123
+ start_date: "2023-01-01",
124
+ end_date: "2023-01-31"
125
+ )
126
+
127
+ # Analyze insights data
128
+ success_rate = insights["success_rate"]
129
+ median_duration_secs = insights["metrics"]["duration_metrics"]["median"]
130
+ total_runs = insights["metrics"]["total_runs"]
131
+
132
+ # Report findings
133
+ UI.message("Workflow success rate: #{success_rate}%")
134
+ UI.message("Median duration: #{median_duration_secs / 60.0} minutes")
135
+ UI.message("Total runs: #{total_runs}")
136
+
137
+ # Look for duration trends
138
+ if insights["trends"] && insights["trends"]["duration_trend"] > 0
139
+ UI.important("⚠️ Build times are trending upward!")
140
+ elsif insights["trends"] && insights["trends"]["duration_trend"] < 0
141
+ UI.success("✅ Build times are trending downward!")
142
+ else
143
+ UI.message("Build times are stable")
144
+ end'
145
+ ]
146
+ end
147
+
148
+ def self.is_supported?(platform)
149
+ true
150
+ end
151
+
152
+ def self.category
153
+ :ci
154
+ end
155
+ end
156
+ end
157
+ end