Skip to content

Commit 84021a1

Browse files
committed
Switch from Travis to Github Actions
1 parent 035fc31 commit 84021a1

File tree

5 files changed

+76
-52
lines changed

5 files changed

+76
-52
lines changed

.github/workflows/ci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
7+
tests:
8+
name: Tests
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
otp: ['19.3', '22.3', 24]
13+
runs-on: ubuntu-20.04
14+
container:
15+
image: erlang:${{ matrix.otp }}
16+
17+
steps:
18+
19+
- uses: actions/checkout@v2
20+
21+
- name: Cache rebar3
22+
uses: actions/cache@v2
23+
with:
24+
path: |
25+
~/.cache/rebar3/
26+
key: ${{matrix.otp}}-${{hashFiles('rebar.config')}}
27+
28+
- run: ./configure --enable-gcov
29+
- run: rebar3 compile
30+
- run: rebar3 xref
31+
- run: rebar3 dialyzer
32+
- run: rebar3 eunit -v
33+
34+
- name: Send to Coveralls
35+
if: matrix.otp == 24
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
run: |
39+
COVERALLS=true rebar3 as test coveralls send
40+
curl -v -k https://coveralls.io/webhook \
41+
--header "Content-Type: application/json" \
42+
--data '{"repo_name":"$GITHUB_REPOSITORY",
43+
"repo_token":"$GITHUB_TOKEN",
44+
"payload":{"build_num":$GITHUB_RUN_ID,
45+
"status":"done"}}'

.travis.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Fast Stringprep implementation for Erlang / Elixir
22

3-
[![Build Status](https://travis-ci.org/processone/stringprep.svg?branch=master)](https://travis-ci.org/processone/stringprep) [![Coverage Status](https://coveralls.io/repos/processone/stringprep/badge.svg?branch=master&service=github)](https://coveralls.io/github/processone/stringprep?branch=master) [![Hex version](https://img.shields.io/hexpm/v/stringprep.svg "Hex version")](https://hex.pm/packages/stringprep)
3+
[![CI](https://github.com/processone/stringprep/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/processone/stringprep/actions/workflows/ci.yml)
4+
[![Coverage Status](https://coveralls.io/repos/processone/stringprep/badge.svg?branch=master&service=github)](https://coveralls.io/github/processone/stringprep?branch=master)
5+
[![Hex version](https://img.shields.io/hexpm/v/stringprep.svg "Hex version")](https://hex.pm/packages/stringprep)
46

57
Stringprep is a framework for preparing Unicode test strings in order
68
to increase the likelihood that string input and string comparison

rebar.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@
3636

3737
{cover_enabled, true}.
3838
{cover_export_enabled, true}.
39+
{coveralls_coverdata , "_build/test/cover/eunit.coverdata"}.
40+
{coveralls_service_name , "github"}.
3941

4042
{xref_checks, [undefined_function_calls, undefined_functions, deprecated_function_calls, deprecated_functions]}.
4143

42-
{profiles, [{test, [{erl_opts, [{src_dirs, ["src", "test"]}]}]}]}.
4344

4445
%% Local Variables:
4546
%% mode: erlang

rebar.config.script

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ IsRebar3 = case application:get_key(rebar, vsn) of
3939
lists:keymember(mix, 1, application:loaded_applications())
4040
end,
4141

42-
JobId = case os:getenv("TRAVIS_JOB_ID") of false -> ""; V -> V end,
43-
4442
ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) ->
4543
{OldVal,PartCfg} = case lists:keytake(Key, 1, Cfg) of
4644
{value, {_, V1}, V2} -> {V1, V2};
@@ -103,14 +101,34 @@ GlobalDepsFilter = fun(Deps) ->
103101
end, DepNames)
104102
end,
105103

104+
GithubConfig = case {os:getenv("GITHUB_ACTIONS"), os:getenv("GITHUB_TOKEN")} of
105+
{"true", Token} when is_list(Token) ->
106+
CONFIG1 = [{coveralls_repo_token, Token},
107+
{coveralls_service_job_id, os:getenv("GITHUB_RUN_ID")},
108+
{coveralls_commit_sha, os:getenv("GITHUB_SHA")},
109+
{coveralls_service_number, os:getenv("GITHUB_RUN_NUMBER")}],
110+
case os:getenv("GITHUB_EVENT_NAME") =:= "pull_request"
111+
andalso string:tokens(os:getenv("GITHUB_REF"), "/") of
112+
[_, "pull", PRNO, _] ->
113+
[{coveralls_service_pull_request, PRNO} | CONFIG1];
114+
_ ->
115+
CONFIG1
116+
end;
117+
_ ->
118+
[]
119+
end,
120+
106121
Rules = [
107122
{[port_env, "CXXFLAGS"], true,
108123
AppendStr(CfgCXXFlags), "$CXXFLAGS"},
109124
{[port_env, "LDFLAGS"], true,
110125
AppendStr(CfgLDFlags), "$LDFLAGS"},
111-
{[post_hooks], CfgWithGCov == "true",
126+
{[post_hooks], (not IsRebar3) and (CfgWithGCov == "true"),
112127
AppendList([{eunit, "gcov -o c_src stringprep"},
113128
{eunit, "mv *.gcov .eunit/"}]), []},
129+
{[post_hooks], IsRebar3 and (CfgWithGCov == "true"),
130+
AppendList([{eunit, "gcov -o c_src stringprep"},
131+
{eunit, "mv *.gcov _build/test/cover/"}]), []},
114132
{[port_env, "LDFLAGS"], CfgWithGCov == "true",
115133
AppendStr("--coverage"), ""},
116134
{[port_env, "CXXFLAGS"], CfgWithGCov == "true",
@@ -124,17 +142,16 @@ Rules = [
124142
{compile, {pc, compile}},
125143
{clean, {pc, clean}}
126144
]}]), []},
127-
{[deps], os:getenv("TRAVIS") == "true",
128-
AppendList([{coveralls, ".*", {git, "https://github.com/markusn/coveralls-erl.git", {tag, "v2.0.1"}}}]), []},
129-
{[post_hooks], os:getenv("TRAVIS") == "true",
130-
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"},
131-
{eunit, "escript ./getcover.erl"}]), []},
145+
{[plugins], os:getenv("COVERALLS") == "true",
146+
AppendList([{coveralls, {git,
147+
"https://github.com/RoadRunnr/coveralls-erl.git",
148+
{branch, "feature/git-info"}}} ]), []},
132149
{[deps], os:getenv("USE_GLOBAL_DEPS") /= false,
133150
GlobalDepsFilter, []}
134151
],
135152

136153

137-
Config = FilterConfig(FilterConfig, CONFIG, Rules),
154+
Config = FilterConfig(FilterConfig, CONFIG, Rules) ++ GithubConfig,
138155

139156
%io:format("Rules:~n~p~n~nCONFIG:~n~p~n~nConfig:~n~p~n", [Rules, CONFIG, Config]),
140157

0 commit comments

Comments
 (0)