Skip to content

Commit

Permalink
Multiple improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
devinus committed Jan 9, 2021
1 parent f18a03a commit 0f3109a
Show file tree
Hide file tree
Showing 23 changed files with 597 additions and 506 deletions.
147 changes: 74 additions & 73 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,111 +1,112 @@
version: 2.1
jobs:
build:

executors:
elixir:
docker:
- image: circleci/elixir:1.9.4
- image: circleci/elixir:1.11.3
environment:
MIX_ENV: test

jobs:
build:
executor: elixir
steps:
- checkout

- run: mix local.hex --force
- run: mix local.rebar --force

- run: elixir -e 'IO.binwrite("#{System.version}-otp-#{:erlang.system_info(:otp_release)}")' | tee -i ~/.elixir-version
- restore_cache:
key: v1-deps-cache-{{ checksum "mix.lock" }}
- run: mix do deps.get, deps.compile
- save_cache:
key: v1-deps-cache-{{ checksum "mix.lock" }}
paths:
- deps
- ~/.mix
- _build
keys:
- v1-build-cache-{{ checksum "~/.elixir-version" }}-{{ checksum "mix.lock" }}-{{ .Revision }}
- v1-build-cache-{{ checksum "~/.elixir-version" }}-{{ checksum "mix.lock" }}-
- v1-build-cache-{{ checksum "~/.elixir-version" }}-

- run: mix local.hex --force --if-missing
- run: mix local.rebar --force --if-missing

- run: mix deps.get
- run: mix deps.compile
- run: mix compile

- run: echo "$OTP_VERSION $ELIXIR_VERSION" > .version_file
- restore_cache:
keys:
- plt-cache-{{ checksum ".version_file" }}-{{ checksum "mix.lock" }}
- run: mix dialyzer --plt
- save_cache:
key: plt-cache-{{ checksum ".version_file" }}-{{ checksum "mix.lock" }}
key: v1-build-cache-{{ checksum "~/.elixir-version" }}-{{ checksum "mix.lock" }}-{{ .Revision }}
paths:
- _build
- deps
- ~/.mix
- deps
- _build

format:
docker:
- image: circleci/elixir:1.9.4
environment:
MIX_ENV: test
- persist_to_workspace:
root: ~/
paths:
- .elixir-version
- .mix
- .hex

format:
executor: elixir
steps:
- attach_workspace:
at: ~/
- checkout
- run: mix format --check-formatted
- restore_cache:
key: v1-build-cache-{{ checksum "~/.elixir-version" }}-{{ checksum "mix.lock" }}-{{ .Revision }}
- run: mix format --check-formatted --dry-run

credo:
docker:
- image: circleci/elixir:1.9.4
environment:
MIX_ENV: test

executor: elixir
steps:
- attach_workspace:
at: ~/
- checkout
- run: mix archive.install hex bunt '~> 0.2' --force
- run: mix archive.install hex credo '~> 1.1' --force
- run: mix credo --strict
- restore_cache:
key: v1-build-cache-{{ checksum "~/.elixir-version" }}-{{ checksum "mix.lock" }}-{{ .Revision }}
- run: mix credo

dialyzer:
docker:
- image: circleci/elixir:1.9.4
environment:
MIX_ENV: test

executor: elixir
steps:
- attach_workspace:
at: ~/
- checkout
- run: echo "$OTP_VERSION $ELIXIR_VERSION" > .version_file
- restore_cache:
keys:
- plt-cache-{{ checksum ".version_file" }}-{{ checksum "mix.lock" }}
- run:
name: Execute dialyzer
command: mix dialyzer --halt-exit-status
- v1-plt-cache-{{ checksum "~/.elixir-version" }}-{{ checksum "mix.lock" }}-{{ .Revision }}
- v1-plt-cache-{{ checksum "~/.elixir-version" }}-{{ checksum "mix.lock" }}-
- v1-build-cache-{{ checksum "~/.elixir-version" }}-{{ checksum "mix.lock" }}-{{ .Revision }}
- run: mix dialyzer --plt
- save_cache:
key: v1-plt-cache-{{ checksum "~/.elixir-version" }}-{{ checksum "mix.lock" }}-{{ .Revision }}
paths:
- ~/.mix
- deps
- _build
- run: mix dialyzer --no-check

test:
docker:
- image: circleci/elixir:1.9.4

executor: elixir
steps:
- attach_workspace:
at: ~/
- checkout

- run: git submodule update --init
- restore_cache:
key: v1-deps-cache-{{ checksum "mix.lock" }}

key: v1-build-cache-{{ checksum "~/.elixir-version" }}-{{ checksum "mix.lock" }}-{{ .Revision }}
- run: mix coveralls.html

- store_artifacts:
path: cover
destination: coverage_results

- store_test_results:
path: _build/test/lib/poison
- store_artifacts:
path: cover

# docs:
# docker:
# - image: circleci/elixir:1.9.4
# environment:
# MIX_ENV: test
# steps:
# - checkout
# - restore_cache:
# key: v1-deps-cache-{{ checksum "mix.lock" }}
# - run: mix docs
# - store_artifacts:
# path: doc
# destination: documentation
docs:
executor: elixir
steps:
- attach_workspace:
at: ~/
- checkout
- restore_cache:
key: v1-build-cache-{{ checksum "~/.elixir-version" }}-{{ checksum "mix.lock" }}-{{ .Revision }}
- run: mix docs
- store_artifacts:
path: doc

