-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf81e7e
commit c15fde8
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
language: elixir | ||
|
||
elixir: | ||
- 1.7.4 | ||
- 1.8.1 | ||
|
||
otp_release: | ||
- 20.3 | ||
before_script: | ||
- if elixir -v | grep -q 1.8; then mix format --check-formatted; fi # only enforce formatting for Elixir ~> 1.8 | ||
|
||
script: | ||
- mix coveralls.safe_travis | ||
- mix credo --strict | ||
|
||
after_script: | ||
- MIX_ENV=test mix inch.report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
if Mix.env() == :test do | ||
defmodule Mix.Tasks.Coveralls.SafeTravis do | ||
@moduledoc false | ||
alias Mix.Tasks.Coveralls | ||
|
||
use Mix.Task | ||
|
||
@preferred_cli_env :test | ||
@shortdoc "A safe `coveralls.travis` variant that doesn't crash on failed upload." | ||
|
||
def run(args) do | ||
Coveralls.Travis.run(args) | ||
rescue | ||
e in ExCoveralls.ReportUploadError -> | ||
Mix.shell().error("Failed coveralls upload: #{Exception.message(e)}") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
defmodule Mix.Tasks.OpenStates.BuildTest do | ||
use ExUnit.Case | ||
import ExUnit.CaptureIO | ||
import Mock | ||
alias Mix.Tasks.{Coveralls, Coveralls.SafeTravis, Coveralls.Travis} | ||
alias Mix.Tasks.{Credo, Docs, Format, Inch, OpenStates.Build} | ||
|
||
describe "mix open_states.build" do | ||
test "runs build task" do | ||
with_mocks([ | ||
{Coveralls.Html, [], [run: fn _ -> nil end]}, | ||
{Credo, [], [run: fn _ -> nil end]}, | ||
{Docs, [], [run: fn _ -> nil end]}, | ||
{Inch, [], [run: fn _ -> nil end]} | ||
]) do | ||
Build.run(["--no-format"]) | ||
assert_called(Coveralls.Html.run([])) | ||
assert_called(Credo.run(["--strict"])) | ||
assert_called(Docs.run([])) | ||
assert_called(Inch.run([])) | ||
end | ||
end | ||
|
||
test "runs the formatter when Elixir >= 1.8" do | ||
if System.version() >= "1.8" do | ||
with_mock(Format, run: fn _ -> nil end) do | ||
assert capture_io(fn -> Build.run_formatter([]) end) | ||
|> String.contains?("Running formatter") | ||
|
||
assert_called(Format.run(["--check-equivalent"])) | ||
end | ||
else | ||
assert_raise RuntimeError, ~r/Elixir version must be >= 1.8/, fn -> | ||
Build.run_formatter([]) | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe "mix coveralls.safe_travis" do | ||
test "runs" do | ||
with_mock Travis, run: fn _ -> nil end do | ||
SafeTravis.run(["hello"]) | ||
assert_called(Travis.run(["hello"])) | ||
end | ||
end | ||
|
||
test "catches ExCoveralls.ReportUploadError" do | ||
with_mock Travis, run: fn _ -> raise ExCoveralls.ReportUploadError end do | ||
assert capture_io(:stderr, fn -> SafeTravis.run(["hello"]) end) | ||
end | ||
end | ||
end | ||
end |