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

Upgrades Elixir and dependencies #100

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
sudo: required

services:
- docker
language: elixir
elixir:
- 1.5.1
otp_release:
- 20.0

before_install:
- docker build -t operable/spanner-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/spanner-testing mix coveralls.travis
- "MIX_ENV=test mix coveralls.travis"

notifications:
slack:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM operable/elixir:1.3.4-r0
FROM elixir:1.5

COPY mix.exs mix.lock /code/
WORKDIR /code
Expand Down
8 changes: 4 additions & 4 deletions lib/spanner/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ defmodule Spanner.Config do

@doc "Return all config files in directory via `Path.wildcard/1`"
def find_configs(base_dir) do
extensions = Enum.join(config_extensions, ",")
Path.wildcard("#{base_dir}/#{config_file_name}{#{extensions}}")
extensions = Enum.join(config_extensions(), ",")
Path.wildcard("#{base_dir}/#{config_file_name()}{#{extensions}}")
end

@doc "Determine if a given path points to a config file"
def config_file?(filename) do
String.ends_with?(filename, Enum.map(config_extensions, &("#{@config_file}#{&1}")))
String.ends_with?(filename, Enum.map(config_extensions(), &("#{@config_file}#{&1}")))
end

@doc "Determine if a given path points to a file with a valid config extension"
def config_extension?(filename) do
String.ends_with?(filename, Enum.map(config_extensions, &("#{&1}")))
String.ends_with?(filename, Enum.map(config_extensions(), &("#{&1}")))
end

