diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9065d4d..55a523a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,13 +16,15 @@ jobs: fail-fast: false matrix: os: - - macos-latest # amd64 - - macos-latest-xlarge # arm64 + - macos-13 # amd64 + - macos-latest # arm64 product: - cockroach - cockroach@23.1 - cockroach@23.2 - cockroach@24.1 + - cockroach@24.2 + - cockroach@24.3 - cockroach-sql - ccloud name: ${{ matrix.product }} formula tests (${{ matrix.os }}) diff --git a/Formula/cockroach-sql.rb b/Formula/cockroach-sql.rb index f1ff2fd..d9ad187 100644 --- a/Formula/cockroach-sql.rb +++ b/Formula/cockroach-sql.rb @@ -19,7 +19,7 @@ class CockroachSql < Formula def install bin.install "cockroach-sql" prefix.install "LICENSE" if File.exist?("LICENSE") - prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") + prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") prefix.install "THIRD-PARTY-NOTICES.txt" end diff --git a/Formula/cockroach.rb b/Formula/cockroach.rb index c0a141d..f6fe52a 100644 --- a/Formula/cockroach.rb +++ b/Formula/cockroach.rb @@ -19,7 +19,7 @@ class Cockroach < Formula def install bin.install "cockroach" prefix.install "LICENSE" if File.exist?("LICENSE") - prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") + prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") prefix.install "THIRD-PARTY-NOTICES.txt" on_intel do lib.mkpath diff --git a/Formula/cockroach@23.1.rb b/Formula/cockroach@23.1.rb index 5dd8742..79f27e7 100644 --- a/Formula/cockroach@23.1.rb +++ b/Formula/cockroach@23.1.rb @@ -19,7 +19,7 @@ class CockroachAT231 < Formula def install bin.install "cockroach" prefix.install "LICENSE" if File.exist?("LICENSE") - prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") + prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") prefix.install "THIRD-PARTY-NOTICES.txt" on_intel do lib.mkpath diff --git a/Formula/cockroach@23.2.rb b/Formula/cockroach@23.2.rb index d8942e4..e3afcc5 100644 --- a/Formula/cockroach@23.2.rb +++ b/Formula/cockroach@23.2.rb @@ -19,7 +19,7 @@ class CockroachAT232 < Formula def install bin.install "cockroach" prefix.install "LICENSE" if File.exist?("LICENSE") - prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") + prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") prefix.install "THIRD-PARTY-NOTICES.txt" on_intel do lib.mkpath diff --git a/Formula/cockroach@24.1.rb b/Formula/cockroach@24.1.rb index 255f40d..43b2e95 100644 --- a/Formula/cockroach@24.1.rb +++ b/Formula/cockroach@24.1.rb @@ -19,7 +19,7 @@ class CockroachAT241 < Formula def install bin.install "cockroach" prefix.install "LICENSE" if File.exist?("LICENSE") - prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") + prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") prefix.install "THIRD-PARTY-NOTICES.txt" on_intel do lib.mkpath diff --git a/Formula/cockroach@24.2.rb b/Formula/cockroach@24.2.rb new file mode 100644 index 0000000..17b2a6b --- /dev/null +++ b/Formula/cockroach@24.2.rb @@ -0,0 +1,135 @@ +# Auto-generated file, DO NOT EDIT +# Source: release/cockroach-tmpl.rb + +class CockroachAT242 < Formula + desc "Distributed SQL database" + homepage "https://www.cockroachlabs.com" + version "24.2.5" + on_macos do + on_intel do + url "https://binaries.cockroachdb.com/cockroach-v24.2.5.darwin-10.9-amd64.tgz" + sha256 "ad9188fb6d05051512562681b6a78acef54c40ff828adf50f4345e6badbb8040" + end + on_arm do + url "https://binaries.cockroachdb.com/cockroach-v24.2.5.darwin-11.0-arm64.tgz" + sha256 "44fd6376d051e669a0b84db41ec70d5fdafbb679152c2d79588a5ffc9592125d" + end + end + + def install + bin.install "cockroach" + prefix.install "LICENSE" if File.exist?("LICENSE") + prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") + prefix.install "THIRD-PARTY-NOTICES.txt" + on_intel do + lib.mkpath + mkdir "#{lib}/cockroach" + lib.install "lib/libgeos.dylib" => "cockroach/libgeos.dylib" + lib.install "lib/libgeos_c.dylib" => "cockroach/libgeos_c.dylib" + + # Brew sets rpaths appropriately, but only if the rpaths are set + # to not include "@rpath". As such, use the #{lib} location for the + # rpaths. + system "install_name_tool", "-id", + "#{lib}/cockroach/libgeos.dylib", "#{lib}/cockroach/libgeos.dylib" + system "install_name_tool", "-id", + "#{lib}/cockroach/libgeos_c.1.dylib", "#{lib}/cockroach/libgeos_c.dylib" + if version < Version::new("23.2.0") + system "install_name_tool", "-change", + "@rpath/libgeos.3.8.1.dylib", "#{lib}/cockroach/libgeos.dylib", + "#{lib}/cockroach/libgeos_c.dylib" + else + system "install_name_tool", "-change", + "@rpath/libgeos.3.11.2.dylib", "#{lib}/cockroach/libgeos.dylib", + "#{lib}/cockroach/libgeos_c.dylib" + end + end + + system "#{bin}/cockroach", "gen", "man", "--path=#{man1}" + + bash_completion.mkpath + system "#{bin}/cockroach", "gen", "autocomplete", "bash", "--out=#{bash_completion}/cockroach" + + zsh_completion.mkpath + system "#{bin}/cockroach", "gen", "autocomplete", "zsh", "--out=#{zsh_completion}/_cockroach" + end + + def caveats; <<~EOS + For local development only, this formula ships a launchd configuration to + start a single-node cluster that stores its data under: + #{var}/cockroach/ + Instead of the default port of 8080, the node serves its admin UI at: + #{Formatter.url("http://localhost:26256")} + + Do NOT use this cluster to store data you care about; it runs in insecure + mode and may expose data publicly in e.g. a DNS rebinding attack. To run + CockroachDB securely, please see: + #{Formatter.url("https://www.cockroachlabs.com/docs/stable/secure-a-cluster.html")} + EOS + end + + service do + args = [ + "start-single-node", + "--store=#{var}/cockroach", + "--http-port=26256", + "--insecure", + "--host=localhost", + ] + if !(OS.mac? && Hardware::CPU.arm?) + args << "--spatial-libs=#{opt_bin}/../lib/cockroach" + end + run [opt_bin/"cockroach"] + args + working_dir var + keep_alive true + log_path var/"log/cockroach.log" + error_log_path var/"log/cockroach.err" + end + + test do + begin + # Redirect stdout and stderr to a file, or else `brew test --verbose` + # will hang forever as it waits for stdout and stderr to close. + pid = fork do + exec "#{bin}/cockroach start-single-node --insecure --background --listen-addr=127.0.0.1:0 --http-addr=127.0.0.1:0 --listening-url-file=listen_url_fifo &> start.out" + end + sleep 20 + + # TODO(bdarnell): remove the X from this variable and the --url flags after + # https://github.com/cockroachdb/cockroach/issues/40747 is fixed. + ENV["XCOCKROACH_URL"] = File.read("listen_url_fifo").strip + pipe_output("#{bin}/cockroach sql --url=$XCOCKROACH_URL", <<~EOS) + CREATE DATABASE bank; + CREATE TABLE bank.accounts (id INT PRIMARY KEY, balance DECIMAL); + INSERT INTO bank.accounts VALUES (1, 1000.50); + EOS + output = pipe_output("#{bin}/cockroach sql --url=$XCOCKROACH_URL --format=csv", + "SELECT * FROM bank.accounts;") + assert_equal <<~EOS, output + id,balance + 1,1000.50 + EOS + if !(OS.mac? && Hardware::CPU.arm?) + output = pipe_output("#{bin}/cockroach sql --url=$XCOCKROACH_URL --format=csv", + "SELECT ST_IsValid(ST_MakePoint(1, 1)) is_valid;") + assert_equal <<~EOS, output + is_valid + t + EOS + end + rescue => e + # If an error occurs, attempt to print out any messages from the + # server. + begin + $stderr.puts "server messages:", File.read("start.out") + rescue + $stderr.puts "unable to load messages from start.out" + end + raise e + ensure + Process.kill("SIGINT", pid) + Process.wait(pid) + end + end +end + diff --git a/Formula/cockroach@24.3.rb b/Formula/cockroach@24.3.rb new file mode 100644 index 0000000..2ec777d --- /dev/null +++ b/Formula/cockroach@24.3.rb @@ -0,0 +1,135 @@ +# Auto-generated file, DO NOT EDIT +# Source: release/cockroach-tmpl.rb + +class CockroachAT243 < Formula + desc "Distributed SQL database" + homepage "https://www.cockroachlabs.com" + version "24.3.0" + on_macos do + on_intel do + url "https://binaries.cockroachdb.com/cockroach-v24.3.0.darwin-10.9-amd64.tgz" + sha256 "93979ffaa09aaf84f4c9f1f5d55cf6cd06f83aa228a50aba4174e3ee1c680aab" + end + on_arm do + url "https://binaries.cockroachdb.com/cockroach-v24.3.0.darwin-11.0-arm64.tgz" + sha256 "d34882ce15289948d4794542fc2bb402ce373d812ca5d8ef4624220c4bec9c7d" + end + end + + def install + bin.install "cockroach" + prefix.install "LICENSE" if File.exist?("LICENSE") + prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") + prefix.install "THIRD-PARTY-NOTICES.txt" + on_intel do + lib.mkpath + mkdir "#{lib}/cockroach" + lib.install "lib/libgeos.dylib" => "cockroach/libgeos.dylib" + lib.install "lib/libgeos_c.dylib" => "cockroach/libgeos_c.dylib" + + # Brew sets rpaths appropriately, but only if the rpaths are set + # to not include "@rpath". As such, use the #{lib} location for the + # rpaths. + system "install_name_tool", "-id", + "#{lib}/cockroach/libgeos.dylib", "#{lib}/cockroach/libgeos.dylib" + system "install_name_tool", "-id", + "#{lib}/cockroach/libgeos_c.1.dylib", "#{lib}/cockroach/libgeos_c.dylib" + if version < Version::new("23.2.0") + system "install_name_tool", "-change", + "@rpath/libgeos.3.8.1.dylib", "#{lib}/cockroach/libgeos.dylib", + "#{lib}/cockroach/libgeos_c.dylib" + else + system "install_name_tool", "-change", + "@rpath/libgeos.3.11.2.dylib", "#{lib}/cockroach/libgeos.dylib", + "#{lib}/cockroach/libgeos_c.dylib" + end + end + + system "#{bin}/cockroach", "gen", "man", "--path=#{man1}" + + bash_completion.mkpath + system "#{bin}/cockroach", "gen", "autocomplete", "bash", "--out=#{bash_completion}/cockroach" + + zsh_completion.mkpath + system "#{bin}/cockroach", "gen", "autocomplete", "zsh", "--out=#{zsh_completion}/_cockroach" + end + + def caveats; <<~EOS + For local development only, this formula ships a launchd configuration to + start a single-node cluster that stores its data under: + #{var}/cockroach/ + Instead of the default port of 8080, the node serves its admin UI at: + #{Formatter.url("http://localhost:26256")} + + Do NOT use this cluster to store data you care about; it runs in insecure + mode and may expose data publicly in e.g. a DNS rebinding attack. To run + CockroachDB securely, please see: + #{Formatter.url("https://www.cockroachlabs.com/docs/stable/secure-a-cluster.html")} + EOS + end + + service do + args = [ + "start-single-node", + "--store=#{var}/cockroach", + "--http-port=26256", + "--insecure", + "--host=localhost", + ] + if !(OS.mac? && Hardware::CPU.arm?) + args << "--spatial-libs=#{opt_bin}/../lib/cockroach" + end + run [opt_bin/"cockroach"] + args + working_dir var + keep_alive true + log_path var/"log/cockroach.log" + error_log_path var/"log/cockroach.err" + end + + test do + begin + # Redirect stdout and stderr to a file, or else `brew test --verbose` + # will hang forever as it waits for stdout and stderr to close. + pid = fork do + exec "#{bin}/cockroach start-single-node --insecure --background --listen-addr=127.0.0.1:0 --http-addr=127.0.0.1:0 --listening-url-file=listen_url_fifo &> start.out" + end + sleep 20 + + # TODO(bdarnell): remove the X from this variable and the --url flags after + # https://github.com/cockroachdb/cockroach/issues/40747 is fixed. + ENV["XCOCKROACH_URL"] = File.read("listen_url_fifo").strip + pipe_output("#{bin}/cockroach sql --url=$XCOCKROACH_URL", <<~EOS) + CREATE DATABASE bank; + CREATE TABLE bank.accounts (id INT PRIMARY KEY, balance DECIMAL); + INSERT INTO bank.accounts VALUES (1, 1000.50); + EOS + output = pipe_output("#{bin}/cockroach sql --url=$XCOCKROACH_URL --format=csv", + "SELECT * FROM bank.accounts;") + assert_equal <<~EOS, output + id,balance + 1,1000.50 + EOS + if !(OS.mac? && Hardware::CPU.arm?) + output = pipe_output("#{bin}/cockroach sql --url=$XCOCKROACH_URL --format=csv", + "SELECT ST_IsValid(ST_MakePoint(1, 1)) is_valid;") + assert_equal <<~EOS, output + is_valid + t + EOS + end + rescue => e + # If an error occurs, attempt to print out any messages from the + # server. + begin + $stderr.puts "server messages:", File.read("start.out") + rescue + $stderr.puts "unable to load messages from start.out" + end + raise e + ensure + Process.kill("SIGINT", pid) + Process.wait(pid) + end + end +end + diff --git a/release/cockroach-sql-tmpl.rb b/release/cockroach-sql-tmpl.rb index 0c3399e..a3e8291 100644 --- a/release/cockroach-sql-tmpl.rb +++ b/release/cockroach-sql-tmpl.rb @@ -19,7 +19,7 @@ class CockroachSql < Formula def install bin.install "cockroach-sql" prefix.install "LICENSE" if File.exist?("LICENSE") - prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") + prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") prefix.install "THIRD-PARTY-NOTICES.txt" end diff --git a/release/cockroach-tmpl.rb b/release/cockroach-tmpl.rb index 68f7ddc..9ff08e4 100644 --- a/release/cockroach-tmpl.rb +++ b/release/cockroach-tmpl.rb @@ -19,7 +19,7 @@ class Cockroach{{ .ClassSuffix }} < Formula def install bin.install "cockroach" prefix.install "LICENSE" if File.exist?("LICENSE") - prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") + prefix.install "LICENSE.txt" if File.exist?("LICENSE.txt") prefix.install "THIRD-PARTY-NOTICES.txt" on_intel do lib.mkpath