You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2021/11/17 15:42:51 UTC
[couchdb-erlfdb] branch main updated (111367c -> a367af4)
This is an automated email from the ASF dual-hosted git repository.
kocolosk pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-erlfdb.git.
from 111367c Implement wrapper for get_estimated_range_size API
new 2f6b648 Enable code coverage for eunit + bindingtester
new a367af4 Publish coverage to coveralls.io
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.github/workflows/ci.yml | 40 +++++++++++++++++++++++++++++++++++++++-
README.md | 2 +-
rebar.config | 7 +++++++
rebar.config.script | 22 +++++++++++++++++++++-
test/tester.es | 25 ++++++++++++++++++++++++-
5 files changed, 92 insertions(+), 4 deletions(-)
[couchdb-erlfdb] 02/02: Publish coverage to coveralls.io
Posted by ko...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kocolosk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-erlfdb.git
commit a367af4072e821d170aae442a634dc731dbfc860
Author: Adam Kocoloski <ko...@apache.org>
AuthorDate: Wed Nov 10 14:35:07 2021 -0500
Publish coverage to coveralls.io
---
.github/workflows/ci.yml | 40 +++++++++++++++++++++++++++++++++++++++-
README.md | 2 +-
rebar.config | 5 +++++
rebar.config.script | 22 +++++++++++++++++++++-
4 files changed, 66 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c64b077..844f9a7 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -5,6 +5,9 @@ on:
branches: [ main ]
pull_request:
+permissions:
+ contents: read
+
jobs:
build_on_linux:
@@ -106,6 +109,14 @@ jobs:
services:
foundationdb:
image: foundationdb/foundationdb:6.3.18
+ env:
+ # We could create a different profile that looks for fdb.cluster in the
+ # default /etc/foundationdb/ location, but for now we can just specify the
+ # custom location here
+ FDB_CLUSTER_FILE: /usr/local/etc/foundationdb/fdb.cluster
+ # This profile just ensures we use the FDB server in the service container
+ REBAR_PROFILE: devcontainer
+ DIAGNOSTIC: 1
steps:
- name: Create FDB cluster file
env:
@@ -122,15 +133,42 @@ jobs:
persist-credentials: false
- name: Compile erlfdb
run: rebar3 compile
+ - name: Execute unit tests
+ run: rebar3 eunit
- name: Execute binding test
env:
TEST_NAME: ${{ matrix.test-name }}
API_VERSION: ${{ matrix.api-version }}
- ERL_LIBS: _build/default/lib/erlfdb/
+ COVER_ENABLED: true
+ ERL_LIBS: _build/devcontainer+test/lib/erlfdb/
run: |
mkdir -p /usr/src/erlfdb/test/
ln -s $GITHUB_WORKSPACE/test/tester.es /usr/src/erlfdb/test/tester.es
/usr/src/foundationdb/bindings/bindingtester/bindingtester.py erlang \
--test-name $TEST_NAME \
--api-version $API_VERSION \
+ --instruction-prefix $TEST_NAME \
--num-ops 10000
+ - name: Upload results to Coveralls
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ COVERALLS_FLAG_NAME: bindingtest-${{ matrix.test-name }}-${{ matrix.api-version }}
+ run: rebar3 as test coveralls send
+
+
+ finish:
+ needs: [build_on_linux, build_on_windows, binding_tester]
+ runs-on: ubuntu-latest
+ steps:
+ - name: Finalize Coveralls report
+ run: |
+ curl https://coveralls.io/webhook \
+ --header 'Content-Type: application/json' \
+ --data '{
+ "repo_name": "${{ github.repository }}",
+ "repo_token": "${{ secrets.GITHUB_TOKEN }}",
+ "payload": {
+ "build_num": ${{ github.run_number }},
+ "status": "done"
+ }
+ }'
diff --git a/README.md b/README.md
index 30e34e2..2d95224 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
An Erlang Binding to FoundationDB
===
-[](https://github.com/apache/couchdb-erlfdb/actions/workflows/ci.yml)
+[](https://github.com/apache/couchdb-erlfdb/actions/workflows/ci.yml)[](https://coveralls.io/github/apache/couchdb-erlfdb?branch=main)
This project is a NIF wrapper for the FoundationDB C API. Documentation on
the main API can be found [here][fdb_docs].
diff --git a/rebar.config b/rebar.config
index 2b00cba..34d277d 100644
--- a/rebar.config
+++ b/rebar.config
@@ -1,4 +1,5 @@
{plugins, [
+ coveralls,
pc
]}.
@@ -38,3 +39,7 @@
]}.
{cover_enabled, true}.
+{cover_export_enabled, true}.
+{coveralls_coverdata, "_build/devcontainer+test/cover/*.coverdata"}.
+{coveralls_service_name, "github"}.
+{coveralls_parallel, true}.
diff --git a/rebar.config.script b/rebar.config.script
index 7a8dbb6..4a07085 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -9,6 +9,26 @@ MaxAPIVersion =
integer_to_list(APIVersionBytes, 16)
end.
+% https://github.com/markusn/coveralls-erl#example-usage-rebar3-and-github-actions
+CoverallConfig =
+ 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_service_number, os:getenv("GITHUB_RUN_NUMBER")},
+ {coveralls_commit_sha, os:getenv("GITHUB_SHA")},
+ {coveralls_flag_name, os:getenv("COVERALLS_FLAG_NAME")} | CONFIG],
+ 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;
+ _ ->
+ CONFIG
+ end.
+
[{port_env, [
{
"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin|gnu)",
@@ -31,4 +51,4 @@ MaxAPIVersion =
"LDFLAGS",
"$LDFLAGS /LIBPATH:\"c:/Program Files/foundationdb/lib/foundationdb\" fdb_c.lib"
}
-]}] ++ CONFIG.
+]}] ++ CoverallConfig.
[couchdb-erlfdb] 01/02: Enable code coverage for eunit + bindingtester
Posted by ko...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kocolosk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-erlfdb.git
commit 2f6b6484e472ee805c0eb3253ad66a2a1b5a2e29
Author: Adam Kocoloski <ko...@apache.org>
AuthorDate: Wed Nov 10 13:59:44 2021 -0500
Enable code coverage for eunit + bindingtester
The EUnit coverage is on by default. The bindingtester can be enabled
by defining the COVER_ENABLED environment variable. It writes to the
same directory that EUnit does; namely "_build/test/cover/" if ERL_LIBS
is defined to point to the "test" profile for erlfdb (as it should be
for code coverage analysis). For example:
COVER_ENABLED=1 ERL_LIBS=_build/test/lib/erlfdb /usr/src/foundationdb/bindings/bindingtester/bindingtester.py erlang --test-name api --instruction-prefix api --num-ops 10000
We could try to be a little smarter here and align to rebar3's config
options, but I didn't bother with that for now.
---
rebar.config | 2 ++
test/tester.es | 25 ++++++++++++++++++++++++-
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/rebar.config b/rebar.config
index 4d45a7f..2b00cba 100644
--- a/rebar.config
+++ b/rebar.config
@@ -36,3 +36,5 @@
debug_info,
verbose
]}.
+
+{cover_enabled, true}.
diff --git a/test/tester.es b/test/tester.es
index c1d3b3c..617c03d 100755
--- a/test/tester.es
+++ b/test/tester.es
@@ -1020,6 +1020,27 @@ get_dir_or_ss_mod(#{}) ->
erlfdb_directory.
+maybe_cover_compile() ->
+ case os:getenv("COVER_ENABLED") of
+ Cover when Cover == false; Cover == "" ->
+ ok;
+ _ ->
+ cover:compile_beam_directory(code:lib_dir(erlfdb, ebin))
+ end.
+
+maybe_write_coverdata(Prefix, APIVsn) ->
+ case os:getenv("COVER_ENABLED") of
+ Cover when Cover == false; Cover == "" ->
+ ok;
+ _ ->
+ CoverDir = filename:join(code:lib_dir(erlfdb), "../../cover/"),
+ Filename = io_lib:format("bindingtest-~s-~s.coverdata", [Prefix, APIVsn]),
+ Path = filename:join(CoverDir, Filename),
+ filelib:ensure_dir(Path),
+ cover:export(Path)
+ end.
+
+
main([Prefix, APIVsn]) ->
main([Prefix, APIVsn, ""]);
@@ -1028,6 +1049,8 @@ main([Prefix, APIVsn, ClusterFileStr]) ->
%% io:get_line(Prompt),
%% io:format("Running tests: ~s ~s ~s~n", [Prefix, APIVsn, ClusterFileStr]),
+ maybe_cover_compile(),
application:set_env(erlfdb, api_version, list_to_integer(APIVsn)),
Db = erlfdb:open(iolist_to_binary(ClusterFileStr)),
- init_run_loop(Db, iolist_to_binary(Prefix)).
+ init_run_loop(Db, iolist_to_binary(Prefix)),
+ maybe_write_coverdata(Prefix, APIVsn).