From 9c49cf62a72213b12477c15268e98ba9fa2cd509 Mon Sep 17 00:00:00 2001 From: Badlop Date: Wed, 30 Jun 2021 09:21:41 +0200 Subject: [PATCH] Add support to send C coverage. Don't cache. Move hex plugin to Action --- .github/workflows/ci.yml | 24 +++++++------- .github/workflows/hexpm-release.yml | 7 +++- configure.ac | 43 +++++++++++++++++++++++++ rebar.config.script | 50 ++++++++++++++++++++++------- vars.config.in | 6 ++++ 5 files changed, 105 insertions(+), 25 deletions(-) create mode 100644 configure.ac create mode 100644 vars.config.in diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11f7884..d49563f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,29 +13,29 @@ jobs: 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 + cover: + name: Cover + needs: [tests] + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - run: ./configure --enable-gcov + - run: rebar3 compile + - run: rebar3 eunit -v + - run: pip install --user cpp-coveralls + - run: cpp-coveralls -b `pwd` --verbose --gcov-options '\-lp' --dump c.json - name: Send to Coveralls - if: matrix.otp == 24 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - COVERALLS=true rebar3 as test coveralls send + ADDJSONFILE=c.json COVERALLS=true rebar3 as test coveralls send curl -v -k https://coveralls.io/webhook \ --header "Content-Type: application/json" \ --data '{"repo_name":"$GITHUB_REPOSITORY", diff --git a/.github/workflows/hexpm-release.yml b/.github/workflows/hexpm-release.yml index fae4ccb..99f7e56 100644 --- a/.github/workflows/hexpm-release.yml +++ b/.github/workflows/hexpm-release.yml @@ -1,4 +1,4 @@ -name: hexpm-release +name: Hex on: push: @@ -12,6 +12,11 @@ jobs: - name: Check out uses: actions/checkout@v2 + - name: Setup rebar3 hex + run: | + mkdir -p ~/.config/rebar3/ + echo "{plugins, [rebar3_hex]}." > ~/.config/rebar3/rebar.config + - name: Publish to hex.pm run: rebar3 hex publish --repo hexpm --yes || head rebar3.crashdump env: diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..d0d0bf2 --- /dev/null +++ b/configure.ac @@ -0,0 +1,43 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.53) +AC_PACKAGE_VERSION(1.0.0) +AC_INIT(sqlite3, 1.0.0, [], []) + +# Checks for programs. +AC_PROG_CC +AC_PROG_MAKE_SET + +if test "x$GCC" = "xyes"; then + CFLAGS="$CFLAGS -Wall" +fi + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST + +# Checks for library functions. +AC_FUNC_MALLOC +AC_HEADER_STDC + +# Checks Erlang runtime and compiler +AC_ERLANG_NEED_ERL +AC_ERLANG_NEED_ERLC + +# Checks and sets ERLANG_ROOT_DIR and ERLANG_LIB_DIR variable +# AC_ERLANG_SUBST_ROOT_DIR +# AC_ERLANG_SUBST_LIB_DIR + +AC_ARG_ENABLE(gcov, +[AC_HELP_STRING([--enable-gcov], [compile with gcov enabled (default: no)])], +[case "${enableval}" in + yes) gcov=true ;; + no) gcov=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-gcov) ;; +esac],[gcov=false]) + +AC_SUBST(gcov) + +AC_CONFIG_FILES([vars.config]) + +AC_OUTPUT diff --git a/rebar.config.script b/rebar.config.script index 4d49ed2..209e3cf 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -1,10 +1,10 @@ %%%---------------------------------------------------------------------- -%%% File : rebar.config.script -%%% Author : Evgeniy Khramtsov +%%% File : rebar.config +%%% Author : Mickael Remond %%% Purpose : Rebar build script. Compliant with rebar and rebar3. -%%% Created : 8 May 2013 by Evgeniy Khramtsov +%%% Created : 15 Dec 2015 by Mickael Remond %%% -%%% Copyright (C) 2002-2017 ProcessOne, SARL. All Rights Reserved. +%%% Copyright (C) 2002-2021 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. @@ -19,17 +19,28 @@ %%% limitations under the License. %%% %%%---------------------------------------------------------------------- +Cfg = case file:consult(filename:join([filename:dirname(SCRIPT),"vars.config"])) of + {ok, Terms} -> + Terms; + _Err -> + [] + end ++ [{cflags, "-g -O2 -Wall"}, {ldflags, ""}, {with_gcov, "false"}], +{cflags, CfgCFlags} = lists:keyfind(cflags, 1, Cfg), +{ldflags, CfgLDFlags} = lists:keyfind(ldflags, 1, Cfg), +{with_gcov, CfgWithGCov} = lists:keyfind(with_gcov, 1, Cfg), + +SysVersion = lists:map(fun erlang:list_to_integer/1, + string:tokens(erlang:system_info(version), ".")), IsRebar3 = case application:get_key(rebar, vsn) of {ok, VSN} -> - [VSN1 | _] = string:tokens(VSN, "-+"), - [Maj, Min, Patch] = string:tokens(VSN1, "."), + [VSN1 | _] = string:tokens(VSN, "-"), + [Maj|_] = string:tokens(VSN1, "."), (list_to_integer(Maj) >= 3); undefined -> lists:keymember(mix, 1, application:loaded_applications()) end, - ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) -> {OldVal,PartCfg} = case lists:keytake(Key, 1, Cfg) of {value, {_, V1}, V2} -> {V1, V2}; @@ -110,10 +121,26 @@ GithubConfig = case {os:getenv("GITHUB_ACTIONS"), os:getenv("GITHUB_TOKEN")} of end, Rules = [ + {[port_env, "CFLAGS"], SysVersion >= [7, 3], + AppendStr("-DHAS_ERTS_EXIT"), "$CFLAGS"}, + {[port_env, "CFLAGS"], true, + AppendStr(CfgCFlags), "$CFLAGS"}, + {[port_env, "LDFLAGS"], true, + AppendStr(CfgLDFlags), "$LDFLAGS"}, + {[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", + AppendStr("--coverage"), ""}, {[deps], IsRebar3, Rebar3DepsFilter, []}, {[plugins], IsRebar3, - AppendList([rebar3_hex, pc]), []}, + AppendList([pc]), []}, {[provider_hooks], IsRebar3, AppendList([{pre, [ {compile, {pc, compile}}, @@ -121,15 +148,14 @@ Rules = [ ]}]), []}, {[plugins], os:getenv("COVERALLS") == "true", AppendList([{coveralls, {git, - "https://github.com/RoadRunnr/coveralls-erl.git", - {branch, "feature/git-info"}}} ]), []}, + "https://github.com/processone/coveralls-erl.git", + {branch, "addjsonfile"}}} ]), []}, {[deps], os:getenv("USE_GLOBAL_DEPS") /= false, GlobalDepsFilter, []} ], -Config = FilterConfig(FilterConfig, CONFIG, Rules) -++ GithubConfig, +Config = FilterConfig(FilterConfig, CONFIG, Rules) ++ GithubConfig, %io:format("Rules:~n~p~n~nCONFIG:~n~p~n~nConfig:~n~p~n", [Rules, CONFIG, Config]), diff --git a/vars.config.in b/vars.config.in new file mode 100644 index 0000000..cdb35dc --- /dev/null +++ b/vars.config.in @@ -0,0 +1,6 @@ +{with_gcov, "@gcov@"}. + +%% Local Variables: +%% mode: erlang +%% End: +%% vim: set filetype=erlang tabstop=8: