Merge pull request #6064 from zmstone/style-check-newline-at-eof
Style: check newline at EOF
This commit is contained in:
commit
3b02366a5b
|
@ -0,0 +1,27 @@
|
||||||
|
name: Code style check
|
||||||
|
|
||||||
|
on: [pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 1000
|
||||||
|
- name: Set git token
|
||||||
|
if: endsWith(github.repository, 'enterprise')
|
||||||
|
run: |
|
||||||
|
echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
|
||||||
|
git config --global credential.helper store
|
||||||
|
- name: Run elvis check
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
if [ -f EMQX_ENTERPRISE ]; then
|
||||||
|
./scripts/elvis-check.sh $GITHUB_BASE_REF emqx-enterprise
|
||||||
|
else
|
||||||
|
./scripts/elvis-check.sh $GITHUB_BASE_REF emqx
|
||||||
|
fi
|
||||||
|
- name: Check line-break at EOF
|
||||||
|
- run: |
|
||||||
|
./scripts/check-nl-at-eof.sh
|
|
@ -1,16 +0,0 @@
|
||||||
name: Elvis Linter
|
|
||||||
|
|
||||||
on: [pull_request]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Set git token
|
|
||||||
if: endsWith(github.repository, 'enterprise')
|
|
||||||
run: |
|
|
||||||
echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
|
|
||||||
git config --global credential.helper store
|
|
||||||
- run: |
|
|
||||||
./scripts/elvis-check.sh $GITHUB_BASE_REF
|
|
|
@ -79,4 +79,4 @@ Just as in the **subject**, use the imperative, present tense: "change" not "cha
|
||||||
|
|
||||||
The footer should contain any information about **Breaking Changes** and is also the place to reference GitHub issues that this commit **Closes**.
|
The footer should contain any information about **Breaking Changes** and is also the place to reference GitHub issues that this commit **Closes**.
|
||||||
|
|
||||||
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
|
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
|
||||||
|
|
|
@ -41,7 +41,7 @@ t_lookup_subpid(_) ->
|
||||||
emqx_broker_helper:register_sub(self(), <<"clientid">>),
|
emqx_broker_helper:register_sub(self(), <<"clientid">>),
|
||||||
ct:sleep(10),
|
ct:sleep(10),
|
||||||
?assertEqual(self(), emqx_broker_helper:lookup_subpid(<<"clientid">>)).
|
?assertEqual(self(), emqx_broker_helper:lookup_subpid(<<"clientid">>)).
|
||||||
|
|
||||||
t_register_sub(_) ->
|
t_register_sub(_) ->
|
||||||
ok = emqx_broker_helper:register_sub(self(), <<"clientid">>),
|
ok = emqx_broker_helper:register_sub(self(), <<"clientid">>),
|
||||||
ct:sleep(10),
|
ct:sleep(10),
|
||||||
|
@ -62,7 +62,7 @@ t_shard_seq(_) ->
|
||||||
|
|
||||||
t_shards_num(_) ->
|
t_shards_num(_) ->
|
||||||
?assertEqual(emqx_vm:schedulers() * 32, emqx_broker_helper:shards_num()).
|
?assertEqual(emqx_vm:schedulers() * 32, emqx_broker_helper:shards_num()).
|
||||||
|
|
||||||
t_get_sub_shard(_) ->
|
t_get_sub_shard(_) ->
|
||||||
?assertEqual(0, emqx_broker_helper:get_sub_shard(self(), <<"topic">>)).
|
?assertEqual(0, emqx_broker_helper:get_sub_shard(self(), <<"topic">>)).
|
||||||
|
|
||||||
|
@ -72,4 +72,4 @@ t_terminate(_) ->
|
||||||
t_uncovered_func(_) ->
|
t_uncovered_func(_) ->
|
||||||
gen_server:call(emqx_broker_helper, test),
|
gen_server:call(emqx_broker_helper, test),
|
||||||
gen_server:cast(emqx_broker_helper, test),
|
gen_server:cast(emqx_broker_helper, test),
|
||||||
emqx_broker_helper ! test.
|
emqx_broker_helper ! test.
|
||||||
|
|
|
@ -112,7 +112,8 @@ t_out(_) ->
|
||||||
t_out_2(_) ->
|
t_out_2(_) ->
|
||||||
{empty, {pqueue, [{-1, {queue, [a], [], 1}}]}} = ?PQ:out(0, ?PQ:from_list([{1, a}])),
|
{empty, {pqueue, [{-1, {queue, [a], [], 1}}]}} = ?PQ:out(0, ?PQ:from_list([{1, a}])),
|
||||||
{{value, a}, {queue, [], [], 0}} = ?PQ:out(1, ?PQ:from_list([{1, a}])),
|
{{value, a}, {queue, [], [], 0}} = ?PQ:out(1, ?PQ:from_list([{1, a}])),
|
||||||
{{value, a}, {pqueue, [{-1, {queue, [], [b], 1}}]}} = ?PQ:out(1, ?PQ:from_list([{1, a}, {1, b}])),
|
{{value, a}, {pqueue, [{-1, {queue, [], [b], 1}}]}} =
|
||||||
|
?PQ:out(1, ?PQ:from_list([{1, a}, {1, b}])),
|
||||||
{{value, a}, {queue, [b], [], 1}} = ?PQ:out(1, ?PQ:from_list([{1, a}, {0, b}])).
|
{{value, a}, {queue, [b], [], 1}} = ?PQ:out(1, ?PQ:from_list([{1, a}, {0, b}])).
|
||||||
|
|
||||||
t_out_p(_) ->
|
t_out_p(_) ->
|
||||||
|
@ -174,4 +175,4 @@ t_filter(_) ->
|
||||||
t_highest(_) ->
|
t_highest(_) ->
|
||||||
empty = ?PQ:highest(?PQ:new()),
|
empty = ?PQ:highest(?PQ:new()),
|
||||||
0 = ?PQ:highest(?PQ:from_list([{0, a}, {0, b}])),
|
0 = ?PQ:highest(?PQ:from_list([{0, a}, {0, b}])),
|
||||||
2 = ?PQ:highest(?PQ:from_list([{0, a}, {0, b}, {1, c}, {2, d}, {2, e}])).
|
2 = ?PQ:highest(?PQ:from_list([{0, a}, {0, b}, {1, c}, {2, d}, {2, e}])).
|
||||||
|
|
|
@ -36,4 +36,4 @@ t_child(_) ->
|
||||||
?assertMatch({error, not_found}, emqx_sup:stop_child(undef)),
|
?assertMatch({error, not_found}, emqx_sup:stop_child(undef)),
|
||||||
?assertMatch({error, _}, emqx_sup:start_child(emqx_broker_sup, supervisor)),
|
?assertMatch({error, _}, emqx_sup:start_child(emqx_broker_sup, supervisor)),
|
||||||
?assertEqual(ok, emqx_sup:stop_child(emqx_broker_sup)),
|
?assertEqual(ok, emqx_sup:stop_child(emqx_broker_sup)),
|
||||||
?assertMatch({ok, _}, emqx_sup:start_child(emqx_broker_sup, supervisor)).
|
?assertMatch({ok, _}, emqx_sup:start_child(emqx_broker_sup, supervisor)).
|
||||||
|
|
|
@ -19,4 +19,4 @@
|
||||||
-compile(export_all).
|
-compile(export_all).
|
||||||
-compile(nowarn_export_all).
|
-compile(nowarn_export_all).
|
||||||
|
|
||||||
all() -> emqx_common_test_helpers:all(?MODULE).
|
all() -> emqx_common_test_helpers:all(?MODULE).
|
||||||
|
|
|
@ -100,7 +100,8 @@ on_start(InstId, #{redis_type := Type,
|
||||||
Options = case maps:get(enable, SSL) of
|
Options = case maps:get(enable, SSL) of
|
||||||
true ->
|
true ->
|
||||||
[{ssl, true},
|
[{ssl, true},
|
||||||
{ssl_options, emqx_plugin_libs_ssl:save_files_return_opts(SSL, "connectors", InstId)}
|
{ssl_options,
|
||||||
|
emqx_plugin_libs_ssl:save_files_return_opts(SSL, "connectors", InstId)}
|
||||||
];
|
];
|
||||||
false -> [{ssl, false}]
|
false -> [{ssl, false}]
|
||||||
end ++ [{sentinel, maps:get(sentinel, Config, undefined)}],
|
end ++ [{sentinel, maps:get(sentinel, Config, undefined)}],
|
||||||
|
@ -182,4 +183,4 @@ to_server(Server) ->
|
||||||
case string:tokens(Server, ":") of
|
case string:tokens(Server, ":") of
|
||||||
[Host, Port] -> {ok, {Host, list_to_integer(Port)}};
|
[Host, Port] -> {ok, {Host, list_to_integer(Port)}};
|
||||||
_ -> {error, Server}
|
_ -> {error, Server}
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -47,4 +47,4 @@ emqx_limiter {
|
||||||
per_client = "100/10s,10"
|
per_client = "100/10s,10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2099,4 +2099,4 @@
|
||||||
"title": "EMQ",
|
"title": "EMQ",
|
||||||
"uid": "tjRlQw6Zk",
|
"uid": "tjRlQw6Zk",
|
||||||
"version": 29
|
"version": 29
|
||||||
}
|
}
|
||||||
|
|
|
@ -630,4 +630,4 @@
|
||||||
"title": "EMQ Dashboard",
|
"title": "EMQ Dashboard",
|
||||||
"uid": "5sreUw6Wz",
|
"uid": "5sreUw6Wz",
|
||||||
"version": 11
|
"version": 11
|
||||||
}
|
}
|
||||||
|
|
|
@ -1471,4 +1471,4 @@
|
||||||
"title": "ErlangVM",
|
"title": "ErlangVM",
|
||||||
"uid": "stprQQ6Zk",
|
"uid": "stprQQ6Zk",
|
||||||
"version": 13
|
"version": 13
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,4 +8,4 @@
|
||||||
"bulk": "10KB"
|
"bulk": "10KB"
|
||||||
"chars_limit": 1024
|
"chars_limit": 1024
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,4 +55,4 @@ ensure_pool_worker(Pool, Name, Slot) ->
|
||||||
try gproc_pool:add_worker(Pool, Name, Slot)
|
try gproc_pool:add_worker(Pool, Name, Slot)
|
||||||
catch
|
catch
|
||||||
error:exists -> ok
|
error:exists -> ok
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -13,4 +13,4 @@
|
||||||
%% See the License for the specific language governing permissions and
|
%% See the License for the specific language governing permissions and
|
||||||
%% limitations under the License.
|
%% limitations under the License.
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
-module(emqx_resource_uitils).
|
-module(emqx_resource_uitils).
|
||||||
|
|
|
@ -23,4 +23,4 @@ logs/
|
||||||
rebar.lock
|
rebar.lock
|
||||||
test/ct.cover.spec
|
test/ct.cover.spec
|
||||||
etc/emqx_retainer.conf.rendered
|
etc/emqx_retainer.conf.rendered
|
||||||
.rebar3/
|
.rebar3/
|
||||||
|
|
|
@ -33,7 +33,7 @@ nested_get({var, Key}, Data, Default) ->
|
||||||
nested_get({path, Path}, Data, Default) when is_list(Path) ->
|
nested_get({path, Path}, Data, Default) when is_list(Path) ->
|
||||||
do_nested_get(Path, Data, Data, Default).
|
do_nested_get(Path, Data, Data, Default).
|
||||||
|
|
||||||
do_nested_get([Key|More], Data, OrgData, Default) ->
|
do_nested_get([Key | More], Data, OrgData, Default) ->
|
||||||
case general_map_get(Key, Data, OrgData, undefined) of
|
case general_map_get(Key, Data, OrgData, undefined) of
|
||||||
undefined -> Default;
|
undefined -> Default;
|
||||||
Val -> do_nested_get(More, Val, OrgData, Default)
|
Val -> do_nested_get(More, Val, OrgData, Default)
|
||||||
|
@ -51,7 +51,7 @@ nested_put({var, Key}, Val, Map) ->
|
||||||
nested_put({path, Path}, Val, Map) when is_list(Path) ->
|
nested_put({path, Path}, Val, Map) when is_list(Path) ->
|
||||||
do_nested_put(Path, Val, Map, Map).
|
do_nested_put(Path, Val, Map, Map).
|
||||||
|
|
||||||
do_nested_put([Key|More], Val, Map, OrgData) ->
|
do_nested_put([Key | More], Val, Map, OrgData) ->
|
||||||
SubMap = general_map_get(Key, Map, OrgData, undefined),
|
SubMap = general_map_get(Key, Map, OrgData, undefined),
|
||||||
general_map_put(Key, do_nested_put(More, Val, SubMap, OrgData), Map, OrgData);
|
general_map_put(Key, do_nested_put(More, Val, SubMap, OrgData), Map, OrgData);
|
||||||
do_nested_put([], Val, _Map, _OrgData) ->
|
do_nested_put([], Val, _Map, _OrgData) ->
|
||||||
|
@ -131,13 +131,13 @@ setnth(tail, List, Val) when is_list(List) -> List ++ [Val];
|
||||||
setnth(tail, _List, Val) -> [Val];
|
setnth(tail, _List, Val) -> [Val];
|
||||||
setnth(I, List, _Val) when not is_integer(I) -> List;
|
setnth(I, List, _Val) when not is_integer(I) -> List;
|
||||||
setnth(0, List, _Val) -> List;
|
setnth(0, List, _Val) -> List;
|
||||||
setnth(I, List, _Val) when is_integer(I), I > 0 ->
|
setnth(I, List, Val) when is_integer(I), I > 0 ->
|
||||||
do_setnth(I, List, _Val);
|
do_setnth(I, List, Val);
|
||||||
setnth(I, List, _Val) when is_integer(I), I < 0 ->
|
setnth(I, List, Val) when is_integer(I), I < 0 ->
|
||||||
lists:reverse(do_setnth(-I, lists:reverse(List), _Val)).
|
lists:reverse(do_setnth(-I, lists:reverse(List), Val)).
|
||||||
|
|
||||||
do_setnth(1, [_|Rest], Val) -> [Val|Rest];
|
do_setnth(1, [_ | Rest], Val) -> [Val | Rest];
|
||||||
do_setnth(I, [E|Rest], Val) -> [E|setnth(I-1, Rest, Val)];
|
do_setnth(I, [E | Rest], Val) -> [E | setnth(I-1, Rest, Val)];
|
||||||
do_setnth(_, [], _Val) -> [].
|
do_setnth(_, [], _Val) -> [].
|
||||||
|
|
||||||
getnth(0, _) ->
|
getnth(0, _) ->
|
||||||
|
@ -206,4 +206,4 @@ unsafe_atom_key_map(BinKeyMap) when is_map(BinKeyMap) ->
|
||||||
end, #{}, BinKeyMap);
|
end, #{}, BinKeyMap);
|
||||||
unsafe_atom_key_map(ListV) when is_list(ListV) ->
|
unsafe_atom_key_map(ListV) when is_list(ListV) ->
|
||||||
[unsafe_atom_key_map(V) || V <- ListV];
|
[unsafe_atom_key_map(V) || V <- ListV];
|
||||||
unsafe_atom_key_map(Val) -> Val.
|
unsafe_atom_key_map(Val) -> Val.
|
||||||
|
|
|
@ -95,4 +95,4 @@ spec:
|
||||||
{{- toYaml .Values.ingress.mgmt.tls | nindent 4 }}
|
{{- toYaml .Values.ingress.mgmt.tls | nindent 4 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
---
|
---
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
@ -17,8 +17,8 @@ rules:
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
- ""
|
- ""
|
||||||
resources:
|
resources:
|
||||||
- endpoints
|
- endpoints
|
||||||
verbs:
|
verbs:
|
||||||
- get
|
- get
|
||||||
- watch
|
- watch
|
||||||
- list
|
- list
|
||||||
|
@ -39,4 +39,4 @@ subjects:
|
||||||
roleRef:
|
roleRef:
|
||||||
kind: Role
|
kind: Role
|
||||||
name: {{ include "emqx.fullname" . }}
|
name: {{ include "emqx.fullname" . }}
|
||||||
apiGroup: rbac.authorization.k8s.io
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
cd -P -- "$(dirname -- "$0")/.."
|
||||||
|
|
||||||
|
nl_at_eof() {
|
||||||
|
local file="$1"
|
||||||
|
if ! [ -f "$file" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
case "$file" in
|
||||||
|
*.png|*rebar3)
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
local lastbyte
|
||||||
|
lastbyte="$(tail -c 1 "$file" 2>&1)"
|
||||||
|
if [ "$lastbyte" != '' ]; then
|
||||||
|
echo "$file"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
n=0
|
||||||
|
while read -r file; do
|
||||||
|
if ! nl_at_eof "$file"; then
|
||||||
|
n=$(( n + 1 ))
|
||||||
|
fi
|
||||||
|
done < <(git ls-files)
|
||||||
|
|
||||||
|
exit $n
|
|
@ -5,16 +5,16 @@
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
ELVIS_VERSION='1.0.0-emqx-2'
|
elvis_version='1.0.0-emqx-2'
|
||||||
|
|
||||||
base="${1:-}"
|
base="${1:-}"
|
||||||
|
repo="${2:-emqx}"
|
||||||
|
REPO="${GITHUB_REPOSITORY:-${repo}}"
|
||||||
if [ "${base}" = "" ]; then
|
if [ "${base}" = "" ]; then
|
||||||
echo "Usage $0 <git-compare-base-ref>"
|
echo "Usage $0 <git-compare-base-ref>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elvis_version="${2:-$ELVIS_VERSION}"
|
|
||||||
|
|
||||||
echo "elvis -v: $elvis_version"
|
echo "elvis -v: $elvis_version"
|
||||||
echo "git diff base: $base"
|
echo "git diff base: $base"
|
||||||
|
|
||||||
|
@ -27,11 +27,7 @@ if [[ "$base" =~ [0-9a-f]{8,40} ]]; then
|
||||||
# base is a commit sha1
|
# base is a commit sha1
|
||||||
compare_base="$base"
|
compare_base="$base"
|
||||||
else
|
else
|
||||||
if [[ $CI == true ]];then
|
remote="$(git remote -v | grep -E "github\.com(:|/)emqx/$REPO((\.git)|(\s))" | grep fetch | awk '{print $1}')"
|
||||||
remote="$(git remote -v | grep -E "github\.com(.|/)$GITHUB_REPOSITORY" | grep fetch | awk '{print $1}')"
|
|
||||||
else
|
|
||||||
remote="$(git remote -v | grep -E 'github\.com(.|/)emqx' | grep fetch | awk '{print $1}')"
|
|
||||||
fi
|
|
||||||
git fetch "$remote" "$base"
|
git fetch "$remote" "$base"
|
||||||
compare_base="$remote/$base"
|
compare_base="$remote/$base"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue