Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pilosa: Add build step that generates static media assets for WebUI #15311

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Formula/pilosa.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require "language/go"

class Pilosa < Formula
desc "Distributed bitmap index that queries across data sets"
homepage "https://www.pilosa.com"
Expand All @@ -15,13 +17,23 @@ class Pilosa < Formula
depends_on "go" => :build
depends_on "glide" => :build

go_resource "github.com/rakyll/statik" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be far preferable to use a Go vendor directory for this.

glide, govendor, godep, and dep are some good choices for managing a vendor directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pilosa already uses dep for library dependencies (recently switched from Glide). However, statik in this case is a binary dependency and is used as part of the build process (via go generate). As far as I'm aware, it is not possible to install a binary from a vendored dependency.

Here is a relevant ticket in the Glide issue tracker: Masterminds/glide#418

And here is an existing homebrew-core package that includes statik using the same method: https://github.com/Homebrew/homebrew-core/blob/master/Formula/aurora.rb

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be preferable to create a homebrew package for statik (similar to the glide one) and depend on it?

url "https://github.com/rakyll/statik.git",
:revision => "89fe3459b5c829c32e89bdff9c43f18aad728f2f"
end

def install
require "time"
ENV["GOPATH"] = buildpath
ENV["GLIDE_HOME"] = HOMEBREW_CACHE/"glide_home/#{name}"
mkdir_p buildpath/"src/github.com/pilosa/"
ln_s buildpath, buildpath/"src/github.com/pilosa/pilosa"
system "make", "pilosa", "FLAGS=-o #{bin}/pilosa", "VERSION=#{version}"
ENV.prepend_create_path "PATH", buildpath/"bin"
Language::Go.stage_deps resources, buildpath/"src"
cd "src/github.com/rakyll/statik" do
system "go", "install"
end
system "make", "generate-statik", "pilosa", "FLAGS=-o #{bin}/pilosa", "VERSION=#{version}"
end

plist_options :manual => "pilosa server"
Expand Down Expand Up @@ -59,6 +71,7 @@ def plist; <<-EOS.undent
end
sleep 0.5
assert_match("Welcome. Pilosa is running.", shell_output("curl localhost:10101"))
assert_match("<!DOCTYPE html>", shell_output("curl --user-agent NotCurl localhost:10101"))
ensure
Process.kill "TERM", server
Process.wait server
Expand Down