Skip to content

Commit 3b223f2

Browse files
Merge pull request #107 from paulo-ferraz-oliveira/feature/minor-maintenance-updates
Maintenance updates
2 parents 8bd861f + a3436a9 commit 3b223f2

21 files changed

+615
-688
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,36 @@
11
---
22
name: build
3-
on:
4-
push:
5-
branches:
6-
- master
7-
pull_request:
8-
branches:
9-
- master
3+
on: [push, pull_request]
104
jobs:
115
ci:
12-
name: Run checks and tests over ${{matrix.otp_vsn}} and ${{matrix.os}}
13-
runs-on: ${{matrix.os}}
6+
name: Run checks and tests over ${{matrix.otp_vsn}}
7+
runs-on: ubuntu-22.04
148
strategy:
159
matrix:
16-
otp_vsn: [21, 22, 23, 24]
17-
os: [ubuntu-latest]
10+
otp_vsn: ['24', '25', '26']
11+
rebar3_vsn: ['3.22']
1812
steps:
19-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
2014
- uses: erlef/setup-beam@v1
2115
with:
2216
otp-version: ${{matrix.otp_vsn}}
23-
rebar3-version: '3.14'
17+
rebar3-version: ${{matrix.rebar3_vsn}}
2418
- run: |
2519
rm -rf example/_checkouts # Prevent long running analysis
2620
rebar3 test
2721
example:
28-
name: Makes sure our example run over ${{matrix.otp_vsn}} and ${{matrix.os}}
29-
runs-on: ${{matrix.os}}
22+
name: Makes sure our example run over ${{matrix.otp_vsn}}
23+
runs-on: ubuntu-22.04
3024
strategy:
3125
matrix:
32-
otp_vsn: [21, 22, 23, 24]
33-
os: [ubuntu-latest]
26+
otp_vsn: ['24', '25', '26']
27+
rebar3_vsn: ['3.22']
3428
steps:
35-
- uses: actions/checkout@v2
29+
- uses: actions/checkout@v3
3630
- uses: erlef/setup-beam@v1
3731
with:
3832
otp-version: ${{matrix.otp_vsn}}
39-
rebar3-version: '3.14'
33+
rebar3-version: ${{matrix.rebar3_vsn}}
4034
- name: test our example
4135
run: |
4236
cd example
@@ -53,6 +47,10 @@ jobs:
5347
R=$(curl -s -w "%{http_code}" -XDELETE "localhost:8080/poor-kv/some-key" -H "content-type: text/plain")
5448
[[ $R == "404" ]] || exit 1
5549
_build/default/rel/example/bin/example stop
50+
- name: Format check
51+
run: |
52+
cd example
53+
rebar3 format --verify
5654
- name: check our example
5755
run: |
5856
cd example

.gitignore

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
logs/
2-
.eunit
3-
deps
4-
*.o
5-
*.beam
6-
*.plt
7-
erl_crash.dump
8-
ebin
9-
rel/example_project
10-
.concrete/DEV_MODE
11-
.rebar
12-
.erlang.mk*
13-
elvis
14-
*.d
15-
_build
16-
/rebar.lock
17-
doc
18-
rebar3.crashdump
2+
_*
3+
doc/
4+
rebar3.crashdump
5+
.rebar3
6+
logs

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Apache License
22
Version 2.0, January 2004
3-
http://www.apache.org/licenses/
3+
https://www.apache.org/licenses/
44

55
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
66

@@ -192,7 +192,7 @@
192192
you may not use this file except in compliance with the License.
193193
You may obtain a copy of the License at
194194

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

