faas-cli 0.5.0

- update ldflag for specifying the git commit in the version string
- install the template files in pkgshare
- update the test to verify
  - the templates installed in pkgshare work
  - the expected error is triggered when the templates are absent
  - the `template pull` command works
  - the `new --list` command works
- fix a bug in the test where the version string wasn't actually being
  checked for the git commit

Closes #20569.

Signed-off-by: ilovezfs <ilovezfs@icloud.com>
This commit is contained in:
ilovezfs 2017-11-12 13:55:48 -08:00
parent c121a16258
commit e602a24b3e

View file

@ -2,8 +2,8 @@ class FaasCli < Formula
desc "CLI for templating and/or deploying FaaS functions" desc "CLI for templating and/or deploying FaaS functions"
homepage "http://docs.get-faas.com/" homepage "http://docs.get-faas.com/"
url "https://github.com/openfaas/faas-cli.git", url "https://github.com/openfaas/faas-cli.git",
:tag => "0.4.31", :tag => "0.5.0",
:revision => "5eac30a84ce41603527cab8decb716f45eaeb40b" :revision => "91177ec27037eccaf6e827c265a0e452e772f1ab"
bottle do bottle do
cellar :any_skip_relocation cellar :any_skip_relocation
@ -20,9 +20,12 @@ class FaasCli < Formula
ENV["GOPATH"] = buildpath ENV["GOPATH"] = buildpath
(buildpath/"src/github.com/openfaas/faas-cli").install buildpath.children (buildpath/"src/github.com/openfaas/faas-cli").install buildpath.children
cd "src/github.com/openfaas/faas-cli" do cd "src/github.com/openfaas/faas-cli" do
commit = Utils.popen_read("git rev-list -1 HEAD").chomp project = "github.com/openfaas/faas-cli"
system "go", "build", "-ldflags", "-s -w -X github.com/openfaas/faas-cli/commands.GitCommit=#{commit}", "-a", commit = Utils.popen_read("git", "rev-parse", "HEAD").chomp
system "go", "build", "-ldflags",
"-s -w -X #{project}/version.GitCommit=#{commit}", "-a",
"-installsuffix", "cgo", "-o", bin/"faas-cli" "-installsuffix", "cgo", "-o", bin/"faas-cli"
pkgshare.install "template"
prefix.install_metafiles prefix.install_metafiles
end end
end end
@ -68,12 +71,25 @@ class FaasCli < Formula
EOS EOS
begin begin
cp_r pkgshare/"template", testpath
output = shell_output("#{bin}/faas-cli deploy -yaml test.yml") output = shell_output("#{bin}/faas-cli deploy -yaml test.yml")
assert_equal expected, output assert_equal expected, output
commit = Utils.popen_read("git rev-list -1 HEAD").chomp rm_rf "template"
output = shell_output("#{bin}/faas-cli version")
assert_match commit, output.chomp output = shell_output("#{bin}/faas-cli deploy -yaml test.yml 2>&1", 1)
assert_match "stat ./template/python/template.yml", output
assert_match "ruby", shell_output("#{bin}/faas-cli template pull 2>&1")
assert_match "node", shell_output("#{bin}/faas-cli new --list")
output = shell_output("#{bin}/faas-cli deploy -yaml test.yml")
assert_equal expected, output
stable_resource = stable.instance_variable_get(:@resource)
commit = stable_resource.instance_variable_get(:@specs)[:revision]
assert_match commit, shell_output("#{bin}/faas-cli version")
ensure ensure
Process.kill("TERM", pid) Process.kill("TERM", pid)
Process.wait(pid) Process.wait(pid)