Browse Source

Switch from Travis to Github Actions

master
Badlop 11 months ago
parent
commit
1fc31930c1
  1. 44
      .github/workflows/ci.yml
  2. 19
      .travis.yml
  3. 4
      README.md
  4. 6
      rebar.config
  5. 37
      rebar.config.script
  6. 5
      src/mqtree.erl

44
.github/workflows/ci.yml

@ -0,0 +1,44 @@
name: CI
on: [push, pull_request]
jobs:
tests:
name: Tests
strategy:
fail-fast: false
matrix:
otp: ['19.3', '22.3', 24]
runs-on: ubuntu-20.04
container:
image: erlang:${{ matrix.otp }}
steps:
- uses: actions/checkout@v2
- name: Cache rebar3
uses: actions/cache@v2
with:
path: |
~/.cache/rebar3/
key: ${{matrix.otp}}-${{hashFiles('rebar.config')}}
- run: rebar3 compile
- run: rebar3 xref
- run: rebar3 dialyzer
- run: rebar3 eunit -v
- name: Send to Coveralls
if: matrix.otp == 24
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
COVERALLS=true rebar3 as test coveralls send
curl -v -k https://coveralls.io/webhook \
--header "Content-Type: application/json" \
--data '{"repo_name":"$GITHUB_REPOSITORY",
"repo_token":"$GITHUB_TOKEN",
"payload":{"build_num":$GITHUB_RUN_ID,
"status":"done"}}'

19
.travis.yml

@ -1,19 +0,0 @@
language: erlang
os: linux
dist: xenial
before_install:
- pip install --user cpp-coveralls coveralls-merge
script: make && make xref && make test
after_success:
- cpp-coveralls --exclude lib --exclude tests --gcov-options '\-lp' --dump c.json
- coveralls-merge c.json erlang.json
otp_release:
- 19.3
- 22.3
- 23.0

4
README.md