197197
Unless required by applicable law or agreed to in writing, software
198198
distributed under the License is distributed on an "AS IS" BASIS,

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ If you find any **bugs** or have a **problem** while using this library, please
1212
[open an issue](https://github.com/inaka/cowboy-trails/issues/new) in this repo
1313
(or a pull request 😄).
1414

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

1717
## Why Cowboy Trails?
1818

@@ -104,11 +104,13 @@ Dispatch = cowboy_router:compile(Routes),
104104

105105
But now, with `trails`, you're able to define the routes on each of your resource handlers,
106106
separately.
107-
These handlers must implement callback `trails/0` or `trails/1` and return the specific
107+
These handlers must implement callback `c:trails_handler:trails/0` or `c:trails_handler:trails/1`
108+
and return the specific
108109
routes that define them. For a better understanding, you can check out the
109-
examples in the `test` folder ([trails_test_handler](./test/trails_test_handler.erl)).
110+
examples in the `test` folder ([trails_test_handler](https://github.com/inaka/cowboy-trails/blob/master/test/trails_test_handler.erl)).
110111

111-
Once you have implemented the `trails/0` or `trails/1` callback on your handlers, you can do
112+
Once you have implemented the `c:trails_handler:trails/0` or `c:trails_handler:trails/1` callback
113+
on your handlers, you can do
112114
something like this:
113115

114116
```erlang
@@ -137,4 +139,4 @@ merge them easily.
137139
## Example
138140

139141
For more information about `cowboy_trails`, how to use it and the different
140-
functions that it exposes, please check this [example](./example).
142+
functions that it exposes, please check this [example](https://github.com/inaka/cowboy-trails/blob/master/example).

elvis.config

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
1-
[
2-
{
3-
elvis,
4-
[
5-
{config,
6-
[#{dirs => ["src", "test"],
7-
filter => "*.erl",
8-
rules => [{elvis_style, invalid_dynamic_call, #{ignore => [trails_handler]}},
9-
{elvis_style, dont_repeat_yourself, #{min_complexity => 14}},
10-
{elvis_style, god_modules, #{ ignore => [trails_SUITE]}}],
11-
ruleset => erl_files
12-
},
13-
#{dirs => ["."],
14-
filter => "rebar.config",
15-
ruleset => rebar_config
16-
},
17-
#{dirs => ["."],
18-
filter => "elvis.config",
19-
ruleset => elvis_config
20-
}
21-
]
22-
}
23-
]
24-
}
25-
].
1+
[{elvis,
2+
[{config,
3+
[#{dirs => ["src", "test"],
4+
filter => "*.erl",
5+
rules =>
6+
[{elvis_style, invalid_dynamic_call, #{ignore => [trails_handler]}},
7+
{elvis_style, dont_repeat_yourself, #{min_complexity => 14}},
8+
{elvis_style, god_modules, #{ignore => [trails_SUITE]}}],
9+
ruleset => erl_files},
10+
#{dirs => ["."],
11+
filter => "rebar.config",
12+
ruleset => rebar_config},
13+
#{dirs => ["."],
14+
filter => "elvis.config",
15+
ruleset => elvis_config}]}]}].

example/rebar.config

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
1-
%% -*- mode: erlang;erlang-indent-level: 2;indent-tabs-mode: nil -*-
2-
%% ex: ts=4 sw=4 ft=erlang et
1+
%% == Compiler and Profiles ==
32

4-
%% == Erlang Compiler ==
5-
6-
%% Erlang compiler options
73
{erl_opts,
8-
[warn_unused_vars,
9-
warn_export_all,
10-
warn_shadow_vars,
11-
warn_unused_import,
12-
warn_unused_function,
13-
warn_bif_clash,
14-
warn_unused_record,
15-
warn_deprecated_function,
16-
warn_obsolete_guard,
17-
strict_validation,
18-
warn_export_vars,
19-
warn_exported_vars,
20-
warn_untyped_record,
21-
debug_info]}.
22-
23-
%% == Dependencies ==
24-
25-
{deps,
26-
[{mixer, "1.2.0", {pkg, inaka_mixer}},
27-
trails]}. % checked out
28-
29-
{project_plugins, [rebar3_lint, rebar3_hank, rebar3_format]}.
4+
[warn_unused_import, warn_export_vars, warnings_as_errors, verbose, report, debug_info]}.
5+
6+
{minimum_otp_vsn, "23"}.
7+
8+
{alias, [{test, [compile, format, hank, lint, xref, dialyzer]}]}.
9+
10+
%% == Dependencies and plugins ==
11+
12+
{deps, [{mixer, "1.2.0", {pkg, inaka_mixer}}, trails]}. % checked out
13+
14+
{project_plugins,
15+
[{rebar3_hank, "~> 1.4.0"}, {rebar3_format, "~> 1.3.0"}, {rebar3_lint, "~> 3.0.1"}]}.
16+
17+
%% == Format ==
18+
19+
{format, [{files, ["*.config", "src/*"]}]}.
20+
21+
%% == Hank ==
22+
23+
{hank, [{ignore, ["_build/**", "_checkouts"]}]}.
24+
25+
%% == Dialyzer + XRef ==
26+
27+
{dialyzer,
28+
[{warnings, [no_return, underspecs, unmatched_returns, error_handling, unknown]}]}.
29+
30+
{xref_checks,
31+
[undefined_function_calls, deprecated_function_calls, deprecated_functions]}.
32+
33+
{xref_extra_paths, ["test/**"]}.
3034

3135
%% == Shell (for interactive example) ==
3236

@@ -38,17 +42,5 @@
3842
[{include_src, false},
3943
{extended_start_script, true},
4044
{release, {example, "0.1"}, [example, sasl]},
41-
{sys_config, "rel/sys.config"}]}.
42-
43-
%% == Alias ==
44-
45-
{alias, [{test, [dialyzer, lint, hank]}]}.
46-
47-
%% == hank ==
48-
49-
{hank, [
50-
{ignore, [
51-
"_build/**",
52-
"_checkouts/**"
53-
]}
54-
]}.
45+
{sys_config, "rel/sys.config"},
46+
{vm_args, "rel/vm.args"}]}.

example/rel/sys.config

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
[{example,
2-
[{http_port, 8080},
3-
{http_listener_count, 10}]}
4-
].
1+
[{example, [{http_port, 8080}, {http_listener_count, 10}]}].

example/rel/vm.args

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-name example@127.0.0.1
2+
-setcookie bogus

example/src/example.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ stop(_State) ->
2929
ok = cowboy:stop_listener(example_http).
3030

3131
% start_listeners() ->
32-
-spec start_phase(atom(), application:start_type(), []) -> ok | {error, term()}.
32+
-spec start_phase(atom(), application:start_type(), []) -> ok.
3333
start_phase(start_trails_http, _StartType, []) ->
3434
{ok, Port} = application:get_env(example, http_port),
3535
{ok, ListenerCount} = application:get_env(example, http_listener_count),

0 commit comments

Comments
 (0)