From 3cb09cbffde2caa4ee201535a0b1914e19511042 Mon Sep 17 00:00:00 2001 From: Yevhenii Kurtov Date: Sat, 3 Aug 2019 13:31:35 +0000 Subject: [PATCH 01/14] Update deprecated time unit Rename `seconds` to `second` as per warning message https://github.com/elixir-lang/elixir/blob/3c9ff7b1aea00667f32253ecafe4c6fea23982ff/lib/elixir/lib/system.ex#L1073 --- lib/plug_session_mnesia/cleaner.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plug_session_mnesia/cleaner.ex b/lib/plug_session_mnesia/cleaner.ex index 6defef9..b0d8af4 100644 --- a/lib/plug_session_mnesia/cleaner.ex +++ b/lib/plug_session_mnesia/cleaner.ex @@ -62,7 +62,7 @@ defmodule PlugSessionMnesia.Cleaner do def clean_sessions(table, max_age) do oldest_timestamp = - System.os_time() - System.convert_time_unit(max_age, :seconds, :native) + System.os_time() - System.convert_time_unit(max_age, :second, :native) delete_old_sessions = fn -> old_sids = From ee73efeb620a16d4be999bfc31b7ccb8e667504e Mon Sep 17 00:00:00 2001 From: Jean-Philippe Cugnet Date: Sun, 4 Aug 2019 13:02:51 +0200 Subject: [PATCH 02/14] Bump the version to 0.1.3-dev --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index dc87443..c1a4a34 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule PlugSessionMnesia.Mixfile do use Mix.Project - @version "0.1.2" + @version "0.1.3-dev" @repo_url "https://github.com/ejpcmac/plug_session_mnesia" def project do From cf0b480be111e6cb98fbf5fe33878f4e9f5483c4 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Cugnet Date: Sun, 4 Aug 2019 13:09:21 +0200 Subject: [PATCH 03/14] Update the copyrights --- LICENSE | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 63e81de..e4a4cc8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Jean-Philippe Cugnet +Copyright (c) 2017-2019 Jean-Philippe Cugnet and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index d03d110..51ab6b3 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,6 @@ Before contributing to this project, please read the ## License -Copyright © 2017-2018 Jean-Philippe Cugnet +Copyright © 2017-2019 Jean-Philippe Cugnet and contributors This project is licensed under the [MIT license](LICENSE). From 712dbae987dcac7bd559d67866c77043875cd1dd Mon Sep 17 00:00:00 2001 From: Jean-Philippe Cugnet Date: Sun, 4 Aug 2019 13:39:53 +0200 Subject: [PATCH 04/14] Update to the current xgen conventions --- .envrc | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++ .formatter.exs | 5 ++- .gitignore | 46 +++++++++++++++++---------- mix.exs | 73 +++++++++++++++++++++++++++++++++++-------- mix.lock | 40 ++++++++++++------------ shell.nix | 22 +++++++++++++ 6 files changed, 221 insertions(+), 49 deletions(-) create mode 100644 .envrc create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..6d28500 --- /dev/null +++ b/.envrc @@ -0,0 +1,84 @@ +#################################### +# Environment setup for Nix shells # +#################################### + +# From https://github.com/direnv/direnv/wiki/Nix#persistent-cached-shell +# +# Usage: use_nix [...] +# +# Load environment variables from `nix-shell`. +# If you have a `default.nix` or `shell.nix` one of these will be used and +# the derived environment will be stored at ./.direnv/env- +# and symlink to it will be created at ./.direnv/default. +# Dependencies are added to the GC roots, such that the environment remains persistent. +# +# Packages can also be specified directly via e.g `use nix -p ocaml`, +# however those will not be added to the GC roots. +# +# The resulting environment is cached for better performance. +# +# To trigger switch to a different environment: +# `rm -f .direnv/default` +# +# To derive a new environment: +# `rm -rf .direnv/env-$(md5sum {shell,default}.nix 2> /dev/null | cut -c -32)` +# +# To remove cache: +# `rm -f .direnv/dump-*` +# +# To remove all environments: +# `rm -rf .direnv/env-*` +# +# To remove only old environments: +# `find .direnv -name 'env-*' -and -not -name `readlink .direnv/default` -exec rm -rf {} +` +# +use_nix() { + set -e + + local shell="shell.nix" + if [[ ! -f "${shell}" ]]; then + shell="default.nix" + fi + + if [[ ! -f "${shell}" ]]; then + fail "use nix: shell.nix or default.nix not found in the folder" + fi + + local dir="${PWD}"/.direnv + local default="${dir}/default" + if [[ ! -L "${default}" ]] || [[ ! -d `readlink "${default}"` ]]; then + local wd="${dir}/env-`md5sum "${shell}" | cut -c -32`" # TODO: Hash also the nixpkgs version? + mkdir -p "${wd}" + + local drv="${wd}/env.drv" + if [[ ! -f "${drv}" ]]; then + log_status "use nix: deriving new environment" + IN_NIX_SHELL=1 nix-instantiate --add-root "${drv}" --indirect "${shell}" > /dev/null + nix-store -r `nix-store --query --references "${drv}"` --add-root "${wd}/dep" --indirect > /dev/null + fi + + rm -f "${default}" + ln -s `basename "${wd}"` "${default}" + fi + + local drv=`readlink -f "${default}/env.drv"` + local dump="${dir}/dump-`md5sum ".envrc" | cut -c -32`-`md5sum ${drv} | cut -c -32`" + + if [[ ! -f "${dump}" ]] || [[ "${XDG_CONFIG_DIR}/direnv/direnvrc" -nt "${dump}" ]]; then + log_status "use nix: updating cache" + + old=`find "${dir}" -name 'dump-*'` + nix-shell "${drv}" --show-trace "$@" --run 'direnv dump' > "${dump}" + rm -f ${old} + fi + + direnv_load cat "${dump}" + + watch_file "${default}" + watch_file shell.nix + if [[ ${shell} == "default.nix" ]]; then + watch_file default.nix + fi +} + +use nix diff --git a/.formatter.exs b/.formatter.exs index 698fe01..58ff344 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,4 +1,7 @@ [ - inputs: ["{mix,.formatter,.credo}.exs", "{config,lib,test}/**/*.{ex,exs}"], + inputs: [ + "{mix,.iex,.formatter,.credo}.exs", + "{config,lib,rel,test}/**/*.{ex,exs}" + ], line_length: 80 ] diff --git a/.gitignore b/.gitignore index d499303..7e6001b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,40 @@ -# The directory Mix will write compiled artifacts to. -/_build/ +## +## Application artifacts +## -# If you run "mix test --cover", coverage assets end up here. -/cover/ +# direnv cache for Nix shells +/.direnv/ -# The directory Mix downloads your dependencies sources to. -/deps/ - -# Where 3rd-party dependencies like ExDoc output generated docs. -/doc/ +# Elixir build directory +/_build/ -# Ignore .fetch files in case you like to edit your project deps locally. +# Elixir dependencies +/deps/ /.fetch -# If the VM crashes, it generates a dump, let's ignore it too. -erl_crash.dump - -# Also ignore archive artifacts (built via "mix archive.build"). +# Elixir binary files +*.beam *.ez +/xgen-*.tar +/xgen -# Elixir LS artifacts. -/.elixir_ls/ +# Test coverage and documentation +/cover/ +/doc/ # Mnesia database /Mnesia.* + +## +## Editor artifacts +## + +/.elixir_ls/ +/.history/ + +## +## Crash dumps +## + +# Erang VM +erl_crash.dump diff --git a/mix.exs b/mix.exs index c1a4a34..d237218 100644 --- a/mix.exs +++ b/mix.exs @@ -1,33 +1,31 @@ defmodule PlugSessionMnesia.Mixfile do use Mix.Project - @version "0.1.3-dev" + @version "0.1.3" @repo_url "https://github.com/ejpcmac/plug_session_mnesia" def project do [ app: :plug_session_mnesia, - version: @version, + version: @version <> dev(), elixir: "~> 1.5", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, deps: deps(), - dialyzer: [ - plt_add_deps: :transitive, - flags: [:unmatched_returns, :error_handling, :race_conditions], - ignore_warnings: ".dialyzer_ignore" - ], + + # Tools + dialyzer: dialyzer(), test_coverage: [tool: ExCoveralls], - preferred_cli_env: [ - coveralls: :test, - "coveralls.detail": :test, - "coveralls.html": :test - ], + preferred_cli_env: cli_env(), + + # Docs docs: [ main: "PlugSessionMnesia", source_url: @repo_url, source_ref: "v#{@version}" ], + + # Package package: package(), description: """ An application for storing and managing Plug sessions with Mnesia. @@ -63,6 +61,44 @@ defmodule PlugSessionMnesia.Mixfile do ] end + # Dialyzer configuration + defp dialyzer do + [ + # Use a custom PLT directory for continuous integration caching. + plt_core_path: System.get_env("PLT_DIR"), + plt_file: plt_file(), + plt_add_deps: :transitive, + flags: [ + :unmatched_returns, + :error_handling, + :race_conditions + ], + ignore_warnings: ".dialyzer_ignore" + ] + end + + defp plt_file do + case System.get_env("PLT_DIR") do + nil -> nil + plt_dir -> {:no_warn, Path.join(plt_dir, "xgen.plt")} + end + end + + defp cli_env do + [ + # Run mix test.watch in `:test` env. + "test.watch": :test, + + # Always run Coveralls Mix tasks in `:test` env. + coveralls: :test, + "coveralls.detail": :test, + "coveralls.html": :test, + + # Use a custom env for docs. + docs: :docs + ] + end + defp package do [ maintainers: ["Jean-Philippe Cugnet"], @@ -70,4 +106,17 @@ defmodule PlugSessionMnesia.Mixfile do links: %{"GitHub" => @repo_url} ] end + + # Helper to add a development revision to the version. Do NOT make a call to + # Git this way in a production release!! + def dev do + with {rev, 0} <- + System.cmd("git", ["rev-parse", "--short", "HEAD"], + stderr_to_stdout: true + ) do + "-dev+" <> String.trim(rev) + else + _ -> "-dev" + end + end end diff --git a/mix.lock b/mix.lock index 452a862..33fd847 100644 --- a/mix.lock +++ b/mix.lock @@ -1,22 +1,22 @@ %{ - "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [], [], "hexpm"}, - "certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [], [], "hexpm"}, - "credo": {:hex, :credo, "0.8.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, - "dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [], [], "hexpm"}, - "earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [], [], "hexpm"}, - "ex_doc": {:hex, :ex_doc, "0.18.1", "37c69d2ef62f24928c1f4fdc7c724ea04aecfdf500c4329185f8e3649c915baf", [], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, - "ex_unit_notifier": {:hex, :ex_unit_notifier, "0.1.4", "36a2dcab829f506e01bf17816590680dd1474407926d43e64c1263e627c364b8", [], [], "hexpm"}, - "excoveralls": {:hex, :excoveralls, "0.8.0", "99d2691d3edf8612f128be3f9869c4d44b91c67cec92186ce49470ae7a7404cf", [], [{: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", [], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"}, - "fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [], [], "hexpm"}, - "hackney": {:hex, :hackney, "1.10.1", "c38d0ca52ea80254936a32c45bb7eb414e7a96a521b4ce76d00a69753b157f21", [], [{: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", [], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, - "jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [], [], "hexpm"}, - "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [], [], "hexpm"}, - "mime": {:hex, :mime, "1.2.0", "78adaa84832b3680de06f88f0997e3ead3b451a440d183d688085be2d709b534", [], [], "hexpm"}, - "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [], [], "hexpm"}, - "mix_test_watch": {:hex, :mix_test_watch, "0.5.0", "2c322d119a4795c3431380fca2bca5afa4dc07324bd3c0b9f6b2efbdd99f5ed3", [], [{:fs, "~> 0.9.1", [hex: :fs, repo: "hexpm", optional: false]}], "hexpm"}, - "plug": {:hex, :plug, "1.4.3", "236d77ce7bf3e3a2668dc0d32a9b6f1f9b1f05361019946aae49874904be4aed", [], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [], [], "hexpm"}, - "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [], [], "hexpm"}, + "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, + "certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"}, + "credo": {:hex, :credo, "0.8.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, + "dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"}, + "earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [:mix], [], "hexpm"}, + "ex_doc": {:hex, :ex_doc, "0.18.1", "37c69d2ef62f24928c1f4fdc7c724ea04aecfdf500c4329185f8e3649c915baf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, + "ex_unit_notifier": {:hex, :ex_unit_notifier, "0.1.4", "36a2dcab829f506e01bf17816590680dd1474407926d43e64c1263e627c364b8", [:mix], [], "hexpm"}, + "excoveralls": {:hex, :excoveralls, "0.8.0", "99d2691d3edf8612f128be3f9869c4d44b91c67cec92186ce49470ae7a7404cf", [: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], [], "hexpm"}, + "hackney": {:hex, :hackney, "1.10.1", "c38d0ca52ea80254936a32c45bb7eb414e7a96a521b4ce76d00a69753b157f21", [: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.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm"}, + "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, + "mime": {:hex, :mime, "1.2.0", "78adaa84832b3680de06f88f0997e3ead3b451a440d183d688085be2d709b534", [:mix], [], "hexpm"}, + "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, + "mix_test_watch": {:hex, :mix_test_watch, "0.5.0", "2c322d119a4795c3431380fca2bca5afa4dc07324bd3c0b9f6b2efbdd99f5ed3", [:mix], [{:fs, "~> 0.9.1", [hex: :fs, repo: "hexpm", optional: false]}], "hexpm"}, + "plug": {:hex, :plug, "1.4.3", "236d77ce7bf3e3a2668dc0d32a9b6f1f9b1f05361019946aae49874904be4aed", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"}, } diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..9537a9a --- /dev/null +++ b/shell.nix @@ -0,0 +1,22 @@ +{ pkgs ? import {} }: + +with pkgs; + +let + inherit (lib) optional optionals; + + elixir = beam.packages.erlangR22.elixir_1_9; + gitflow = gitAndTools.gitflow; +in + +mkShell { + buildInputs = [ elixir git gitflow ] + ++ optional stdenv.isLinux libnotify # For ExUnit Notifier on Linux. + ++ optional stdenv.isLinux inotify-tools # For file_system on Linux. + ++ optional stdenv.isDarwin terminal-notifier # For ExUnit Notifier on macOS. + ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ + # For file_system on macOS. + CoreFoundation + CoreServices + ]); +} From 5c1c46d2f78a6b1a5cf42966089bf3b1df05e942 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Cugnet Date: Sun, 4 Aug 2019 13:45:51 +0200 Subject: [PATCH 05/14] Update the contributing guidelines to use Nix --- CONTRIBUTING.md | 100 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 84 insertions(+), 16 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0fb493e..d652bbb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,8 +1,15 @@ # Contributing to plug_session_mnesia -This project uses [git-flow](https://github.com/petervanderdoes/gitflow-avh). -The `master` branch is reserved to releases: the development process occurs on -`develop` and feature branches. **Please never commit to master.** +`plug_session_mnesia` is written in [Elixir](https://elixir-lang.org). + +For branching management, this project uses +[git-flow](https://github.com/petervanderdoes/gitflow-avh). The `master` branch +is reserved for releases: the development process occurs on `develop` and +feature branches. **Please never commit to master.** + +You can easily set up a development environment featuring all the dependencies, +including Elixir and `git-flow`, by using [Nix](https://nixos.org/nix/). This is +detailed below. ## Setup @@ -13,34 +20,77 @@ The `master` branch is reserved to releases: the development process occurs on 2. Clone your fork to a local repository: $ git clone https://github.com/you/plug_session_mnesia.git - $ cd project + $ cd plug_session_mnesia 3. Add the main repository as a remote: - $ git remote add upstream https://github.com/ejpcmac.net/plug_session_mnesia.git + $ git remote add upstream https://github.com/ejpcmac/plug_session_mnesia.git 4. Checkout to `develop`: $ git checkout develop -### Development environment +### Development environment (without Nix) + +Install an Elixir environment, and optionally install `git-flow`. + +### Development environment (with Nix) + +1. Install Nix by running the script and following the instructions: + + $ curl https://nixos.org/nix/install | sh + +2. Optionally install [direnv](https://github.com/direnv/direnv) to + automatically setup the environment when you enter the project directory: + + $ nix-env -i direnv + + In this case, you also need to add to your `~/.rc`: + + ```sh + eval "$(direnv hook )" + ``` + + *Make sure to replace `` by your shell, namely `bash`, `zsh`, …* + +3. In the project directory, if you **did not** install direnv, start a Nix + shell: + + $ cd plug_session_mnesia + $ nix-shell -1. Install an Elixir environment. + If you opted to use direnv, please allow the `.envrc` instead of running a + Nix shell manually: -2. Fetch the project dependencies and build the project: + $ cd plug_session_mnesia + $ direnv allow - $ cd project + In this case, direnv will automatically update your environment to behave + like a Nix shell whenever you enter the project directory. + +### Git-flow + +If you want to use `git-flow` and use the standard project configuration, please +run: + + $ ./.gitsetup + +### Building the project + +1. Fetch the project dependencies and build the project: + + $ cd plug_session_mnesia $ mix do deps.get, compile -3. Launch the tests: +2. Launch the tests: - $ mix test --stale + $ mix test -All tests should pass. +All the tests should pass. ## Workflow -To make a change, please follow this workflow: +To make a change, please use this workflow: 1. Checkout to `develop` and apply the last upstream changes (use rebase, not merge!): @@ -49,11 +99,21 @@ To make a change, please follow this workflow: $ git fetch --all --prune $ git rebase upstream/develop -2. Create a new branch with an explicit name: +2. For a tiny patch, create a new branch with an explicit name: $ git checkout -b -3. Work on your feature (don’t forget to write some tests, TDD is good ;-)): + Alternatively, if you are working on a feature which would need more work, + you can create a feature branch with `git-flow`: + + $ git flow feature start + + *Note: always open an issue and ask before starting a big feature, to avoid + it not beeing merged and your time lost.* + +3. Work on your feature (don’t forget to write typespecs and tests; you can + check your coverage with `mix coveralls.html` and open + `cover/excoveralls.html`): # Some work $ git commit -am "My first change" @@ -71,11 +131,16 @@ To make a change, please follow this workflow: $ git rebase upstream/develop 5. If there were commits on `develop` since the beginning of your feature - branch, integrate them by **rebasing**: + branch, integrate them by **rebasing** if your branch has few commits, or + merging if you had a long-lived branch: $ git checkout $ git rebase develop + *Note: the only case you should merge is when you are working on a big + feature. If it is the case, we should have discussed this before as stated + above.* + 6. Run the tests and static analyzers to ensure there is no regression and all works as expected: @@ -90,3 +155,6 @@ To make a change, please follow this workflow: Please format your code with `mix format` or your editor and follow [this style guide](https://github.com/christopheradams/elixir_style_guide). + +All contributed code must be documented and functions must have typespecs. In +general, take your inspiration from the existing code. From 16c7a84061663abfacf223443cd95c2aa16dbd09 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Cugnet Date: Sun, 4 Aug 2019 13:55:53 +0200 Subject: [PATCH 06/14] [CI] Add a configuration for Travis CI --- .travis.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f451e12 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,45 @@ +language: elixir +elixir: + - 1.6 + - 1.7 + - 1.8 + - 1.9 +otp_release: + - 19.3 + - 20.3 + - 21.2 + - 22.0 +matrix: + exclude: + - elixir: 1.6 + otp_release: 21.2 + - elixir: 1.6 + otp_release: 22.0 + - elixir: 1.7 + otp_release: 19.3 + - elixir: 1.7 + otp_release: 20.3 + - elixir: 1.8 + otp_release: 19.3 + - elixir: 1.8 + otp_release: 20.3 + - elixir: 1.9 + otp_release: 19.3 + - elixir: 1.9 + otp_release: 20.3 +env: + - PLT_DIR=$HOME/.plt +before_script: + - mkdir -p $PLT_DIR + - mix deps.compile + - MIX_ENV=test mix deps.compile + - travis_wait mix dialyzer --plt +script: + - mix compile --force --verbose --warnings-as-errors + - mix test --trace + - mix dialyzer --no-compile --no-check --halt-exit-status + - mix credo + - if [[ "$TRAVIS_ELIXIR_VERSION" == "1.9.1" ]]; then mix format --check-formatted; fi +cache: + directories: + - $PLT_DIR From c66daac0d7e926436679ea64ee4f581453ea146f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Cugnet Date: Sun, 4 Aug 2019 13:58:06 +0200 Subject: [PATCH 07/14] Add a build status badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 51ab6b3..e4e1dc4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # plug_session_mnesia +[![Build Status](https://travis-ci.com/ejpcmac/plug_session_mnesia.svg?branch=develop)](https://travis-ci.com/ejpcmac/plug_session_mnesia) [![hex.pm version](http://img.shields.io/hexpm/v/plug_session_mnesia.svg?style=flat)](https://hex.pm/packages/plug_session_mnesia) An application for storing and managing Plug sessions with Mnesia. From 004ba2dd0631a0167ed415d1747f0a55cf29f854 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Cugnet Date: Sun, 4 Aug 2019 15:03:13 +0200 Subject: [PATCH 08/14] Update the dependencies --- .credo.exs | 138 ++++++++++++++++++++++++---------------------- config/config.exs | 4 +- config/dev.exs | 3 - config/test.exs | 3 + mix.exs | 8 +-- mix.lock | 39 +++++++------ 6 files changed, 103 insertions(+), 92 deletions(-) diff --git a/.credo.exs b/.credo.exs index f4b3913..f68970a 100644 --- a/.credo.exs +++ b/.credo.exs @@ -21,8 +21,8 @@ # You can give explicit globs or simply directories. # In the latter case `**/*.{ex,exs}` will be used. # - included: ["lib/", "test/"], - excluded: [~r"/_build/", ~r"/deps/"] + included: ["lib/", "src/", "test/", "web/", "apps/"], + excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"] }, # # If you create your own checks, you must specify the source files for @@ -51,12 +51,12 @@ # ## Consistency Checks # - {Credo.Check.Consistency.ExceptionNames}, - {Credo.Check.Consistency.LineEndings}, - {Credo.Check.Consistency.ParameterPatternMatching}, - {Credo.Check.Consistency.SpaceAroundOperators}, - {Credo.Check.Consistency.SpaceInParentheses}, - {Credo.Check.Consistency.TabsOrSpaces}, + {Credo.Check.Consistency.ExceptionNames, []}, + {Credo.Check.Consistency.LineEndings, []}, + {Credo.Check.Consistency.ParameterPatternMatching, []}, + {Credo.Check.Consistency.SpaceAroundOperators, []}, + {Credo.Check.Consistency.SpaceInParentheses, []}, + {Credo.Check.Consistency.TabsOrSpaces, []}, # ## Design Checks @@ -64,95 +64,99 @@ # You can customize the priority of any check # Priority values are: `low, normal, high, higher` # - {Credo.Check.Design.AliasUsage, priority: :low}, + {Credo.Check.Design.AliasUsage, + [ + priority: :low, + if_nested_deeper_than: 2, + if_called_more_often_than: 0 + ]}, # For some checks, you can also set other parameters # # If you don't want the `setup` and `test` macro calls in ExUnit tests # or the `schema` macro in Ecto schemas to trigger DuplicatedCode, just # set the `excluded_macros` parameter to `[:schema, :setup, :test]`. # - {Credo.Check.Design.DuplicatedCode, excluded_macros: []}, - + {Credo.Check.Design.DuplicatedCode, [excluded_macros: []]}, # You can also customize the exit_status of each check. # If you don't want TODO comments to cause `mix credo` to fail, just # set this value to 0 (zero). # - {Credo.Check.Design.TagTODO, exit_status: 0}, - {Credo.Check.Design.TagFIXME}, + {Credo.Check.Design.TagTODO, [exit_status: 0]}, + {Credo.Check.Design.TagFIXME, []}, # ## Readability Checks # - {Credo.Check.Readability.FunctionNames}, - {Credo.Check.Readability.LargeNumbers}, - {Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 80}, - {Credo.Check.Readability.ModuleAttributeNames}, - {Credo.Check.Readability.ModuleDoc}, - {Credo.Check.Readability.ModuleNames}, - {Credo.Check.Readability.ParenthesesOnZeroArityDefs}, - {Credo.Check.Readability.ParenthesesInCondition}, - {Credo.Check.Readability.PredicateFunctionNames}, - {Credo.Check.Readability.PreferImplicitTry}, - {Credo.Check.Readability.RedundantBlankLines}, - {Credo.Check.Readability.StringSigils}, - {Credo.Check.Readability.TrailingBlankLine}, - {Credo.Check.Readability.TrailingWhiteSpace}, - {Credo.Check.Readability.VariableNames}, - {Credo.Check.Readability.Semicolons}, - {Credo.Check.Readability.SpaceAfterCommas}, + {Credo.Check.Readability.AliasOrder, []}, + {Credo.Check.Readability.FunctionNames, []}, + {Credo.Check.Readability.LargeNumbers, []}, + {Credo.Check.Readability.MaxLineLength, + [priority: :low, max_length: 80]}, + {Credo.Check.Readability.ModuleAttributeNames, []}, + {Credo.Check.Readability.ModuleDoc, []}, + {Credo.Check.Readability.ModuleNames, []}, + {Credo.Check.Readability.ParenthesesInCondition, []}, + {Credo.Check.Readability.ParenthesesOnZeroArityDefs, []}, + {Credo.Check.Readability.PredicateFunctionNames, []}, + {Credo.Check.Readability.PreferImplicitTry, []}, + {Credo.Check.Readability.RedundantBlankLines, []}, + {Credo.Check.Readability.Semicolons, []}, + {Credo.Check.Readability.SpaceAfterCommas, []}, + {Credo.Check.Readability.StringSigils, []}, + {Credo.Check.Readability.TrailingBlankLine, []}, + {Credo.Check.Readability.TrailingWhiteSpace, []}, + {Credo.Check.Readability.VariableNames, []}, # ## Refactoring Opportunities # - {Credo.Check.Refactor.DoubleBooleanNegation, false}, - {Credo.Check.Refactor.CondStatements}, - {Credo.Check.Refactor.CyclomaticComplexity}, - {Credo.Check.Refactor.FunctionArity}, - {Credo.Check.Refactor.LongQuoteBlocks}, - {Credo.Check.Refactor.MatchInCondition}, - {Credo.Check.Refactor.NegatedConditionsInUnless}, - {Credo.Check.Refactor.NegatedConditionsWithElse}, - {Credo.Check.Refactor.Nesting}, - {Credo.Check.Refactor.PipeChainStart}, - {Credo.Check.Refactor.UnlessWithElse}, + {Credo.Check.Refactor.CondStatements, []}, + {Credo.Check.Refactor.CyclomaticComplexity, []}, + {Credo.Check.Refactor.FunctionArity, []}, + {Credo.Check.Refactor.LongQuoteBlocks, []}, + {Credo.Check.Refactor.MatchInCondition, []}, + {Credo.Check.Refactor.NegatedConditionsInUnless, []}, + {Credo.Check.Refactor.NegatedConditionsWithElse, []}, + {Credo.Check.Refactor.Nesting, []}, + {Credo.Check.Refactor.PipeChainStart, + [ + excluded_argument_types: [:atom, :binary, :fn, :keyword], + excluded_functions: [] + ]}, + {Credo.Check.Refactor.UnlessWithElse, []}, # ## Warnings # - {Credo.Check.Warning.BoolOperationOnSameValues}, - {Credo.Check.Warning.ExpensiveEmptyEnumCheck}, - {Credo.Check.Warning.IExPry}, - {Credo.Check.Warning.IoInspect}, - {Credo.Check.Warning.LazyLogging}, - {Credo.Check.Warning.OperationOnSameValues}, - {Credo.Check.Warning.OperationWithConstantResult}, - {Credo.Check.Warning.UnusedEnumOperation}, - {Credo.Check.Warning.UnusedFileOperation}, - {Credo.Check.Warning.UnusedKeywordOperation}, - {Credo.Check.Warning.UnusedListOperation}, - {Credo.Check.Warning.UnusedPathOperation}, - {Credo.Check.Warning.UnusedRegexOperation}, - {Credo.Check.Warning.UnusedStringOperation}, - {Credo.Check.Warning.UnusedTupleOperation}, - {Credo.Check.Warning.RaiseInsideRescue}, + {Credo.Check.Warning.BoolOperationOnSameValues, []}, + {Credo.Check.Warning.ExpensiveEmptyEnumCheck, []}, + {Credo.Check.Warning.IExPry, []}, + {Credo.Check.Warning.IoInspect, []}, + {Credo.Check.Warning.OperationOnSameValues, []}, + {Credo.Check.Warning.OperationWithConstantResult, []}, + {Credo.Check.Warning.RaiseInsideRescue, []}, + {Credo.Check.Warning.UnusedEnumOperation, []}, + {Credo.Check.Warning.UnusedFileOperation, []}, + {Credo.Check.Warning.UnusedKeywordOperation, []}, + {Credo.Check.Warning.UnusedListOperation, []}, + {Credo.Check.Warning.UnusedPathOperation, []}, + {Credo.Check.Warning.UnusedRegexOperation, []}, + {Credo.Check.Warning.UnusedStringOperation, []}, + {Credo.Check.Warning.UnusedTupleOperation, []}, # # Controversial and experimental checks (opt-in, just remove `, false`) # + {Credo.Check.Consistency.MultiAliasImportRequireUse, false}, + {Credo.Check.Readability.Specs, false}, {Credo.Check.Refactor.ABCSize, false}, {Credo.Check.Refactor.AppendSingleItem, false}, + {Credo.Check.Refactor.DoubleBooleanNegation, false}, + {Credo.Check.Refactor.MapInto, false}, {Credo.Check.Refactor.VariableRebinding, false}, + {Credo.Check.Warning.LazyLogging, false}, {Credo.Check.Warning.MapGetUnsafePass, false}, - {Credo.Check.Consistency.MultiAliasImportRequireUse, false}, - - # - # Deprecated checks (these will be deleted after a grace period) - # - {Credo.Check.Readability.Specs, false}, - {Credo.Check.Warning.NameRedeclarationByAssignment, false}, - {Credo.Check.Warning.NameRedeclarationByCase, false}, - {Credo.Check.Warning.NameRedeclarationByDef, false}, - {Credo.Check.Warning.NameRedeclarationByFn, false} + {Credo.Check.Warning.UnsafeToAtom, false} # # Custom checks can be created using `mix credo.gen.check`. diff --git a/config/config.exs b/config/config.exs index d70ad8a..77dde22 100644 --- a/config/config.exs +++ b/config/config.exs @@ -2,4 +2,6 @@ use Mix.Config # Import environment specific config. This must remain at the bottom of this # file so it overrides the configuration defined above. -import_config "#{Mix.env()}.exs" +unless Mix.env() == :docs do + import_config "#{Mix.env()}.exs" +end diff --git a/config/dev.exs b/config/dev.exs index 099e168..b2781ac 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -4,6 +4,3 @@ config :plug_session_mnesia, table: :session, max_age: 60, cleaner_timeout: 1 - -# Clear the console before each test run -config :mix_test_watch, clear: true diff --git a/config/test.exs b/config/test.exs index 95cda5d..623c410 100644 --- a/config/test.exs +++ b/config/test.exs @@ -3,6 +3,9 @@ use Mix.Config # Print only warnings and errors during test config :logger, level: :warn +# Clear the console before each test run +config :mix_test_watch, clear: true + # Configuration for the session cleaner config :plug_session_mnesia, table: :session, diff --git a/mix.exs b/mix.exs index d237218..f5d82aa 100644 --- a/mix.exs +++ b/mix.exs @@ -47,17 +47,17 @@ defmodule PlugSessionMnesia.Mixfile do defp deps do [ # Development and test dependencies - {:credo, "~> 0.8.8", only: [:dev, :test], runtime: false}, - {:dialyxir, ">= 0.0.0", only: [:dev, :test], runtime: false}, + {:credo, "~> 1.0", only: :dev, runtime: false}, + {:dialyxir, "~> 1.0-rc", only: :dev, runtime: false}, {:excoveralls, ">= 0.0.0", only: :test, runtime: false}, - {:mix_test_watch, ">= 0.0.0", only: :dev, runtime: false}, + {:mix_test_watch, ">= 0.0.0", only: :test, runtime: false}, {:ex_unit_notifier, ">= 0.0.0", only: :test, runtime: false}, # Project dependencies {:plug, "~> 1.4", optional: true}, # Documentation dependencies - {:ex_doc, ">= 0.0.0", only: :dev, runtime: false} + {:ex_doc, "~> 0.19", only: :docs, runtime: false} ] end diff --git a/mix.lock b/mix.lock index 33fd847..0249d9d 100644 --- a/mix.lock +++ b/mix.lock @@ -1,22 +1,27 @@ %{ "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, - "certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"}, - "credo": {:hex, :credo, "0.8.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, - "dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"}, - "earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [:mix], [], "hexpm"}, - "ex_doc": {:hex, :ex_doc, "0.18.1", "37c69d2ef62f24928c1f4fdc7c724ea04aecfdf500c4329185f8e3649c915baf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, + "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"}, + "credo": {:hex, :credo, "1.1.2", "02b6422f3e659eb74b05aca3c20c1d8da0119a05ee82577a82e6c2938bf29f81", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, + "dialyxir": {:hex, :dialyxir, "1.0.0-rc.6", "78e97d9c0ff1b5521dd68041193891aebebce52fc3b93463c0a6806874557d7d", [:mix], [{:erlex, "~> 0.2.1", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm"}, + "earmark": {:hex, :earmark, "1.3.5", "0db71c8290b5bc81cb0101a2a507a76dca659513984d683119ee722828b424f6", [:mix], [], "hexpm"}, + "erlex": {:hex, :erlex, "0.2.4", "23791959df45fe8f01f388c6f7eb733cc361668cbeedd801bf491c55a029917b", [:mix], [], "hexpm"}, + "ex_doc": {:hex, :ex_doc, "0.21.1", "5ac36660846967cd869255f4426467a11672fec3d8db602c429425ce5b613b90", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, "ex_unit_notifier": {:hex, :ex_unit_notifier, "0.1.4", "36a2dcab829f506e01bf17816590680dd1474407926d43e64c1263e627c364b8", [:mix], [], "hexpm"}, - "excoveralls": {:hex, :excoveralls, "0.8.0", "99d2691d3edf8612f128be3f9869c4d44b91c67cec92186ce49470ae7a7404cf", [: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], [], "hexpm"}, - "hackney": {:hex, :hackney, "1.10.1", "c38d0ca52ea80254936a32c45bb7eb414e7a96a521b4ce76d00a69753b157f21", [: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.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm"}, + "excoveralls": {:hex, :excoveralls, "0.11.1", "dd677fbdd49114fdbdbf445540ec735808250d56b011077798316505064edb2c", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, + "file_system": {:hex, :file_system, "0.2.7", "e6f7f155970975789f26e77b8b8d8ab084c59844d8ecfaf58cbda31c494d14aa", [:mix], [], "hexpm"}, + "hackney": {:hex, :hackney, "1.15.1", "9f8f471c844b8ce395f7b6d8398139e26ddca9ebc171a8b91342ee15a19963f4", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, + "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, + "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, + "makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, - "mime": {:hex, :mime, "1.2.0", "78adaa84832b3680de06f88f0997e3ead3b451a440d183d688085be2d709b534", [:mix], [], "hexpm"}, - "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, - "mix_test_watch": {:hex, :mix_test_watch, "0.5.0", "2c322d119a4795c3431380fca2bca5afa4dc07324bd3c0b9f6b2efbdd99f5ed3", [:mix], [{:fs, "~> 0.9.1", [hex: :fs, repo: "hexpm", optional: false]}], "hexpm"}, - "plug": {:hex, :plug, "1.4.3", "236d77ce7bf3e3a2668dc0d32a9b6f1f9b1f05361019946aae49874904be4aed", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"}, - "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"}, + "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"}, + "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm"}, + "mix_test_watch": {:hex, :mix_test_watch, "0.9.0", "c72132a6071261893518fa08e121e911c9358713f62794a90c95db59042af375", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm"}, + "nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"}, + "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, + "plug": {:hex, :plug, "1.8.3", "12d5f9796dc72e8ac9614e94bda5e51c4c028d0d428e9297650d09e15a684478", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm"}, + "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm"}, } From c3fa18402cddb61abeb397339675d21a19b46896 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Cugnet Date: Sun, 4 Aug 2019 15:16:06 +0200 Subject: [PATCH 09/14] Also fix time units in tests --- test/plug_session_mnesia/cleaner_test.exs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/plug_session_mnesia/cleaner_test.exs b/test/plug_session_mnesia/cleaner_test.exs index 763e723..632ea0f 100644 --- a/test/plug_session_mnesia/cleaner_test.exs +++ b/test/plug_session_mnesia/cleaner_test.exs @@ -33,8 +33,8 @@ defmodule PlugSessionMnesia.CleanerTest do test "cleans old sessions" do now = System.os_time() - one_sec_ago = now - System.convert_time_unit(1, :seconds, :native) - five_sec_ago = now - System.convert_time_unit(5, :seconds, :native) + one_sec_ago = now - System.convert_time_unit(1, :second, :native) + five_sec_ago = now - System.convert_time_unit(5, :second, :native) session_a = {@table, "session_a", @data, five_sec_ago} session_b = {@table, "session_b", @data, one_sec_ago} @@ -60,7 +60,7 @@ defmodule PlugSessionMnesia.CleanerTest do Application.put_env(@app, :cleaner_timeout, 1) now = System.os_time() - two_sec_ago = now - System.convert_time_unit(2, :seconds, :native) + two_sec_ago = now - System.convert_time_unit(2, :second, :native) old_session = {@table, "old_session", @data, two_sec_ago} :ok = :mnesia.dirty_write(old_session) @@ -74,9 +74,9 @@ defmodule PlugSessionMnesia.CleanerTest do end defp reset_env_on_exit(_) do - on_exit fn -> + on_exit(fn -> Application.delete_env(@app, :table) Application.delete_env(@app, :max_age) - end + end) end end From d475d7f6d4deed584227909183682de795911dc5 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Cugnet Date: Sun, 4 Aug 2019 15:18:13 +0200 Subject: [PATCH 10/14] Fix Credo warnings --- lib/mix/tasks/session.setup.ex | 2 +- lib/plug_session_mnesia/helpers.ex | 2 +- test/mix/tasks/session.setup_test.exs | 2 +- test/plug_session_mnesia/helpers_test.exs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mix/tasks/session.setup.ex b/lib/mix/tasks/session.setup.ex index 3dc02e0..d582b63 100644 --- a/lib/mix/tasks/session.setup.ex +++ b/lib/mix/tasks/session.setup.ex @@ -36,8 +36,8 @@ defmodule Mix.Tasks.Session.Setup do """ alias PlugSessionMnesia.Helpers - alias PlugSessionMnesia.TableNotDefined alias PlugSessionMnesia.TableExists + alias PlugSessionMnesia.TableNotDefined @spec run(OptionParser.argv()) :: boolean() def run(_argv) do diff --git a/lib/plug_session_mnesia/helpers.ex b/lib/plug_session_mnesia/helpers.ex index 6389907..1440982 100644 --- a/lib/plug_session_mnesia/helpers.ex +++ b/lib/plug_session_mnesia/helpers.ex @@ -7,8 +7,8 @@ defmodule PlugSessionMnesia.Helpers do features like distribution, you should create the table yourself. """ - alias PlugSessionMnesia.TableNotDefined alias PlugSessionMnesia.TableExists + alias PlugSessionMnesia.TableNotDefined @typep persistence() :: :persistent | :volatile @typep return_value() :: :ok | {:error | :abort, term()} diff --git a/test/mix/tasks/session.setup_test.exs b/test/mix/tasks/session.setup_test.exs index f3833c9..d2db59f 100644 --- a/test/mix/tasks/session.setup_test.exs +++ b/test/mix/tasks/session.setup_test.exs @@ -5,8 +5,8 @@ defmodule Mix.Tasks.Session.SetupTest do import Mix.Tasks.Session.Setup - alias PlugSessionMnesia.TableNotDefined alias PlugSessionMnesia.TableExists + alias PlugSessionMnesia.TableNotDefined setup [:mnesia, :with_env] diff --git a/test/plug_session_mnesia/helpers_test.exs b/test/plug_session_mnesia/helpers_test.exs index 916e348..c2fab59 100644 --- a/test/plug_session_mnesia/helpers_test.exs +++ b/test/plug_session_mnesia/helpers_test.exs @@ -2,8 +2,8 @@ defmodule PlugSessionMnesia.HelpersTest do use PlugSessionMnesia.TestCase alias PlugSessionMnesia.Helpers - alias PlugSessionMnesia.TableNotDefined alias PlugSessionMnesia.TableExists + alias PlugSessionMnesia.TableNotDefined setup [:mnesia, :with_env] From 482587324d99d76c8cec7fac1ed58d35ad396144 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Cugnet Date: Sun, 4 Aug 2019 15:28:51 +0200 Subject: [PATCH 11/14] Run the formatter --- test/plug_session_mnesia/store_test.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/plug_session_mnesia/store_test.exs b/test/plug_session_mnesia/store_test.exs index 2eba930..526c34f 100644 --- a/test/plug_session_mnesia/store_test.exs +++ b/test/plug_session_mnesia/store_test.exs @@ -48,7 +48,7 @@ defmodule PlugSessionMnesia.StoreTest do test "does not update the timestamp if timestamp is set to :fixed" do Application.put_env(@app, :timestamp, :fixed) - on_exit fn -> Application.delete_env(@app, :timestamp) end + on_exit(fn -> Application.delete_env(@app, :timestamp) end) {_, _, _, timestamp} = session_fixture() get(nil, @sid, @table) @@ -87,7 +87,7 @@ defmodule PlugSessionMnesia.StoreTest do test "does not update the timestamp if timestamp is set to :fixed" do Application.put_env(@app, :timestamp, :fixed) - on_exit fn -> Application.delete_env(@app, :timestamp) end + on_exit(fn -> Application.delete_env(@app, :timestamp) end) {_, _, _, timestamp} = session_fixture() put(nil, @sid, @new_data, @table) From 5a230eadba270b8781fa51198902bebb30152336 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Cugnet Date: Sun, 4 Aug 2019 15:33:41 +0200 Subject: [PATCH 12/14] [CI] Do not test anymore on OTP 19.3 --- .travis.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index f451e12..13b7f36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,26 +5,17 @@ elixir: - 1.8 - 1.9 otp_release: - - 19.3 - 20.3 - 21.2 - 22.0 matrix: exclude: - - elixir: 1.6 - otp_release: 21.2 - elixir: 1.6 otp_release: 22.0 - - elixir: 1.7 - otp_release: 19.3 - elixir: 1.7 otp_release: 20.3 - - elixir: 1.8 - otp_release: 19.3 - elixir: 1.8 otp_release: 20.3 - - elixir: 1.9 - otp_release: 19.3 - elixir: 1.9 otp_release: 20.3 env: From 2dd73f1a441f409bd0a3419854ed97a949e02ab8 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Cugnet Date: Sun, 4 Aug 2019 15:38:32 +0200 Subject: [PATCH 13/14] Bump the version to 0.1.3 --- README.md | 2 +- mix.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e4e1dc4..2510e26 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ feature. To use it in your app, add this to your dependencies: ```elixir -{:plug_session_mnesia, "~> 0.1.2"} +{:plug_session_mnesia, "~> 0.1.3"} ``` Then, add to your configuration: diff --git a/mix.exs b/mix.exs index f5d82aa..f0c4f77 100644 --- a/mix.exs +++ b/mix.exs @@ -7,7 +7,7 @@ defmodule PlugSessionMnesia.Mixfile do def project do [ app: :plug_session_mnesia, - version: @version <> dev(), + version: @version, elixir: "~> 1.5", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, From 49b16711c04d2a0a07369c78bb282f27e1e6edf8 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Cugnet Date: Sun, 4 Aug 2019 15:54:39 +0200 Subject: [PATCH 14/14] Update the changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bc3254..c96406b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.1.3 + +* Fix the time units + ## v0.1.2 * Add an index on timestamp