@@ -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-
4442ModCfg0 = 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+
106121Rules = [
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\n main(_)->{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