Class: BoringBuilder::Pipeline
- Inherits:
-
Object
- Object
- BoringBuilder::Pipeline
- Defined in:
- lib/boringbuilder/pipeline.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#progress ⇒ Object
readonly
Returns the value of attribute progress.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #build ⇒ Object
- #container(image = nil) ⇒ Object
- #exec(container, command, name:, workdir: project.application_path, **options) ⇒ Object
-
#initialize(project, client, environment: ENV, progress: BuildProgress.silent) ⇒ Pipeline
constructor
A new instance of Pipeline.
- #mise(tools: {}, image: Mise::DEFAULT_IMAGE, workdir: project.application_path) ⇒ Object
- #run(container, command, cache:, at: nil, entry: nil, workdir: project.application_path, sharing: :LOCKED, name: "Run cached step", **options) ⇒ Object
- #source ⇒ Object
- #step(name, container) ⇒ Object
Constructor Details
#initialize(project, client, environment: ENV, progress: BuildProgress.silent) ⇒ Pipeline
Returns a new instance of Pipeline.
7 8 9 10 11 12 |
# File 'lib/boringbuilder/pipeline.rb', line 7 def initialize(project, client, environment: ENV, progress: BuildProgress.silent) @project = project @client = client @environment = environment @progress = progress end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/boringbuilder/pipeline.rb', line 5 def client @client end |
#progress ⇒ Object (readonly)
Returns the value of attribute progress.
5 6 7 |
# File 'lib/boringbuilder/pipeline.rb', line 5 def progress @progress end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
5 6 7 |
# File 'lib/boringbuilder/pipeline.rb', line 5 def project @project end |
Instance Method Details
#build ⇒ Object
14 15 16 17 18 19 |
# File 'lib/boringbuilder/pipeline.rb', line 14 def build container = yield self raise ConfigurationError, "The custom pipeline must return a Dagger container" unless container sync_step(container, "Build application") end |
#container(image = nil) ⇒ Object
21 22 23 24 |
# File 'lib/boringbuilder/pipeline.rb', line 21 def container(image = nil) result = client.container() image ? result.from(image) : result end |
#exec(container, command, name:, workdir: project.application_path, **options) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/boringbuilder/pipeline.rb', line 60 def exec(container, command, name:, workdir: project.application_path, **) arguments = Array(command).map(&:to_s) raise ConfigurationError, "step command cannot be empty" if arguments.empty? result = execute(container.with_workdir(workdir.to_s), arguments, ) sync_step(result, name, output: -> { command_output(result) }) end |
#mise(tools: {}, image: Mise::DEFAULT_IMAGE, workdir: project.application_path) ⇒ Object
30 31 32 |
# File 'lib/boringbuilder/pipeline.rb', line 30 def mise(tools: {}, image: Mise::DEFAULT_IMAGE, workdir: project.application_path) Mise.new(project, self).container(tools: tools, image: image, workdir: workdir) end |
#run(container, command, cache:, at: nil, entry: nil, workdir: project.application_path, sharing: :LOCKED, name: "Run cached step", **options) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/boringbuilder/pipeline.rb', line 34 def run(container, command, cache:, at: nil, entry: nil, workdir: project.application_path, sharing: :LOCKED, name: "Run cached step", **) arguments = Array(command).map(&:to_s) mounts = normalize_mounts(cache, at, entry) validate_step!(arguments, mounts) remote_cache = BoringCache.new(project, client, environment: @environment) container = container.with_workdir(workdir.to_s) result, executed = if remote_cache.enabled? container = remote_cache.prepare(container, workdir: workdir) command = if entry remote_cache.wrap(arguments, entry: entry.to_s) else remote_cache.wrap_mounts(arguments, mounts) end command_result = execute(container, command, ) final_result = entry ? command_result : remove_directories(command_result, mounts.values) [final_result, command_result] else run_with_local_cache(container, arguments, mounts, sharing, ) end sync_step(result, name, output: -> { command_output(executed) }) end |
#source ⇒ Object
26 27 28 |
# File 'lib/boringbuilder/pipeline.rb', line 26 def source project.source(client) end |
#step(name, container) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/boringbuilder/pipeline.rb', line 68 def step(name, container) result = yield container raise ConfigurationError, "The pipeline step must return a Dagger container" unless result sync_step(result, name) end |