From 1f02d363028bb41cd2da447e410dfcbb0b3b4855 Mon Sep 17 00:00:00 2001 From: Badlop Date: Thu, 17 Jun 2021 13:22:28 +0200 Subject: [PATCH] Switch from Travis to Github Actions --- .github/workflows/ci.yml | 44 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 23 --------------------- README.md | 6 ++++-- rebar.config | 7 +++++++ rebar.config.script | 25 +++++++++++++++++++++-- 5 files changed, 78 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..82ef5eb --- /dev/null +++ b/.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', '21.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: | + 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"}}' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 488fdcb..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: erlang - -os: linux - -dist: xenial - -before_install: - - pip install --user cpp-coveralls coveralls-merge - -install: - - rebar get-deps - -script: rebar compile && rebar skip_deps=true eunit - -after_success: - - cpp-coveralls --exclude lib --exclude tests --gcov-options '\-lp' --dump c.json - - coveralls-merge c.json erlang.json - -otp_release: - - R16B03-1 - - 17.3 - - 19.3 - - 23.0 diff --git a/README.md b/README.md index 0dc69d9..fb51645 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ # Erlang wrapper for SQLite3 +[![CI](https://github.com/badlop/erlang-sqlite3/actions/workflows/ci.yml/badge.svg)](https://github.com/badlop/erlang-sqlite3/actions/workflows/ci.yml) +[![Coverage Status](https://coveralls.io/repos/processone/erlang-sqlite3/badge.svg?branch=master&service=github)](https://coveralls.io/github/processone/erlang-sqlite3?branch=master) +[![Hex version](https://img.shields.io/hexpm/v/sqlite3.svg "Hex version")](https://hex.pm/packages/sqlite3) + This library allows you to work with SQLite3 databases from Erlang. It is compatible with Windows and Linux, and should probably work on other OSes as well. -[![Build Status](https://travis-ci.org/alexeyr/erlang-sqlite3.svg?branch=master)](https://travis-ci.org/alexeyr/erlang-sqlite3) - See also [esqlite](https://github.com/mmzeeman/esqlite) for an alternative library. ## Requirements diff --git a/rebar.config b/rebar.config index 75bb724..8849a52 100644 --- a/rebar.config +++ b/rebar.config @@ -9,3 +9,10 @@ {".*win32.*", "DRV_LDFLAGS", "$DRV_LDFLAGS sqlite3.lib"}]}. {cover_enabled, true}. {eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]}. +{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, ["src", "test"]}]}]}]}. diff --git a/rebar.config.script b/rebar.config.script index 28921d4..6b81f22 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -29,7 +29,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 @@ -93,6 +92,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 = [ {[deps], IsRebar3, Rebar3DepsFilter, []}, @@ -103,12 +119,17 @@ Rules = [ {compile, {pc, compile}}, {clean, {pc, clean}} ]}]), []}, + {[plugins], IsRebar3 and (os:getenv("GITHUB_ACTIONS") == "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]),