Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintenance updates #51

Merged
merged 22 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b7193f2
Preemptively accept format results
paulo-ferraz-oliveira Aug 4, 2023
4bc1263
Make Elvis rock
paulo-ferraz-oliveira Aug 4, 2023
ce966bf
Have tests pass
paulo-ferraz-oliveira Aug 5, 2023
6205dc9
Ease maintenance of .gitignore
paulo-ferraz-oliveira Aug 6, 2023
e85e723
Adapt to ex_doc
paulo-ferraz-oliveira Aug 7, 2023
ae1f4c0
Further accept format results
paulo-ferraz-oliveira Aug 7, 2023
0a2b769
Modernize rebar.config
paulo-ferraz-oliveira Aug 7, 2023
98cb5ad
Move http:// to https://
paulo-ferraz-oliveira Aug 7, 2023
4f3c984
Accept elvis' defaults
paulo-ferraz-oliveira Aug 7, 2023
0c1eb56
Add a header to the README
paulo-ferraz-oliveira Aug 7, 2023
6074e08
Lint README.md
paulo-ferraz-oliveira Aug 7, 2023
0567e58
Increase consumer confidence
paulo-ferraz-oliveira Aug 7, 2023
6e62aaa
Fix as per CI results: OTP 26 errors out on option race_conditions
paulo-ferraz-oliveira Aug 7, 2023
fb58fb2
Fix as per CI results: don't run yamllint on CHANGELOG.md
paulo-ferraz-oliveira Aug 7, 2023
cd4e7ba
Fix as per CI results: LICENSE was not valid Markdown
paulo-ferraz-oliveira Aug 7, 2023
981d55d
Fix as per CI results: README.md was not valid Markdown
paulo-ferraz-oliveira Aug 7, 2023
edbdd14
Fix as per CI results: yamllint and truthy values
paulo-ferraz-oliveira Aug 7, 2023
93d7429
Fix as per CI results: replace meta SUITE with GitHub CI
paulo-ferraz-oliveira Aug 7, 2023
8f02292
Act on self-review: move .md to where it's supposed to be found
paulo-ferraz-oliveira Aug 7, 2023
c0a28b1
Act on self-review: trick the formatter too :)
paulo-ferraz-oliveira Aug 7, 2023
f11e328
Act on self-review: generate a proper link
paulo-ferraz-oliveira Aug 7, 2023
f0cf691
Update plugins versions
paulo-ferraz-oliveira Aug 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/erlang.yml
Original file line number Diff line number Diff line change
@@ -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
paulo-ferraz-oliveira marked this conversation as resolved.
Show resolved Hide resolved
29 changes: 29 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
default: true
MD013:
line_length: 100
7 changes: 7 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
extends: default
rules:
line-length:
max: 100
ignore: |
CHANGELOG.md
paulo-ferraz-oliveira marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 4 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
paulo-ferraz-oliveira marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -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}]}]}].
140 changes: 55 additions & 85 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,85 +1,55 @@
%% -*- 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.0.1"},
{rebar3_ex_doc, "0.2.18"}]}.

%% == Documentation ==

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

{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/**"]}.