Skip to content

Commit b045b89

Browse files
rjanjabrienw
authored andcommitted
Add CircleCI workflow; update coveralls, dialyxir (#261)
1 parent d8a701f commit b045b89

File tree

10 files changed

+136
-52
lines changed

10 files changed

+136
-52
lines changed

.circleci/config.yml

+83-12
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,116 @@ general:
33
branches:
44
ignore:
55
- gh-pages
6+
defaults: &defaults
7+
working_directory: ~/bootleg
68
jobs:
79
build:
8-
machine: true
9-
working_directory: ~/bootleg
10+
<<: *defaults
11+
parallelism: 1 # run only one instance of this job in parallel
12+
docker: # run the steps with Docker
13+
- image: circleci/elixir:1.6
14+
environment: # environment variables for primary container
15+
SHELL: /bin/bash
1016
steps:
1117
- checkout
12-
- run: echo 'export INSTALL_PATH="$HOME/dependencies";export PATH="$INSTALL_PATH/bin:$PATH";export MIX_ENV=test;export VERSION_CIRCLECI=2' >> $BASH_ENV
18+
19+
- run: mix local.hex --force
20+
- run: mix local.rebar --force
21+
22+
- restore_cache: # restores saved mix cache
23+
keys: # list of cache keys, in decreasing specificity
24+
- mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
25+
- mix-cache-{{ .Branch }}
26+
- mix-cache
27+
- restore_cache: # restores saved build cache
28+
keys:
29+
- build-cache-{{ .Branch }}
30+
- build-cache
31+
- restore_cache: # restores saved plt cache
32+
keys:
33+
- dialyzer-cache
34+
35+
- run: mix do deps.get, deps.compile # get updated dependencies & compile them
36+
37+
- save_cache: # generate and store cache so `restore_cache` works
38+
key: mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
39+
paths: "deps"
40+
- save_cache: # make another less specific cache
41+
key: mix-cache-{{ .Branch }}
42+
paths: "deps"
43+
- save_cache: # and one more build cache for good measure
44+
key: mix-cache
45+
paths: "deps"
46+
47+
- run: mix compile
48+
49+
- save_cache: # save a *build* cache, too
50+
key: build-cache-{{ .Branch }}
51+
paths: "_build"
52+
- save_cache: # and one more build cache for good measure
53+
key: build-cache
54+
paths: "_build"
55+
56+
- run: mix do format --check-formatted, credo --strict
57+
- run: mix test --exclude functional
58+
- run: mix dialyzer --halt-exit-status
59+
60+
- save_cache:
61+
key: dialyzer-cache
62+
paths: "_build/test/dialyxir*.plt"
63+
64+
- store_test_results:
65+
path: ~/bootleg/_build/test/lib/bootleg
66+
67+
functional:
68+
<<: *defaults
69+
machine:
70+
image: circleci/classic:latest
71+
steps:
72+
- checkout
73+
- run:
74+
name: Setup Environment Variables
75+
command: |
76+
echo 'export INSTALL_PATH="$HOME/dependencies"' >> $BASH_ENV
77+
echo 'export PATH="$INSTALL_PATH/bin:$PATH"' >> $BASH_ENV
78+
echo 'export VERSION_CIRCLECI=2' >> $BASH_ENV
79+
echo 'export COVERALLS_REPO_TOKEN=$COVERALLS_REPO_TOKEN' >> $BASH_ENV
80+
echo 'export CI_PULL_REQUEST=$CIRCLE_PR_NUMBER' >> $BASH_ENV
1381
- restore_cache:
14-
key: environment-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "script/ci/prepare.sh" }}-{{ arch }}
82+
key: environment-cache-{{ checksum "script/ci/prepare.sh" }}-{{ arch }}
1583
- run:
1684
name: Install Elixir
1785
command: script/ci/prepare.sh
1886
- save_cache:
19-
key: environment-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "script/ci/prepare.sh" }}-{{ arch }}
87+
key: environment-cache-{{ checksum "script/ci/prepare.sh" }}-{{ arch }}
2088
paths:
2189
- ~/dependencies
2290
- restore_cache:
23-
key: dependencies-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "script/ci/prepare.sh" }}-{{ checksum "mix.lock" }}-{{ arch }}
91+
key: dependencies-cache-{{ checksum "script/ci/prepare.sh" }}-{{ checksum "mix.lock" }}-{{ arch }}
2492
- run:
2593
name: Preparing dependencies
2694
command: |
2795
mix local.hex --force
2896
mix local.rebar --force
2997
mix deps.get;
3098
mix deps.compile;
31-
mix dialyzer --plt;
32-
no_output_timeout: 10m
3399
- save_cache:
34-
key: dependencies-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "script/ci/prepare.sh" }}-{{ checksum "mix.lock" }}-{{ arch }}
100+
key: dependencies-cache-{{ checksum "script/ci/prepare.sh" }}-{{ checksum "mix.lock" }}-{{ arch }}
35101
paths:
36102
- ~/.mix
37103
- _build
38104
- deps
39105
- run: mix compile
40-
- run: mix dialyzer
41-
- run: mix format --check-formatted --dry-run || (mix format && git --no-pager diff && false)
42-
- run: mix credo --strict
43106
- run: mix coveralls.html
44107
- store_test_results:
45108
path: ~/bootleg/_build/test/lib/bootleg
46109
- store_artifacts:
47110
path: cover
111+
workflows:
112+
version: 2
113+
build-and-verify:
114+
jobs:
115+
- build
116+
- functional:
117+
requires:
118+
- build