workflows:
version: 2
Expand All @@ -124,6 +125,6 @@ workflows:
- test:
requires:
- build
# - docs:
# requires:
# - build
- docs:
requires:
- build
33 changes: 29 additions & 4 deletions .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
configs: [
%{
#
# Run any exec using `mix credo -C <name>`. If no exec name is given
# Run any config using `mix credo -C <name>`. If no config name is given
# "default" is used.
#
name: "default",
Expand All @@ -21,7 +21,16 @@
# You can give explicit globs or simply directories.
# In the latter case `**/*.{ex,exs}` will be used.
#
included: ["lib/", "src/", "test/", "web/", "apps/"],
included: [
"lib/",
"src/",
"test/",
"web/",
"apps/*/lib/",
"apps/*/src/",
"apps/*/test/",
"apps/*/web/"
],
excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"]
},
#
Expand All @@ -39,6 +48,10 @@
#
strict: true,
#
# To modify the timeout for parsing files, change this value:
#
parse_timeout: 5000,
#
# If you want to use uncolored output by default, you can change `color`
# to `false` below:
#
Expand Down Expand Up @@ -96,7 +109,6 @@
{Credo.Check.Readability.StringSigils, false},
{Credo.Check.Readability.TrailingBlankLine, []},
{Credo.Check.Readability.TrailingWhiteSpace, []},
# TODO: enable by default in Credo 1.1
{Credo.Check.Readability.UnnecessaryAliasExpansion, []},
{Credo.Check.Readability.VariableNames, []},

Expand All @@ -118,11 +130,13 @@
#
## Warnings
#
{Credo.Check.Warning.ApplicationConfigInModuleAttribute, []},
{Credo.Check.Warning.BoolOperationOnSameValues, []},
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
{Credo.Check.Warning.IExPry, []},
{Credo.Check.Warning.IoInspect, []},
{Credo.Check.Warning.LazyLogging, false},
{Credo.Check.Warning.MixEnv, false},
{Credo.Check.Warning.OperationOnSameValues, []},
{Credo.Check.Warning.OperationWithConstantResult, []},
{Credo.Check.Warning.RaiseInsideRescue, []},
Expand All @@ -134,6 +148,10 @@
{Credo.Check.Warning.UnusedRegexOperation, []},
{Credo.Check.Warning.UnusedStringOperation, []},
{Credo.Check.Warning.UnusedTupleOperation, []},
{Credo.Check.Warning.UnsafeExec, []},

#
# Checks scheduled for next check update (opt-in for now, just replace `false` with `[]`)

#
# Controversial and experimental checks (opt-in, just replace `false` with `[]`)
Expand All @@ -142,15 +160,22 @@
{Credo.Check.Consistency.UnusedVariableNames, []},
{Credo.Check.Design.DuplicatedCode, []},
{Credo.Check.Readability.AliasAs, []},
{Credo.Check.Readability.BlockPipe, []},
{Credo.Check.Readability.ImplTrue, []},
{Credo.Check.Readability.MultiAlias, false},
{Credo.Check.Readability.Specs, false},
{Credo.Check.Readability.SeparateAliasRequire, []},
{Credo.Check.Readability.SinglePipe, []},
{Credo.Check.Readability.Specs, false},
{Credo.Check.Readability.StrictModuleLayout, []},
{Credo.Check.Readability.WithCustomTaggedTuple, []},
{Credo.Check.Refactor.ABCSize, []},
{Credo.Check.Refactor.AppendSingleItem, []},
{Credo.Check.Refactor.DoubleBooleanNegation, []},
{Credo.Check.Refactor.ModuleDependencies, false},
{Credo.Check.Refactor.NegatedIsNil, []},
{Credo.Check.Refactor.PipeChainStart, []},
{Credo.Check.Refactor.VariableRebinding, false},
{Credo.Check.Warning.LeakyEnvironment, []},
{Credo.Check.Warning.MapGetUnsafePass, []},
{Credo.Check.Warning.UnsafeToAtom, []}

Expand Down
1 change: 1 addition & 0 deletions .dockerignore
3 changes: 2 additions & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Used by "mix format"
[
import_deps: [:stream_data],
inputs: [
"{mix,.credo,.formatter}.exs",
"{config,lib,test,bench}/**/*.{ex,exs}"
"{config,lib,test,bench,profile}/**/*.{ex,exs}"
],
line_length: 120
]
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ erl_crash.dump
# Ignore package tarball (built via "mix hex.build").
poison-*.tar

# Temporary files for e.g. tests
/tmp

.elixir_ls
/benchmarks/
/bench/output/
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "JSONTestSuite"]
path = vendor/JSONTestSuite
url = https://github.com/nst/JSONTestSuite.git
shallow = true
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
erlang 22.1.8
elixir 1.9.4-otp-22
erlang ref:master
elixir ref:master
30 changes: 15 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
dist: bionic
sudo: false
language: elixir
elixir:
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.2
- 1.8.1
- 1.8.0
- 1.11.3
- 1.11.2
- 1.11.1
- 1.11.0
- 1.10.4
- 1.10.3
- 1.10.2
- 1.10.1
- 1.10.0
otp_release:
- 23.2
- 23.1
- 23.0
- 22.2
- 22.1
- 22.0
- 21.3
- 21.2
- 21.1
- 21.0
sudo: false
before_script: git submodule update --init
matrix:
include:
- install:
- mix local.rebar --force
- mix local.hex --force
- mix archive.install hex bunt '~> 0.2' --force
- mix archive.install hex credo '~> 1.1' --force
script:
- mix format --check-formatted --dry-run
- mix credo --strict
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"editor.formatOnSave": true
"editor.formatOnSave": true,
"files.watcherExclude": {
"**/target": true
}
}
Loading

0 comments on commit 0f3109a

Please sign in to comment.