-
-
Notifications
You must be signed in to change notification settings - Fork 12.4k
/
circleci.rb
50 lines (44 loc) · 2.13 KB
/
circleci.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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.6648",
:revision => "8e35edbd77390a4b99238f739be905841df98df4"
bottle do
cellar :any_skip_relocation
sha256 "85b05d15b7bdd086d7b5b3404be93b99e76006f2e535e78dedaaf54e99999b28" => :catalina
sha256 "362645bf11b14e68ca4b9c5788dc7d2dd1d95d28c391f060ac491162a68cae30" => :mojave
sha256 "99bc8e083af8cb9cbf62b13acc84b5b9ad01f03c253774b0cfe7cccd66ea38ee" => :high_sierra
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.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