coveralls.json .excoveralls/coveralls.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
],
55
"coverage_options": {
66
"treat_no_relevant_lines_as_covered": true,
7-
"minimum_coverage": 40,
7+
"minimum_coverage": 85,
88
"output_dir": "cover"
99
}
10-
}
10+
}

circle.yml

-21
This file was deleted.

lib/bootleg/tasks.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ defmodule Bootleg.Tasks do
3030
end
3131

3232
@doc false
33-
@spec pop_env_task(binary, [binary]) :: {nil, nil} | {nil, atom} | {binary, atom}
33+
@spec pop_env_task(any, [binary]) :: {nil, nil} | {nil, atom} | {binary, atom}
3434
defp pop_env_task(env, args) when args == [] do
3535
{env, nil}
3636
end

mix.exs

+10-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ defmodule Bootleg.Mixfile do
1414
start_permanent: Mix.env() == :prod,
1515
elixirc_paths: elixirc_paths(Mix.env()),
1616
test_coverage: [tool: ExCoveralls],
17-
dialyzer: [plt_add_deps: :transitive, plt_add_apps: [:mix, :sshkit]],
17+
preferred_cli_env: [
18+
dialyzer: :dev,
19+
coveralls: :test,
20+
"coveralls.detail": :test,
21+
"coveralls.circle": :test,
22+
"coveralls.html": :test
23+
],
24+
dialyzer: [plt_add_apps: [:mix, :sshkit, :ex_unit]],
1825
docs: docs(),
1926
description: description(),
2027
deps: deps(),
@@ -46,9 +53,9 @@ defmodule Bootleg.Mixfile do
4653
{:sshkit, "0.1.0"},
4754
{:ssh_client_key_api, "~> 0.2.1"},
4855
{:credo, "~> 0.10", only: [:dev, :test]},
49-
{:dialyxir, "~> 0.5", only: [:dev, :test], runtime: false},
56+
{:dialyxir, "~> 1.0.0-rc.3", only: [:dev], runtime: false},
5057
{:ex_doc, "~> 0.16", only: :dev, runtime: false},
51-
{:excoveralls, "~> 0.6", only: :test},
58+
{:excoveralls, "~> 0.10", only: :test},
5259
{:mock, "~> 0.3.0", only: :test},
5360
{:junit_formatter, "~> 2.0", only: :test},
5461
{:temp, "~> 0.4.3", only: :test}

