From 25079eaba13a2267a9e22ee9b37f1c57d34b64fb Mon Sep 17 00:00:00 2001 From: Dave Long Date: Tue, 26 Sep 2017 09:04:12 -0400 Subject: [PATCH 1/2] Upgrades Elixir and dependencies --- lib/probe.ex | 4 +--- lib/probe/configuration.ex | 8 ++++---- lib/probe/event_manager.ex | 4 +--- lib/probe/json_log_handler.ex | 5 ++--- lib/probe/tolerant_file.ex | 7 ++----- mix.exs | 13 ++++++------- mix.lock | 21 +++++++++++---------- 7 files changed, 27 insertions(+), 35 deletions(-) diff --git a/lib/probe.ex b/lib/probe.ex index 87a8d12..287b5da 100644 --- a/lib/probe.ex +++ b/lib/probe.ex @@ -16,7 +16,5 @@ defmodule Probe do @doc """ Send an event to be logged. """ - def notify(event), - do: GenEvent.sync_notify(Probe.EventManager, event) - + def notify(event), do: GenEvent.sync_notify(Probe.EventManager, event) end diff --git a/lib/probe/configuration.ex b/lib/probe/configuration.ex index 3abd14d..5bfe83d 100644 --- a/lib/probe/configuration.ex +++ b/lib/probe/configuration.ex @@ -9,8 +9,9 @@ defmodule Probe.Configuration do Probe's logs (`:probe/:log_directory`). Defaults to `audit_logs` in the current directory. """ - def log_directory, - do: Path.absname(Application.get_env(:probe, :log_directory, "audit_logs")) + def log_directory do + Path.absname(Application.get_env(:probe, :log_directory, "audit_logs")) + end @doc """ Raises a `Probe.ConfigurationError` if the log directory exists and @@ -19,7 +20,7 @@ defmodule Probe.Configuration do Does _not_ perform any checks that the directory can be written to. """ def ensure_log_directory! do - dir = log_directory + dir = log_directory() if File.exists?(dir) do if File.dir?(dir) do :ok @@ -38,5 +39,4 @@ defmodule Probe.Configuration do Logger.info("Writing audit logs to the `#{dir}` directory") :ok end - end diff --git a/lib/probe/event_manager.ex b/lib/probe/event_manager.ex index ede2ce8..32e2112 100644 --- a/lib/probe/event_manager.ex +++ b/lib/probe/event_manager.ex @@ -1,14 +1,12 @@ defmodule Probe.EventManager do - @doc """ Starts the GenEvent manager and adds the `Probe.JSONLogHandler` to it. """ def start_link() do - Probe.Configuration.ensure_log_directory! + Probe.Configuration.ensure_log_directory!() {:ok, pid} = GenEvent.start_link(name: __MODULE__) :ok = GenEvent.add_handler(__MODULE__, Probe.JSONLogHandler, []) {:ok, pid} end - end diff --git a/lib/probe/json_log_handler.ex b/lib/probe/json_log_handler.ex index 2c765f0..173acb5 100644 --- a/lib/probe/json_log_handler.ex +++ b/lib/probe/json_log_handler.ex @@ -20,7 +20,7 @@ defmodule Probe.JSONLogHandler do defstruct [log_file: nil] def init(_) do - path = log_path + path = log_path() Logger.info("Attempting to open JSON-formatted event log file `#{path}`") case TolerantFile.open(path) do {:ok, file} -> @@ -55,7 +55,6 @@ defmodule Probe.JSONLogHandler do end end - defp log_path, - do: Path.join(Probe.Configuration.log_directory, @log_file) + defp log_path, do: Path.join(Probe.Configuration.log_directory, @log_file) end diff --git a/lib/probe/tolerant_file.ex b/lib/probe/tolerant_file.ex index a7608fe..c425b6f 100644 --- a/lib/probe/tolerant_file.ex +++ b/lib/probe/tolerant_file.ex @@ -79,8 +79,7 @@ defmodule Probe.TolerantFile do @doc """ Closes the underlying file descriptor of `file`. """ - def close(%__MODULE__{}=file), - do: File.close(file.fd) + def close(%__MODULE__{}=file), do: File.close(file.fd) @doc """ Appends `content` to `file`, respecting underlying file closings. A @@ -109,8 +108,7 @@ defmodule Probe.TolerantFile do end # Ensure unicode and intervening newlines - defp do_put(fd, content), - do: :file.write(fd, to_string(content <> "\n")) + defp do_put(fd, content), do: :file.write(fd, to_string(content <> "\n")) @doc """ Heuristically determine whether or not a TolerantFile still points @@ -131,5 +129,4 @@ defmodule Probe.TolerantFile do true end end - end diff --git a/mix.exs b/mix.exs index 43bd690..d539d60 100644 --- a/mix.exs +++ b/mix.exs @@ -4,14 +4,14 @@ defmodule Probe.Mixfile do def project do [app: :probe, version: "1.1.0", - elixir: "~> 1.3.1", + elixir: "~> 1.5.1", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, test_coverage: [tool: ExCoveralls], preferred_cli_env: ["coveralls": :test, "coveralls.html": :test, "coveralls.travis": :test], - deps: deps] + deps: deps()] end def application do @@ -20,10 +20,9 @@ defmodule Probe.Mixfile do end defp deps do - [{:poison, "~> 2.0"}, - {:ex_doc, "~> 0.13", only: :dev}, - {:earmark, "~> 1.0", only: :dev}, - {:mix_test_watch, "~> 0.2", only: :dev}, - {:excoveralls, "~> 0.6", only: :test}] + [{:poison, "~> 3.1"}, + {:ex_doc, "~> 0.16", only: :dev}, + {:earmark, "~> 1.2", only: :dev}, + {:excoveralls, "~> 0.7", only: :test}] end end diff --git a/mix.lock b/mix.lock index ef58af1..9966902 100644 --- a/mix.lock +++ b/mix.lock @@ -1,14 +1,15 @@ -%{"certifi": {:hex, :certifi, "1.0.0", "1c787a85b1855ba354f0b8920392c19aa1d06b0ee1362f9141279620a5be2039", [:rebar3], []}, - "earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [:mix], []}, - "ex_doc": {:hex, :ex_doc, "0.13.0", "aa2f8fe4c6136a2f7cfc0a7e06805f82530e91df00e2bff4b4362002b43ada65", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]}, - "excoveralls": {:hex, :excoveralls, "0.6.2", "0e993d096f1fbb6e70a3daced5c89aac066bda6bce57829622aa2d1e2b338cfb", [:mix], [{:exjsx, "~> 3.0", [hex: :exjsx, optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, optional: false]}]}, - "exjsx": {:hex, :exjsx, "3.2.1", "1bc5bf1e4fd249104178f0885030bcd75a4526f4d2a1e976f4b428d347614f0f", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, optional: false]}]}, +%{"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"}, + "earmark": {:hex, :earmark, "1.2.3", "206eb2e2ac1a794aa5256f3982de7a76bf4579ff91cb28d0e17ea2c9491e46a4", [:mix], [], "hexpm"}, + "ex_doc": {:hex, :ex_doc, "0.16.4", "4bf6b82d4f0a643b500366ed7134896e8cccdbab4d1a7a35524951b25b1ec9f0", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, + "excoveralls": {:hex, :excoveralls, "0.7.3", "6c05cc452e6ebfc347fccc0de7339e9bc1ed8678c52765353303fa0d2c44c70d", [:mix], [{:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, + "exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"}, "fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], []}, - "hackney": {:hex, :hackney, "1.7.1", "e238c52c5df3c3b16ce613d3a51c7220a784d734879b1e231c9babd433ac1cb4", [:rebar3], [{:certifi, "1.0.0", [hex: :certifi, optional: false]}, {:idna, "4.0.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]}, - "idna": {:hex, :idna, "4.0.0", "10aaa9f79d0b12cf0def53038547855b91144f1bfcc0ec73494f38bb7b9c4961", [:rebar3], []}, + "hackney": {:hex, :hackney, "1.9.0", "51c506afc0a365868469dcfc79a9d0b94d896ec741cfd5bd338f49a5ec515bfe", [:rebar3], [{:certifi, "2.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, + "idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, "jsx": {:hex, :jsx, "2.8.2", "7acc7d785b5abe8a6e9adbde926a24e481f29956dd8b4df49e3e4e7bcc92a018", [:mix, :rebar3], []}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], []}, "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []}, - "mix_test_watch": {:hex, :mix_test_watch, "0.2.6", "9fcc2b1b89d1594c4a8300959c19d50da2f0ff13642c8f681692a6e507f92cab", [:mix], [{:fs, "~> 0.9.1", [hex: :fs, optional: false]}]}, - "poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []}} + "mix_test_watch": {:hex, :mix_test_watch, "0.5.0", "2c322d119a4795c3431380fca2bca5afa4dc07324bd3c0b9f6b2efbdd99f5ed3", [:mix], [{:fs, "~> 0.9.1", [hex: :fs, repo: "hexpm", optional: false]}], "hexpm"}, + "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [], [], "hexpm"}} From 7343b6a2ecf9fd7867d462264cbfc2f07f88394b Mon Sep 17 00:00:00 2001 From: Dave Long Date: Tue, 26 Sep 2017 15:47:49 -0400 Subject: [PATCH 2/2] Fixes Travis build --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9af3b07..5b0ef17 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,14 @@ -sudo: required - -services: - - docker +language: elixir +elixir: + - 1.5.1 +otp_release: + - 20.0 before_install: - - docker build -t operable/probe-testing -f Dockerfile.ci . - -# Need the job ID in order to upload the Coveralls data + - mix do local.hex --force, local.rebar --force + - MIX_ENV=test mix deps.get script: - - docker run -it --rm --env="TRAVIS_JOB_ID=${TRAVIS_JOB_ID}" operable/probe-testing mix coveralls.travis + - "MIX_ENV=test mix coveralls.travis" notifications: slack: