Skip to content

Commit

Permalink
Merge pull request #51 from paulo-ferraz-oliveira/feature/minor-maint…
Browse files Browse the repository at this point in the history
…enance-updates

Maintenance updates
  • Loading branch information
elbrujohalcon committed Sep 18, 2023
2 parents 41ea782 + f0cf691 commit cb28221
Show file tree
Hide file tree
Showing 16 changed files with 648 additions and 744 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/erlang.yml
@@ -0,0 +1,47 @@
---
name: Erlang CI

"on": [push, pull_request]

jobs:
build:
runs-on: ubuntu-22.04

strategy:
matrix:
otp: ['24', '25', '26']
rebar: ['3.22']

steps:
- uses: actions/checkout@v3
- uses: erlef/setup-beam@v1
id: setup-beam
with:
otp-version: ${{matrix.otp}}
rebar3-version: ${{matrix.rebar}}
- name: Restore _build
uses: actions/cache@v3
with:
path: _build
key: "_build-cache-for\
-os-${{runner.os}}\
-otp-${{steps.setup-beam.outputs.otp-version}}\
-rebar3-${{steps.setup-beam.outputs.rebar3-version}}\
-hash-${{hashFiles('rebar.lock')}}"
- name: Restore rebar3's cache
uses: actions/cache@v3
with:
path: ~/.cache/rebar3
key: "rebar3-cache-for\
-os-${{runner.os}}\
-otp-${{steps.setup-beam.outputs.otp-version}}\
-rebar3-${{steps.setup-beam.outputs.rebar3-version}}\
-hash-${{hashFiles('rebar.lock')}}"
- name: Compile
run: rebar3 compile
- name: Format check
run: rebar3 format --verify
- name: Run tests and verifications
run: rebar3 test
- name: Run meta verifications
run: rebar3 as test test
29 changes: 29 additions & 0 deletions .github/workflows/lint.yml
@@ -0,0 +1,29 @@
---
name: Lint

"on": [push, pull_request]

jobs:
build:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

# uses .markdownlint-cli2.yaml for configuration
- name: markdownlint
uses: DavidAnson/markdownlint-cli2-action@v11
with:
globs: |
*.md
LICENSE
!CHANGELOG.md
- name: yamllint
uses: ibiqlik/action-yamllint@v3
with:
file_or_dir: |
.github/**/erlang.yml
.*.yml
strict: true
config_file: .yamllint.yml
15 changes: 4 additions & 11 deletions .gitignore
@@ -1,13 +1,6 @@
doc/
.erlang.mk/
zipper.d
.eunit
deps
*.o
*.beam
*.plt
erl_crash.dump
ebin
.erlang.mk.*
log*/
_build/
rebar3.crashdump
.rebar3
_*
logs
4 changes: 4 additions & 0 deletions .markdownlint.yml
@@ -0,0 +1,4 @@
---
default: true
MD013:
line_length: 100
5 changes: 5 additions & 0 deletions .yamllint.yml
@@ -0,0 +1,5 @@
---
extends: default
rules:
line-length:
max: 100
7 changes: 4 additions & 3 deletions LICENSE
@@ -1,6 +1,7 @@
Apache License
# Apache License

Version 2.0, January 2004
http://www.apache.org/licenses/
https://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

Expand Down Expand Up @@ -192,7 +193,7 @@ Apache License
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
20 changes: 15 additions & 5 deletions README.md
@@ -1,13 +1,17 @@
# Zipper [![GitHub Actions CI](https://github.com/inaka/zipper/workflows/build/badge.svg)](https://github.com/inaka/zipper)

Generic zipper implementation in Erlang.

## Zippers: what are they good for?

Zippers let you traverse immutable data structures with ease and flexibility.

### Contact Us
If you find any **bugs** or have a **problem** while using this library, please [open an issue](https://github.com/inaka/zipper/issues/new) in this repo (or a pull request :)).

And you can check all of our open-source projects at [inaka.github.io](http://inaka.github.io)
If you find any **bugs** or have a **problem** while using this library, please
[open an issue](https://github.com/inaka/zipper/issues/new) in this repo (or a pull request :)).

And you can check all of our open-source projects at [inaka.github.io](https://inaka.github.io)

## Usage

Expand Down Expand Up @@ -44,6 +48,7 @@ Root = #{type => planet,
```

You can build a zipper by providing three simple functions:

- `IsBranchFun`: takes a node and returns `true` if it is a branch node or
`false` otherwise.
- `ChildrenFun`: takes a node and returns a list of its children.
Expand Down Expand Up @@ -85,7 +90,10 @@ io:format("~p", [America]),

## Tests

Circular dependency in test environment ([Katana Test](https://github.com/inaka/katana-test) -> [Elvis Core](https://github.com/inaka/elvis_core) -> [Zipper](https://github.com/inaka/zipper)) is fixed by including Zipper as a dep in the test profile in `rebar.config`
Circular dependency in test environment ([Katana Test](https://github.com/inaka/katana-test) ->
[Elvis Core](https://github.com/inaka/elvis_core) -> [Zipper](https://github.com/inaka/zipper)) is
fixed by including Zipper as a dep in the test profile in `rebar.config`

```erlang
...
{profiles, [
Expand All @@ -99,10 +107,12 @@ Circular dependency in test environment ([Katana Test](https://github.com/inaka/
]}.
...
```

but then, we still replace the tag with the current branch. This is done in `rebar.config.script`.
Therefore, it's really important to have the branch updated and pushed to github before running the tests with `rebar3 ct`.
Therefore, it's really important to have the branch updated and pushed to github before running the
tests with `rebar3 ct`.

## References

- [The Zipper, GERARD HUET](https://www.st.cs.uni-saarland.de/edu/seminare/2005/advanced-fp/docs/huet-zipper.pdf)
- [clojure.zip](http://clojure.github.io/clojure/clojure.zip-api.html#clojure.zip/zipper)
- [clojure.zip](https://clojure.github.io/clojure/clojure.zip-api.html#clojure.zip/zipper)
69 changes: 11 additions & 58 deletions elvis.config
@@ -1,58 +1,11 @@
[
{
elvis,
[
{config,
[#{dirs => ["src", "test"],
filter => "*.erl",
rules => [{elvis_style, line_length, #{limit => 80,
skip_comments => false}},
{elvis_style, no_tabs},
{elvis_style, no_trailing_whitespace},
{elvis_style, macro_names},
{elvis_style, macro_module_names},
{elvis_style, operator_spaces, #{rules => [{right, ","},
{right, "++"},
{left, "++"}]}},
{elvis_style, nesting_level, #{level => 3}},
{elvis_style, god_modules, #{limit => 30}},
{elvis_style, no_if_expression},
{elvis_style, invalid_dynamic_call},
{elvis_style, used_ignored_variable},
{elvis_style, no_behavior_info},
{
elvis_style,
module_naming_convention,
#{regex => "^([a-z][a-z0-9]*_?)*(_SUITE)?$",
ignore => []}
},
{
elvis_style,
function_naming_convention,
#{regex => "^([a-z][a-z0-9]*_?)*$"}
},
{elvis_style, state_record_and_type},
{elvis_style, no_spec_with_records},
{elvis_style, dont_repeat_yourself, #{min_complexity => 18}},
{elvis_style, no_debug_call}
]
},
#{dirs => ["."],
filter => "Makefile",
rules => [{elvis_project, no_deps_master_erlang_mk},
{elvis_project, protocol_for_deps_erlang_mk, #{regex => "(https://.*|[0-9]+([.][0-9]+)*)"}}]
},
#{dirs => ["."],
filter => "rebar.config",
rules => [{elvis_project, no_deps_master_rebar},
{elvis_project, protocol_for_deps_rebar}]
},
#{dirs => ["."],
filter => "elvis.config",
rules => [{elvis_project, old_configuration_format}]
}
]
}
]
}
].
[{elvis,
[{config,
[#{dirs => ["src", "test"],
filter => "*.erl",
ruleset => erl_files},
#{dirs => ["."],
filter => "rebar.config",
ruleset => rebar_config},
#{dirs => ["."],
filter => "elvis.config",
ruleset => elvis_config}]}]}].
141 changes: 56 additions & 85 deletions rebar.config
@@ -1,85 +1,56 @@
%% -*- mode: erlang;erlang-indent-level: 2;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 ft=erlang et

%% == Erlang Compiler ==

%% Erlang compiler options
{erl_opts, [
warn_unused_vars,
warn_export_all,
warn_shadow_vars,
warn_unused_import,
warn_unused_function,
warn_bif_clash,
warn_unused_record,
warn_deprecated_function,
warn_obsolete_guard,
strict_validation,
warn_export_vars,
warn_exported_vars,
warn_missing_spec,
warn_untyped_record, debug_info
]}.

{profiles, [
{test, [
{deps, [
{xref_runner, "1.0.0"}
]}
]},
{shell, [
{deps, [
{sync, {git, "https://github.com/rustyio/sync.git", {ref, "9c78e7b"}}}
]}
]}
]}.

%% == Common Test ==

%% {erl_opts, [...]}, but for CT runs
{ct_compile_opts, [
warn_unused_vars,
warn_export_all,
warn_shadow_vars,
warn_unused_import,
warn_unused_function,
warn_bif_clash,
warn_unused_record,
warn_deprecated_function,
warn_obsolete_guard,
strict_validation,
warn_export_vars,
warn_exported_vars,
warn_missing_spec,
warn_untyped_record, debug_info
]}.

{ct_opts, []}.

%% == Cover ==

{cover_enabled, true}.

{cover_opts, [verbose]}.

%% == Dependencies ==

{deps, []}.

%% == Dialyzer ==

{dialyzer, [
{warnings, [ unmatched_returns
, error_handling
]},
{get_warnings, true},
{plt_apps, top_level_deps},
{plt_extra_apps, []},
{plt_location, local},
{base_plt_apps, [stdlib, kernel]},
{base_plt_location, global}
]}.

%% == Shell ==

{shell, [{apps, [sync]}]}.
%% == Compiler and Profiles ==

{erl_opts,
[warn_unused_import, warn_export_vars, warnings_as_errors, verbose, report, debug_info]}.

{minimum_otp_vsn, "24"}.

{profiles,
[{test,
[{cover_enabled, true},
{cover_opts, [verbose]},
{ct_opts, [{verbose, true}]},
{dialyzer,
[{warnings, [no_return, unmatched_returns, error_handling, unknown]},
{plt_extra_apps, [syntax_tools]}]}]},
{shell, [{deps, [{sync, "0.4.1"}]}, {apps, [sync]}]}]}.

{alias, [{test, [compile, format, hank, lint, xref, dialyzer, ct, cover, ex_doc]}]}.

%% == Dependencies and plugins ==

{project_plugins,
[{rebar3_hank, "~> 1.4.0"},
{rebar3_hex, "~> 7.0.7"},
{rebar3_format, "~> 1.3.0"},
{rebar3_lint, "~> 3.1.0"},
{rebar3_ex_doc, "~> 0.2.20"}]}.

%% == Documentation ==

{ex_doc,
[{source_url, <<"https://github.com/inaka/zipper">>},
{extras, [<<"README.md">>, <<"LICENSE">>]},
{main, <<"README.md">>},
{prefix_ref_vsn_with_v, false}]}.

{hex, [{doc, #{provider => ex_doc}}]}.

%% == Format ==

{format, [{files, ["*.config", "src/*", "test/*"]}]}.

%% == Hank ==

{hank, [{ignore, [{"test/*.erl", unnecessary_function_arguments}]}]}.

%% == Dialyzer + XRef ==

{dialyzer,
[{warnings, [no_return, unmatched_returns, error_handling, unknown]},
{plt_extra_apps, [syntax_tools]}]}.

{xref_checks,
[undefined_function_calls, deprecated_function_calls, deprecated_functions]}.

{xref_extra_paths, ["test/**"]}.

0 comments on commit cb28221

Please sign in to comment.