homebrew-core/Formula/chart-testing.rb

43 lines
1.7 KiB
Ruby

class ChartTesting < Formula
desc "Testing and linting Helm charts"
homepage "https://github.com/helm/chart-testing"
url "https://github.com/helm/chart-testing.git",
tag: "v3.0.0",
revision: "50db473a1e68c605b18d82f019d83ea401542213"
license "Apache-2.0"
bottle do
cellar :any_skip_relocation
rebuild 1
sha256 "b94f0fab8f35f89ce25ec4c8610af7310639899b1534b0907a4f96fb13c0c016" => :catalina
sha256 "58bfd0469d42422dc48b74cda82effc8f1baec442201a77ec2b8753c9810d5ae" => :mojave
sha256 "97661974290727c2832803f74bcf0277d01192adc2b65432714b0c376e01bb99" => :high_sierra
end
depends_on "go" => :build
depends_on "helm" => :test
depends_on "yamllint" => :test
def install
commit = Utils.safe_popen_read("git", "rev-parse", "HEAD").chomp
ldflags = %W[
-X github.com/helm/chart-testing/v#{version.major}/ct/cmd.Version=#{version}
-X github.com/helm/chart-testing/v#{version.major}/ct/cmd.GitCommit=#{commit}
-X github.com/helm/chart-testing/v#{version.major}/ct/cmd.BuildDate=#{Date.today}
].join(" ")
system "go", "build", *std_go_args, "-ldflags", ldflags, "-o", bin/"ct", "./ct/main.go"
etc.install "etc" => "ct"
end
test do
assert_match "Lint and test", shell_output("#{bin}/ct --help")
assert_match /Version:\s+#{version}/, shell_output("#{bin}/ct version")
# Lint an empty Helm chart that we create with `helm create`
system "helm", "create", "testchart"
output = shell_output("#{bin}/ct lint --charts ./testchart --validate-chart-schema=false" \
" --validate-maintainers=false").lines.last.chomp
assert_match "All charts linted successfully", output
end
end