homebrew-core/Formula/circleci.rb

52 lines
2.0 KiB
Ruby

class Circleci < Formula
desc "Enables you to reproduce the CircleCI environment locally"
homepage "https://circleci.com/docs/2.0/local-cli/"
# Updates should be pushed no more frequently than once per week.
url "https://github.com/CircleCI-Public/circleci-cli.git",
tag: "v0.1.11508",
revision: "10b61a8706397a3d470eb0f2a8716ce6604fe584"
license "MIT"
bottle do
cellar :any_skip_relocation
sha256 "65de562014aef43364b3c02b13c0ec5dfafc646ec7c4fd8aefb3fb2ee3e8ba2e" => :big_sur
sha256 "8c583f2c1d80f412f5c751175d81ec319260647bbeb5ad1d4194f7247eaabae9" => :catalina
sha256 "3549fb556f6001dd444d930b66c37167145522fb3aa49aa577f49ab3f8565bc4" => :mojave
end
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
dir = buildpath/"src/github.com/CircleCI-Public/circleci-cli"
dir.install buildpath.children
cd dir do
commit = Utils.safe_popen_read("git", "rev-parse", "--short", "HEAD").chomp
ldflags = %W[
-s -w
-X github.com/CircleCI-Public/circleci-cli/version.packageManager=homebrew
-X github.com/CircleCI-Public/circleci-cli/version.Version=#{version}
-X github.com/CircleCI-Public/circleci-cli/version.Commit=#{commit}
]
system "make", "pack"
system "go", "build", "-ldflags", ldflags.join(" "),
"-o", bin/"circleci"
prefix.install_metafiles
end
end
test do
# assert basic script execution
assert_match /#{version}\+.{7}/, shell_output("#{bin}/circleci version").strip
(testpath/".circleci.yml").write("{version: 2.1}")
output = shell_output("#{bin}/circleci config pack #{testpath}/.circleci.yml")
assert_match "version: 2.1", output
# assert update is not included in output of help meaning it was not included in the build
assert_match "update This command is unavailable on your platform", shell_output("#{bin}/circleci help")
assert_match "`update` is not available because this tool was installed using `homebrew`.",
shell_output("#{bin}/circleci update")
end
end