@doc """
Expand Down
10 changes: 5 additions & 5 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ defmodule Spanner.Mixfile do
def project do
[app: :spanner,
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
Expand All @@ -20,10 +20,10 @@ defmodule Spanner.Mixfile do
end

defp deps do
[{:piper, github: "operable/piper"},
{:yaml_elixir, "~> 1.2"},
[{:piper, github: "davejlong/piper", branch: "elixir-upgrade"},
{:yaml_elixir, "~> 1.3"},
{:ex_json_schema, "~> 0.5"},

{:excoveralls, "~> 0.6", only: :test}]
{:excoveralls, "~> 0.7", only: :test}]
end
end
19 changes: 10 additions & 9 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
%{"certifi": {:hex, :certifi, "1.0.0", "1c787a85b1855ba354f0b8920392c19aa1d06b0ee1362f9141279620a5be2039", [:rebar3], []},
%{"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"},
"ex_json_schema": {:hex, :ex_json_schema, "0.5.1", "83356e5a673d6fbe75da612a44b8f84942711630414d8be5e342f3597b03939a", [:mix], []},
"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]}]},
"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], []},
"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"},
"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], []},
"piper": {:git, "https://github.com/operable/piper.git", "d69e4596cd338ab00d90e4ea6831eff11d0572c0", []},
"poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []},
"piper": {:git, "https://github.com/davejlong/piper.git", "5659aefc3cf79dd70a8326cf44ed0302730d5fce", [branch: "elixir-upgrade"]},
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [], [], "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"},
"uuid": {:hex, :uuid, "1.1.5", "96cb36d86ee82f912efea4d50464a5df606bf3f1163d6bdbb302d98474969369", [:mix], []},
"yamerl": {:hex, :yamerl, "0.3.2", "9eac1537d251e926f47763ab1db0d9e6e8f2397646c290d58aa6ceebc6832fb7", [:rebar3], []},
"yaml_elixir": {:hex, :yaml_elixir, "1.2.1", "4a8ee3b25598100c710ff11dde4d79b6335608ac092d69aab45cc7475b5abc4d", [:mix], [{:yamerl, "~> 0.3.2", [hex: :yamerl, optional: false]}]}}
"yamerl": {:hex, :yamerl, "0.5.0", "6ec55a5d830f6f0d65a4030f5c5db24b0e72b813dfbde32fea44b4951ed9417c", [:rebar3], [], "hexpm"},
"yaml_elixir": {:hex, :yaml_elixir, "1.3.1", "b84b6333343b0cba176c43c463e622f838825e7476e35334f719b83df4535bff", [:mix], [{:yamerl, "~> 0.5", [hex: :yamerl, repo: "hexpm", optional: false]}], "hexpm"}}
30 changes: 15 additions & 15 deletions test/spanner/config/v4_validator_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -45,63 +45,63 @@ defmodule Spanner.Config.V4ValidatorTest do
end

test "minimal config" do
assert validate(minimal_config) == :ok
assert validate(minimal_config()) == :ok
end

test "bad bundle versions" do
updated = put_in(minimal_config, ["version"], "1")
updated = put_in(minimal_config(), ["version"], "1")
assert validate(updated) == {:error, [{"String \"1\" does not match pattern \"^\\\\d+\\\\.\\\\d+($|\\\\.\\\\d+$)\".", "#/version"}], []}
updated = put_in(minimal_config, ["version"], "0.0.1-beta")
updated = put_in(minimal_config(), ["version"], "0.0.1-beta")
assert validate(updated) == {:error, [{"String \"0.0.1-beta\" does not match pattern \"^\\\\d+\\\\.\\\\d+($|\\\\.\\\\d+$)\".", "#/version"}], []}
end

test "wrong cog_bundle_version" do
result = update_in(minimal_config, ["cog_bundle_version"], fn(_) -> 1 end)
result = update_in(minimal_config(), ["cog_bundle_version"], fn(_) -> 1 end)
|> validate
assert result == {:error, [{"cog_bundle_version 1 is not supported. Please update your bundle config to version #{Spanner.Config.current_config_version}.", "#/cog_bundle_version"}], []}
end

test "missing cog_bundle_version" do
result = Map.delete(minimal_config, "cog_bundle_version") |> validate
result = Map.delete(minimal_config(), "cog_bundle_version") |> validate
assert result == {:error, [{"cog_bundle_version not specified. You must specify a valid bundle version. The current version is #{Spanner.Config.current_config_version}.", "#/cog_bundle_version"}], []}
end

test "incomplete rules" do
assert validate(incomplete_rules_config) == :ok
assert validate(incomplete_rules_config()) == :ok
end

test "rules are fixed up" do
{:ok, config} = Spanner.Config.validate(incomplete_rules_config)
{:ok, config} = Spanner.Config.validate(incomplete_rules_config())
[rule] = get_in(config, ["commands", "bar", "rules"])
assert String.starts_with?(rule, "when command is foo:bar")
end

test "errors when permissions don't match rules" do
rules = ["when command is foo:date must have foo:view"]
config = put_in(minimal_config, ["commands", "date", "rules"], rules)
config = put_in(minimal_config(), ["commands", "date", "rules"], rules)
response = validate(config)

assert response == {:error, [{"The permission 'foo:view' is not in the list of permissions.", "#/commands/date/rules/0"}], []}
end

test "errors on bad rule" do
rules = ["when command is foo:bar must have permission == foo:baz"]
config = put_in(minimal_config, ["commands", "date", "rules"], rules)
config = put_in(minimal_config(), ["commands", "date", "rules"], rules)

response = validate(config)

assert response == {:error, [{"(Line: 1, Col: 34) References to permissions must be the literal \"allow\" or start with a command bundle name or \"site\".", "#/commands/date/rules/0"}], []}
end

test "rules are required" do
config = update_in(minimal_config, ["commands", "date"], &Map.delete(&1, "rules"))
config = update_in(minimal_config(), ["commands", "date"], &Map.delete(&1, "rules"))
|> validate
assert config == {:error, [{"Required property rules was not present.", "#/commands/date"}], []}
end

test "errors on bad command option type" do
options = %{"option_1" => %{"type" => "integer", "required" => false}}
config = put_in(minimal_config, ["commands", "date", "options"], options)
config = put_in(minimal_config(), ["commands", "date", "options"], options)
response = validate(config)

assert response == {:error, [{"Value \"integer\" is not allowed in enum.", "#/commands/date/options/option_1/type"}], []}
Expand All @@ -111,7 +111,7 @@ defmodule Spanner.Config.V4ValidatorTest do
Enum.each(["string", true, 4], fn(type) ->
test "env_vars can be a #{type}" do
env_var = %{"env1" => unquote(type)}
config = put_in(minimal_config, ["commands", "date", "env_vars"], env_var)
config = put_in(minimal_config(), ["commands", "date", "env_vars"], env_var)

response = validate(config)
assert response == :ok
Expand All @@ -124,20 +124,20 @@ defmodule Spanner.Config.V4ValidatorTest do
test "templates are validated" do
templates = %{"blah" => %{"body" => "blahblah"},
"foo" => %{"body" => "foofoo"}}
config = put_in(minimal_config, ["templates"], templates)
config = put_in(minimal_config(), ["templates"], templates)
assert :ok == validate(config)
end

test "errors on bad template format" do
templates = %{"foo" => "Some template"}
config = put_in(minimal_config, ["templates"], templates)
config = put_in(minimal_config(), ["templates"], templates)
response = validate(config)
assert {:error, [{"Type mismatch. Expected Object but got String.", "#/templates/foo"}], []} == response
end

test "templates must have proper names" do
templates = %{"1?" => %{"body" => "Some template"}}
config = put_in(minimal_config, ["templates"], templates)
config = put_in(minimal_config(), ["templates"], templates)
response = validate(config)

# Not the greatest error message for this, sadly :(
Expand Down
30 changes: 15 additions & 15 deletions test/spanner/config/v5_validator_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -47,63 +47,63 @@ defmodule Spanner.Config.V5ValidatorTest do
end

test "minimal config" do
assert validate(minimal_config) == :ok
assert validate(minimal_config()) == :ok
end

test "bad bundle versions" do
updated = put_in(minimal_config, ["version"], "1")
updated = put_in(minimal_config(), ["version"], "1")
assert validate(updated) == {:error, [{"String \"1\" does not match pattern \"^\\\\d+\\\\.\\\\d+($|\\\\.\\\\d+$)\".", "#/version"}], []}
updated = put_in(minimal_config, ["version"], "0.0.1-beta")
updated = put_in(minimal_config(), ["version"], "0.0.1-beta")
assert validate(updated) == {:error, [{"String \"0.0.1-beta\" does not match pattern \"^\\\\d+\\\\.\\\\d+($|\\\\.\\\\d+$)\".", "#/version"}], []}
end

test "wrong cog_bundle_version" do
result = update_in(minimal_config, ["cog_bundle_version"], fn(_) -> 1 end)
result = update_in(minimal_config(), ["cog_bundle_version"], fn(_) -> 1 end)
|> validate
assert result == {:error, [{"cog_bundle_version 1 is not supported. Please update your bundle config to version #{Spanner.Config.current_config_version()}.", "#/cog_bundle_version"}], []}
end

test "missing cog_bundle_version" do
result = Map.delete(minimal_config, "cog_bundle_version") |> validate
result = Map.delete(minimal_config(), "cog_bundle_version") |> validate
assert result == {:error, [{"cog_bundle_version not specified. You must specify a valid bundle version. The current version is #{Spanner.Config.current_config_version()}.", "#/cog_bundle_version"}], []}
end

test "incomplete rules" do
assert validate(incomplete_rules_config) == :ok
assert validate(incomplete_rules_config()) == :ok
end

test "rules are fixed up" do
{:ok, config} = Spanner.Config.validate(incomplete_rules_config)
{:ok, config} = Spanner.Config.validate(incomplete_rules_config())
[rule] = get_in(config, ["commands", "bar", "rules"])
assert String.starts_with?(rule, "when command is foo:bar")
end

test "errors when permissions don't match rules" do
rules = ["when command is foo:date must have foo:view"]
config = put_in(minimal_config, ["commands", "date", "rules"], rules)
config = put_in(minimal_config(), ["commands", "date", "rules"], rules)
response = validate(config)

assert response == {:error, [{"The permission 'foo:view' is not in the list of permissions.", "#/commands/date/rules/0"}], []}
end

test "errors on bad rule" do
rules = ["when command is foo:bar must have permission == foo:baz"]
config = put_in(minimal_config, ["commands", "date", "rules"], rules)
config = put_in(minimal_config(), ["commands", "date", "rules"], rules)

response = validate(config)

assert response == {:error, [{"(Line: 1, Col: 34) References to permissions must be the literal \"allow\" or start with a command bundle name or \"site\".", "#/commands/date/rules/0"}], []}
end

test "rules are required" do
config = update_in(minimal_config, ["commands", "date"], &Map.delete(&1, "rules"))
config = update_in(minimal_config(), ["commands", "date"], &Map.delete(&1, "rules"))
|> validate
assert config == {:error, [{"Required property rules was not present.", "#/commands/date"}], []}
end

test "errors on bad command option type" do
options = %{"option_1" => %{"type" => "integer", "required" => false}}
config = put_in(minimal_config, ["commands", "date", "options"], options)
config = put_in(minimal_config(), ["commands", "date", "options"], options)
response = validate(config)

assert response == {:error, [{"Value \"integer\" is not allowed in enum.", "#/commands/date/options/option_1/type"}], []}
Expand All @@ -113,7 +113,7 @@ defmodule Spanner.Config.V5ValidatorTest do
Enum.each(["string", true, 4], fn(type) ->
test "env_vars can be a #{type}" do
env_var = %{"env1" => unquote(type)}
config = put_in(minimal_config, ["commands", "date", "env_vars"], env_var)
config = put_in(minimal_config(), ["commands", "date", "env_vars"], env_var)

response = validate(config)
assert response == :ok
Expand All @@ -126,20 +126,20 @@ defmodule Spanner.Config.V5ValidatorTest do
test "templates are validated" do
templates = %{"blah" => %{"body" => "blahblah"},
"foo" => %{"body" => "foofoo"}}
config = put_in(minimal_config, ["templates"], templates)
config = put_in(minimal_config(), ["templates"], templates)
assert :ok == validate(config)
end

test "errors on bad template format" do
templates = %{"foo" => "Some template"}
config = put_in(minimal_config, ["templates"], templates)
config = put_in(minimal_config(), ["templates"], templates)
response = validate(config)
assert {:error, [{"Type mismatch. Expected Object but got String.", "#/templates/foo"}], []} == response
end

test "templates must have proper names" do
templates = %{"1?" => %{"body" => "Some template"}}
config = put_in(minimal_config, ["templates"], templates)
config = put_in(minimal_config(), ["templates"], templates)
response = validate(config)

# Not the greatest error message for this, sadly :(
Expand Down