Class: Flaky::Providers::GithubActions
- Inherits:
-
Base
- Object
- Base
- Flaky::Providers::GithubActions
show all
- Defined in:
- lib/flaky/providers/github_actions.rb
Instance Attribute Summary
Attributes inherited from Base
#config
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#fetch_jobs(pipeline_id:) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/flaky/providers/github_actions.rb', line 30
def fetch_jobs(pipeline_id:)
output = run_cmd("gh run view #{pipeline_id} --json jobs")
data = JSON.parse(output)
(data["jobs"] || []).filter_map do |job|
name = job["name"]
next unless name.match?(/test/i)
{
id: job["databaseId"].to_s,
name: name,
block_name: name,
result: map_conclusion(job["conclusion"])
}
end
end
|
#fetch_log(job_id:) ⇒ Object
47
48
49
|
# File 'lib/flaky/providers/github_actions.rb', line 47
def fetch_log(job_id:)
run_cmd("gh run view --job #{job_id} --log")
end
|
#fetch_workflows(age: "24h") ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/flaky/providers/github_actions.rb', line 9
def fetch_workflows(age: "24h")
hours = parse_age_to_hours(age)
cutoff = Time.now - (hours * 3600)
output = run_cmd("gh run list --branch #{config.branch} --limit 100 --json databaseId,conclusion,createdAt,headBranch,workflowName")
runs = JSON.parse(output)
runs.filter_map do |run|
created = Time.parse(run["createdAt"])
next if created < cutoff
{
id: run["databaseId"].to_s,
pipeline_id: run["databaseId"].to_s,
branch: run["headBranch"],
result: map_conclusion(run["conclusion"]),
created_at: run["createdAt"]
}
end
end
|