51 lines
2.2 KiB
Ruby
51 lines
2.2 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.5810",
|
|
:revision => "ac0d85fe5e85c0e49441c3803944614877f9ab77"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "95db8c7079e1b4b03b01bae1706e2e1c6ab4ea250f6175a913cea63978de7580" => :mojave
|
|
sha256 "c68a0e6d43cff8f8ff04afb096eb6693a9dfdde075c34565ef037e20d29316ec" => :high_sierra
|
|
sha256 "fd8499af5d05e005ebed6d20c9734d85cdf738f1804ec1d474008aa6ebca1950" => :sierra
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ENV["GOPATH"] = buildpath
|
|
ENV["GO111MODULE"] = "on"
|
|
|
|
dir = buildpath/"src/github.com/CircleCI-Public/circleci-cli"
|
|
dir.install buildpath.children
|
|
|
|
cd dir do
|
|
commit = Utils.popen_read("git rev-parse --short HEAD").chomp
|
|
ldflags = %W[
|
|
-s -w
|
|
-X github.com/CircleCI-Public/circleci-cli/cmd.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
|
|
# assert script fails because 2.1 config is not supported for local builds
|
|
(testpath/".circleci.yml").write("{version: 2.1}")
|
|
output = shell_output("#{bin}/circleci build -c #{testpath}/.circleci.yml 2>&1", 255)
|
|
assert_match "Local builds do not support that version at this time", 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
|