Skip to content

Commit

Permalink
No ERB templates of YAML needed at this point
Browse files Browse the repository at this point in the history
  • Loading branch information
mostlyobvious committed Sep 10, 2023
1 parent df8693a commit ec46088
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
20 changes: 11 additions & 9 deletions support/ci/generate
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# frozen_string_literal: true

require "bundler/inline"
require "erb"
require "psych"

gemfile do
Expand Down Expand Up @@ -813,12 +812,14 @@ class CI

File.write(
File.join(workflows_root, filename),
ERB.new(
File.read(File.join(template_root, "template.yaml.erb"))
).result_with_hash(
name: name,
on: as_formatted_yaml(gem.fetch(:on).reduce(&:merge), indent: 2),
job: as_formatted_yaml({ gem.fetch(:job_name) => job }, indent: 2)
as_formatted_yaml(
{
"name" => name,
"on" => gem.fetch(:on).reduce(&:merge),
"jobs" => {
gem.fetch(:job_name) => job
}
}
)
)

Expand All @@ -836,13 +837,14 @@ class CI
end
end

def as_formatted_yaml(content, indent:)
def as_formatted_yaml(content)
Psych
.safe_dump(content, line_width: 120)
.lines
.drop(1)
.join(" " * indent)
.join
.strip
.gsub(/'on':\n/, "on:\n")
end

def initialize(workflows_root, template_root)
Expand Down
5 changes: 0 additions & 5 deletions support/ci/template.yaml.erb

This file was deleted.

0 comments on commit ec46088

Please sign in to comment.