Class: CIRun

Inherits:
Object
  • Object
show all
Defined in:
lib/ratatui_ruby/devtools/tasks/release/ci_run.rb

Overview

A completed GitHub Actions workflow run for a specific commit.

Constant Summary collapse

WORKFLOW_NAME =

The GitHub Actions workflow name that produces native gem artifacts.

"Build Gems"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_commit(sha) ⇒ Object

Finds the most recent successful run for the given commit SHA.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ratatui_ruby/devtools/tasks/release/ci_run.rb', line 19

def self.for_commit(sha)
  out, status = Open3.capture2(
    "gh", "run", "list",
    "--workflow", WORKFLOW_NAME,
    "--commit", sha,
    "--status", "completed",
    "--json", "databaseId,conclusion",
    "--limit", "1"
  )
  return nil unless status.success?

  runs = JSON.parse(out)
  run = runs.first
  return nil unless run
  return nil unless run.fetch("conclusion") == "success"

  new(id: run.fetch("databaseId"))
end

Instance Method Details

#download(dir) ⇒ Object

Downloads artifacts into dir and returns paths to the .gem files.



39
40
41
42
43
# File 'lib/ratatui_ruby/devtools/tasks/release/ci_run.rb', line 39

def download(dir)
  puts "Downloading native gem artifacts from run #{id}..."
  system("gh", "run", "download", id.to_s, "--dir", dir, exception: true)
  Dir.glob("#{dir}/**/*.gem")
end