mix.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
33
"certifi": {:hex, :certifi, "2.4.2", "75424ff0f3baaccfd34b1214184b6ef616d89e420b258bb0a5ea7d7bc628f7f0", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"},
44
"credo": {:hex, :credo, "0.10.1", "e85efaf2dd7054399083ab2c6a5199f6cb1805de1a5b00d9e8c5f07033407b1f", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
5-
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
5+
"dialyxir": {:hex, :dialyxir, "1.0.0-rc.3", "774306f84973fc3f1e2e8743eeaa5f5d29b117f3916e5de74c075c02f1b8ef55", [:mix], [], "hexpm"},
66
"earmark": {:hex, :earmark, "1.2.6", "b6da42b3831458d3ecc57314dff3051b080b9b2be88c2e5aa41cd642a5b044ed", [:mix], [], "hexpm"},
77
"ex_doc": {:hex, :ex_doc, "0.19.1", "519bb9c19526ca51d326c060cb1778d4a9056b190086a8c6c115828eaccea6cf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.7", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
88
"excoveralls": {:hex, :excoveralls, "0.10.0", "a4508bdd408829f38e7b2519f234b7fd5c83846099cda348efcb5291b081200c", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},

test/support/fixtures.ex

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
defmodule Bootleg.Fixtures do
22
@moduledoc false
33

4-
def inflate_project(name \\ :build_me) do
4+
@dialyzer {:no_return, inflate_project: 0, inflate_project: 1}
5+
@spec inflate_project(atom) :: binary
6+
def inflate_project(name \\ :build_me)
7+
8+
def inflate_project(name) do
59
project_dir = Temp.mkdir!("git-#{name}")
610
File.cp_r!("./test/fixtures/#{name}", project_dir)
711

test/support/functional_case.ex

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ defmodule Bootleg.FunctionalCase do
7272
Map.merge(config, %{id: id, ip: ip, port: port})
7373
end
7474

75+
@dialyzer {:no_return, init: 1, init: 2}
76+
@spec init(binary, []) :: %{}
7577
def init(host, options \\ []) do
7678
adduser!(host, @user)
7779
chpasswd!(host, @user, @pass)

test/test_helper.exs

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
unless System.get_env("TEST_LEAVE_TEMP"), do: Temp.track!()
22

3-
unless Docker.ready?() do
4-
IO.puts("""
5-
It seems like Docker isn't running?
3+
skip_functional_tests =
4+
ExUnit.configuration()
5+
|> Keyword.get(:exclude)
6+
|> Enum.member?(:functional)
67

7-
Please check:
8+
unless skip_functional_tests do
9+
unless Docker.ready?() do
10+
IO.puts("""
11+
It seems like Docker isn't running?
812
9-
1. Docker is installed: `docker version`
10-
2. On OS X and Windows: `docker-machine start`
11-
3. Environment is set up: `eval $(docker-machine env)`
12-
""")
13+
Please check:
1314
14-
exit({:shutdown, 1})
15-
end
15+
1. Docker is installed: `docker version`
16+
2. On OS X and Windows: `docker-machine start`
17+
3. Environment is set up: `eval $(docker-machine env)`
18+
""")
19+
20+
exit({:shutdown, 1})
21+
end
1622

17-
Docker.build!("bootleg-test-sshd", "test/support/docker")
23+
Docker.build!("bootleg-test-sshd", "test/support/docker")
24+
end
1825

1926
ExUnit.configure(formatters: [JUnitFormatter, ExUnit.CLIFormatter])
2027
ExUnit.start()

test/ui_test.exs

+14
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,18 @@ defmodule Bootleg.UITest do
204204
assert Enum.count(char_out, fn codepoint -> codepoint === 8217 end) == 2000
205205
assert size == 273_036, "Received data not in expected form."
206206
end
207+
208+
test "prompt returns user input" do
209+
assert capture_io([input: "foobar", capture_prompt: false], fn ->
210+
input = UI.prompt(">")
211+
IO.write(input)
212+
end) == "foobar"
213+
end
214+
215+
test "prompt pads input prompt with a space" do
216+
assert capture_io([input: "bazfoo"], fn ->
217+
input = UI.prompt(">")
218+
IO.write(input)
219+
end) == "> bazfoo"
220+
end
207221
end

0 commit comments

Comments
 (0)