|
| 1 | +class Miniflux < Formula |
| 2 | + desc "Minimalist and opinionated feed reader" |
| 3 | + homepage "https://miniflux.app" |
| 4 | + url "https://github.com/miniflux/v2/archive/refs/tags/2.2.8.tar.gz" |
| 5 | + sha256 "1c360012c3dd0202601db26755c511969b6c527f96d6829861a74095633a35c2" |
| 6 | + license "Apache-2.0" |
| 7 | + |
| 8 | + bottle do |
| 9 | + sha256 cellar: :any_skip_relocation, arm64_sequoia: "1e0d27dd1fef8dcdcd23598be51cc9819419419c84b62a62bf0b97d28db08b70" |
| 10 | + sha256 cellar: :any_skip_relocation, arm64_sonoma: "45f578e2d4597071549c305ffeced5dc3e364ff171c28d365d253ec891e32bcd" |
| 11 | + sha256 cellar: :any_skip_relocation, arm64_ventura: "042c119283d08ce163e03ed113287b3da869ec3c2f9dd9b29d553b2b2c9155ab" |
| 12 | + sha256 cellar: :any_skip_relocation, sonoma: "1697fb84642eeaed22e169595f8ae33fe18126d7d8121ad9278eaebff95b7137" |
| 13 | + sha256 cellar: :any_skip_relocation, ventura: "39e5e3f7701a0bb7dff79506a00c95958e79b0afd0c02f8c857cc3918e820305" |
| 14 | + sha256 cellar: :any_skip_relocation, x86_64_linux: "be8b87cc40ab4b80182e3041936b2cf60de72623149b6cd216f3e5eeeff2c592" |
| 15 | + end |
| 16 | + |
| 17 | + depends_on "go" => :build |
| 18 | + depends_on "postgresql@17" => :test |
| 19 | + |
| 20 | + def install |
| 21 | + ldflags = %W[ |
| 22 | + -s -w |
| 23 | + -X miniflux.app/v2/internal/version.Version=#{version} |
| 24 | + -X miniflux.app/v2/internal/version.Commit=#{tap.user} |
| 25 | + -X miniflux.app/v2/internal/version.BuildDate=#{time.iso8601} |
| 26 | + ] |
| 27 | + system "go", "build", *std_go_args(ldflags:) |
| 28 | + end |
| 29 | + |
| 30 | + service do |
| 31 | + run [opt_bin/"miniflux", "-c", etc/"miniflux.conf"] |
| 32 | + keep_alive true |
| 33 | + error_log_path var/"log/miniflux.log" |
| 34 | + log_path var/"log/miniflux.log" |
| 35 | + working_dir var |
| 36 | + end |
| 37 | + |
| 38 | + test do |
| 39 | + ENV["LC_ALL"] = "C" |
| 40 | + |
| 41 | + pg_port = free_port |
| 42 | + pg_bin = Formula["postgresql@17"].opt_bin |
| 43 | + pg_ctl = pg_bin/"pg_ctl" |
| 44 | + |
| 45 | + datadir = testpath/"postgres" |
| 46 | + system pg_ctl, "init", "-D", datadir |
| 47 | + |
| 48 | + (datadir/"postgresql.conf").write <<~EOS, mode: "a+" |
| 49 | + port = #{pg_port} |
| 50 | + unix_socket_directories = '#{datadir}' |
| 51 | + EOS |
| 52 | + |
| 53 | + system pg_ctl, "start", "-D", datadir, "-l", testpath/"postgres.log" |
| 54 | + begin |
| 55 | + system pg_bin/"createdb", "-h", datadir, "-p", pg_port.to_s, "miniflux_test" |
| 56 | + |
| 57 | + # Run Miniflux |
| 58 | + miniflux_port = free_port |
| 59 | + (testpath/"miniflux.conf").write <<~CONF |
| 60 | + DATABASE_URL=postgres://localhost:#{pg_port}/miniflux_test?sslmode=disable |
| 61 | + ADMIN_USERNAME=admin |
| 62 | + ADMIN_PASSWORD=test123 |
| 63 | + CREATE_ADMIN=1 |
| 64 | + RUN_MIGRATIONS=1 |
| 65 | + LOG_LEVEL=debug |
| 66 | + LISTEN_ADDR=127.0.0.1:#{miniflux_port} |
| 67 | + CONF |
| 68 | + |
| 69 | + miniflux_pid = spawn(bin/"miniflux", "-c", testpath/"miniflux.conf") |
| 70 | + begin |
| 71 | + sleep 2 |
| 72 | + assert_equal "OK", shell_output("curl -s http://127.0.0.1:#{miniflux_port}/healthcheck") |
| 73 | + ensure |
| 74 | + Process.kill "TERM", miniflux_pid |
| 75 | + Process.wait miniflux_pid |
| 76 | + end |
| 77 | + ensure |
| 78 | + system pg_ctl, "stop", "-D", datadir |
| 79 | + end |
| 80 | + end |
| 81 | +end |
0 commit comments