@ -1,6 +1,10 @@
mqtree: Index tree for MQTT topic filters
====================================================
[![CI](https://github.com/processone/mqtree/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/processone/mqtree/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/processone/mqtree/badge.svg?branch=master&service=github)](https://coveralls.io/github/processone/mqtree?branch=master)
[![Hex version](https://img.shields.io/hexpm/v/mqtree.svg "Hex version")](https://hex.pm/packages/mqtree)
mqtree is an Erlang NIF implementation of N-ary tree to keep MQTT
topic filters for efficient matching.

6
rebar.config

@ -15,7 +15,7 @@
%%% limitations under the License.
%%%
%%%-------------------------------------------------------------------
{erl_opts, [debug_info, {src_dirs, ["src"]}]}.
{erl_opts, [debug_info]}.
{port_env, [{"CFLAGS", "$CFLAGS -std=c99 -g -O2 -Wall"},
{"ERL_LDFLAGS", " -L$ERL_EI_LIBDIR -lei"},
@ -29,12 +29,12 @@
{cover_enabled, true}.
{cover_export_enabled, true}.
{coveralls_coverdata , "_build/test/cover/eunit.coverdata"}.
{coveralls_service_name , "github"}.
{xref_checks, [undefined_function_calls, undefined_functions,
deprecated_function_calls, deprecated_functions]}.
{profiles, [{test, [{erl_opts, [{src_dirs, ["test"]}]}]}]}.
%% Local Variables:
%% mode: erlang
%% End:

37
rebar.config.script

@ -41,8 +41,6 @@ IsRebar3 = case application:get_key(rebar, vsn) of
lists:keymember(mix, 1, application:loaded_applications())
end,
JobId = case os:getenv("TRAVIS_JOB_ID") of false -> ""; V -> V end,
ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) ->
{OldVal,PartCfg} = case lists:keytake(Key, 1, Cfg) of
{value, {_, V1}, V2} -> {V1, V2};
@ -105,6 +103,23 @@ GlobalDepsFilter = fun(Deps) ->
end, DepNames)
end,
GithubConfig = case {os:getenv("GITHUB_ACTIONS"), os:getenv("GITHUB_TOKEN")} of
{"true", Token} when is_list(Token) ->
CONFIG1 = [{coveralls_repo_token, Token},
{coveralls_service_job_id, os:getenv("GITHUB_RUN_ID")},
{coveralls_commit_sha, os:getenv("GITHUB_SHA")},
{coveralls_service_number, os:getenv("GITHUB_RUN_NUMBER")}],
case os:getenv("GITHUB_EVENT_NAME") =:= "pull_request"
andalso string:tokens(os:getenv("GITHUB_REF"), "/") of
[_, "pull", PRNO, _] ->
[{coveralls_service_pull_request, PRNO} | CONFIG1];
_ ->
CONFIG1
end;
_ ->
[]
end,
Rules = [
{[port_env, "CFLAGS"], SysVersion >= [7, 3],
AppendStr("-DHAS_ERTS_EXIT"), "$CFLAGS"},
@ -112,9 +127,12 @@ Rules = [
AppendStr(CfgCFlags), "$CFLAGS"},
{[port_env, "LDFLAGS"], true,
AppendStr(CfgLDFlags), "$LDFLAGS"},
{[post_hooks], CfgWithGCov == "true",
AppendList([{eunit, "gcov -o c_src fast_tls p1_sha"},
{[post_hooks], (not IsRebar3) and (CfgWithGCov == "true"),
AppendList([{eunit, "gcov -o c_src mqtree"},
{eunit, "mv *.gcov .eunit/"}]), []},
{[post_hooks], IsRebar3 and (CfgWithGCov == "true"),
AppendList([{eunit, "gcov -o c_src mqtree"},
{eunit, "mv *.gcov _build/test/cover/"}]), []},
{[port_env, "LDFLAGS"], CfgWithGCov == "true",
AppendStr("--coverage"), ""},
{[port_env, "CFLAGS"], CfgWithGCov == "true",
@ -128,17 +146,16 @@ Rules = [
{compile, {pc, compile}},
{clean, {pc, clean}}
]}]), []},
{[deps], os:getenv("TRAVIS") == "true",
AppendList([{coveralls, ".*", {git, "https://github.com/markusn/coveralls-erl.git", {tag, "v2.0.1"}}}]), []},
{[post_hooks], os:getenv("TRAVIS") == "true",
AppendList([{eunit, "echo '\n%%! -pa .eunit/ deps/coveralls/ebin\nmain(_)->{ok,F}=file:open(\"erlang.json\",[write]),io:fwrite(F,\"~s\",[coveralls:convert_file(\".eunit/cover.coverdata\", \""++JobId++"\", \"travis-ci\",\"\")]).' > getcover.erl"},
{eunit, "escript ./getcover.erl"}]), []},
{[plugins], os:getenv("COVERALLS") == "true",
AppendList([{coveralls, {git,
"https://github.com/RoadRunnr/coveralls-erl.git",
{branch, "feature/git-info"}}} ]), []},
{[deps], os:getenv("USE_GLOBAL_DEPS") /= false,
GlobalDepsFilter, []}
],
Config = FilterConfig(FilterConfig, CONFIG, Rules),
Config = FilterConfig(FilterConfig, CONFIG, Rules) ++ GithubConfig,
%io:format("Rules:~n~p~n~nCONFIG:~n~p~n~nConfig:~n~p~n", [Rules, CONFIG, Config]),

5
src/mqtree.erl

@ -98,6 +98,11 @@ to_list(_Tree) ->
%%% Internal functions
%%%===================================================================
load_nif() ->
case os:getenv("COVERALLS") of
"true" -> ok;
_ -> load_nif2()
end.
load_nif2() ->
Path = p1_nif_utils:get_so_path(?MODULE, [?MODULE], atom_to_list(?MODULE)),
case erlang:load_nif(Path, 0) of
ok -> ok;

Loading…
Cancel
Save