rebar.config.erl 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. -module('rebar.config').
  2. -export([do/2]).
  3. do(Dir, CONFIG) ->
  4. ok = assert_otp(),
  5. ok = warn_profile_env(),
  6. case iolist_to_binary(Dir) of
  7. <<".">> ->
  8. C1 = deps(CONFIG),
  9. Config = dialyzer(C1),
  10. maybe_dump(Config ++ [{overrides, overrides()}] ++ coveralls() ++ config());
  11. _ ->
  12. CONFIG
  13. end.
  14. assert_otp() ->
  15. Oldest = 25,
  16. Latest = 26,
  17. OtpRelease = list_to_integer(erlang:system_info(otp_release)),
  18. case OtpRelease < Oldest orelse OtpRelease > Latest of
  19. true ->
  20. io:format(
  21. standard_error,
  22. "ERROR: Erlang/OTP version ~p found. min=~p, recommended=~p~n",
  23. [OtpRelease, Oldest, Latest]
  24. ),
  25. halt(1);
  26. false when OtpRelease =/= Latest ->
  27. io:format(
  28. "WARNING: Erlang/OTP version ~p found, recommended==~p~n",
  29. [OtpRelease, Latest]
  30. );
  31. false ->
  32. ok
  33. end.
  34. quicer() ->
  35. {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.313"}}}.
  36. jq() ->
  37. {jq, {git, "https://github.com/emqx/jq", {tag, "v0.3.12"}}}.
  38. deps(Config) ->
  39. {deps, OldDeps} = lists:keyfind(deps, 1, Config),
  40. MoreDeps =
  41. [jq() || is_jq_supported()] ++
  42. [quicer() || is_quicer_supported()],
  43. lists:keystore(deps, 1, Config, {deps, OldDeps ++ MoreDeps}).
  44. overrides() ->
  45. [
  46. {add, [{extra_src_dirs, [{"etc", [{recursive, true}]}]}]}
  47. ] ++ snabbkaffe_overrides().
  48. %% Temporary workaround for a rebar3 erl_opts duplication
  49. %% bug. Ideally, we want to set this define globally
  50. snabbkaffe_overrides() ->
  51. Apps = [snabbkaffe, ekka, mria, gen_rpc],
  52. [{add, App, [{erl_opts, [{d, snk_kind, msg}]}]} || App <- Apps].
  53. config() ->
  54. [
  55. {cover_enabled, is_cover_enabled()},
  56. {profiles, profiles()},
  57. {plugins, plugins()}
  58. ].
  59. is_cover_enabled() ->
  60. case os:getenv("ENABLE_COVER_COMPILE") of
  61. "1" -> true;
  62. "true" -> true;
  63. _ -> false
  64. end.
  65. is_enterprise(ce) -> false;
  66. is_enterprise(ee) -> true.
  67. is_community_umbrella_app("apps/emqx_bridge_kafka") -> false;
  68. is_community_umbrella_app("apps/emqx_bridge_confluent") -> false;
  69. is_community_umbrella_app("apps/emqx_bridge_gcp_pubsub") -> false;
  70. is_community_umbrella_app("apps/emqx_bridge_cassandra") -> false;
  71. is_community_umbrella_app("apps/emqx_bridge_opents") -> false;
  72. is_community_umbrella_app("apps/emqx_bridge_clickhouse") -> false;
  73. is_community_umbrella_app("apps/emqx_bridge_dynamo") -> false;
  74. is_community_umbrella_app("apps/emqx_bridge_greptimedb") -> false;
  75. is_community_umbrella_app("apps/emqx_bridge_hstreamdb") -> false;
  76. is_community_umbrella_app("apps/emqx_bridge_influxdb") -> false;
  77. is_community_umbrella_app("apps/emqx_bridge_iotdb") -> false;
  78. is_community_umbrella_app("apps/emqx_bridge_matrix") -> false;
  79. is_community_umbrella_app("apps/emqx_bridge_mongodb") -> false;
  80. is_community_umbrella_app("apps/emqx_bridge_mysql") -> false;
  81. is_community_umbrella_app("apps/emqx_bridge_pgsql") -> false;
  82. is_community_umbrella_app("apps/emqx_bridge_pulsar") -> false;
  83. is_community_umbrella_app("apps/emqx_bridge_redis") -> false;
  84. is_community_umbrella_app("apps/emqx_bridge_rocketmq") -> false;
  85. is_community_umbrella_app("apps/emqx_bridge_tdengine") -> false;
  86. is_community_umbrella_app("apps/emqx_bridge_timescale") -> false;
  87. is_community_umbrella_app("apps/emqx_bridge_oracle") -> false;
  88. is_community_umbrella_app("apps/emqx_bridge_sqlserver") -> false;
  89. is_community_umbrella_app("apps/emqx_oracle") -> false;
  90. is_community_umbrella_app("apps/emqx_bridge_rabbitmq") -> false;
  91. is_community_umbrella_app("apps/emqx_ft") -> false;
  92. is_community_umbrella_app("apps/emqx_s3") -> false;
  93. is_community_umbrella_app("apps/emqx_bridge_s3") -> false;
  94. is_community_umbrella_app("apps/emqx_schema_registry") -> false;
  95. is_community_umbrella_app("apps/emqx_enterprise") -> false;
  96. is_community_umbrella_app("apps/emqx_bridge_kinesis") -> false;
  97. is_community_umbrella_app("apps/emqx_bridge_azure_event_hub") -> false;
  98. is_community_umbrella_app("apps/emqx_gcp_device") -> false;
  99. is_community_umbrella_app("apps/emqx_dashboard_rbac") -> false;
  100. is_community_umbrella_app("apps/emqx_dashboard_sso") -> false;
  101. is_community_umbrella_app("apps/emqx_audit") -> false;
  102. is_community_umbrella_app("apps/emqx_gateway_gbt32960") -> false;
  103. is_community_umbrella_app("apps/emqx_gateway_ocpp") -> false;
  104. is_community_umbrella_app("apps/emqx_gateway_jt808") -> false;
  105. is_community_umbrella_app("apps/emqx_bridge_syskeeper") -> false;
  106. is_community_umbrella_app("apps/emqx_message_validation") -> false;
  107. is_community_umbrella_app("apps/emqx_eviction_agent") -> false;
  108. is_community_umbrella_app("apps/emqx_node_rebalance") -> false;
  109. is_community_umbrella_app(_) -> true.
  110. %% BUILD_WITHOUT_JQ
  111. %% BUILD_WITHOUT_QUIC
  112. %% BUILD_WITHOUT_ROCKSDB
  113. is_build_without(Name) ->
  114. "1" =:= os:getenv("BUILD_WITHOUT_" ++ Name).
  115. %% BUILD_WITH_QUIC
  116. is_build_with(Name) ->
  117. "1" =:= os:getenv("BUILD_WITH_" ++ Name).
  118. is_jq_supported() ->
  119. not is_build_without("JQ").
  120. is_quicer_supported() ->
  121. %% for ones who want to build QUIC on macos
  122. %% export BUILD_WITH_QUIC=1
  123. is_build_with("QUIC") orelse
  124. is_quicer_supported(os:type()).
  125. is_quicer_supported({unix, darwin}) ->
  126. %% no quic on macos so far
  127. false;
  128. is_quicer_supported(_) ->
  129. not is_build_without("QUIC").
  130. is_rocksdb_supported() ->
  131. %% there is no way one can build rocksdb on raspbian
  132. %% so no need to check is_build_with
  133. Distro = os_cmd("./scripts/get-distro.sh"),
  134. is_rocksdb_supported(Distro).
  135. is_rocksdb_supported("respbian" ++ _) ->
  136. false;
  137. is_rocksdb_supported(_) ->
  138. not is_build_without("ROCKSDB").
  139. project_app_dirs() ->
  140. project_app_dirs(get_edition_from_profile_env()).
  141. project_app_dirs(Edition) ->
  142. IsEnterprise = is_enterprise(Edition),
  143. UmbrellaApps = [
  144. Path
  145. || Path <- filelib:wildcard("apps/*"),
  146. is_community_umbrella_app(Path) orelse IsEnterprise
  147. ],
  148. UmbrellaApps.
  149. plugins() ->
  150. [
  151. %{relup_helper, {git, "https://github.com/emqx/relup_helper", {tag, "2.1.0"}}},
  152. %% emqx main project does not require port-compiler
  153. %% pin at root level for deterministic
  154. {pc, "v1.14.0"}
  155. ] ++
  156. %% test plugins are concatenated to default profile plugins
  157. %% otherwise rebar3 test profile runs are super slow
  158. test_plugins().
  159. test_plugins() ->
  160. [
  161. {rebar3_proper, "0.12.1"},
  162. {coveralls, {git, "https://github.com/emqx/coveralls-erl", {tag, "v2.2.0-emqx-1"}}}
  163. ].
  164. test_deps() ->
  165. [
  166. {bbmustache, "1.10.0"},
  167. {meck, "0.9.2"},
  168. {proper, "1.4.0"},
  169. {er_coap_client, {git, "https://github.com/emqx/er_coap_client", {tag, "v1.0.5"}}},
  170. {erl_csv, "0.2.0"},
  171. {eministat, "0.10.1"}
  172. ].
  173. common_compile_opts() ->
  174. common_compile_opts(get_edition_from_profile_env(), undefined).
  175. common_compile_opts(Edition, Vsn) ->
  176. % always include debug_info
  177. [
  178. debug_info,
  179. {compile_info, [{emqx_vsn, Vsn} || Vsn /= undefined]},
  180. {d, 'EMQX_RELEASE_EDITION', Edition}
  181. ] ++
  182. [{d, 'EMQX_BENCHMARK'} || os:getenv("EMQX_BENCHMARK") =:= "1"] ++
  183. [{d, 'BUILD_WITHOUT_QUIC'} || not is_quicer_supported()].
  184. warn_profile_env() ->
  185. case os:getenv("PROFILE") of
  186. false ->
  187. io:format(
  188. standard_error,
  189. "WARN: environment variable PROFILE is not set, using 'emqx-enterprise'~n",
  190. []
  191. );
  192. _ ->
  193. ok
  194. end.
  195. %% this function is only used for test/check profiles
  196. get_edition_from_profile_env() ->
  197. case os:getenv("PROFILE") of
  198. "emqx-enterprise" ++ _ ->
  199. ee;
  200. "emqx" ++ _ ->
  201. ce;
  202. false ->
  203. ee;
  204. V ->
  205. io:format(standard_error, "ERROR: bad_PROFILE ~p~n", [V]),
  206. exit(bad_PROFILE)
  207. end.
  208. prod_compile_opts(Edition, Vsn) ->
  209. [
  210. compressed,
  211. deterministic,
  212. warnings_as_errors
  213. | common_compile_opts(Edition, Vsn)
  214. ].
  215. prod_overrides() ->
  216. [{add, [{erl_opts, [deterministic]}]}].
  217. profiles() ->
  218. case get_edition_from_profile_env() of
  219. ee ->
  220. profiles_ee();
  221. ce ->
  222. profiles_ce()
  223. end ++ profiles_dev().
  224. profiles_ce() ->
  225. Vsn = get_vsn(emqx),
  226. [
  227. {'emqx', [
  228. {erl_opts, prod_compile_opts(ce, Vsn)},
  229. {relx, relx(Vsn, cloud, bin, ce)},
  230. {overrides, prod_overrides()},
  231. {project_app_dirs, project_app_dirs(ce)}
  232. ]},
  233. {'emqx-pkg', [
  234. {erl_opts, prod_compile_opts(ce, Vsn)},
  235. {relx, relx(Vsn, cloud, pkg, ce)},
  236. {overrides, prod_overrides()},
  237. {project_app_dirs, project_app_dirs(ce)}
  238. ]}
  239. ].
  240. profiles_ee() ->
  241. Vsn = get_vsn('emqx-enterprise'),
  242. [
  243. {'emqx-enterprise', [
  244. {erl_opts, prod_compile_opts(ee, Vsn)},
  245. {relx, relx(Vsn, cloud, bin, ee)},
  246. {overrides, prod_overrides()},
  247. {project_app_dirs, project_app_dirs(ee)}
  248. ]},
  249. {'emqx-enterprise-pkg', [
  250. {erl_opts, prod_compile_opts(ee, Vsn)},
  251. {relx, relx(Vsn, cloud, pkg, ee)},
  252. {overrides, prod_overrides()},
  253. {project_app_dirs, project_app_dirs(ee)}
  254. ]}
  255. ].
  256. %% EE has more files than CE, always test/check with EE options.
  257. profiles_dev() ->
  258. [
  259. {check, [
  260. {erl_opts, common_compile_opts()},
  261. {project_app_dirs, project_app_dirs()}
  262. ]},
  263. {test, [
  264. {deps, test_deps()},
  265. {erl_opts, common_compile_opts() ++ erl_opts_i()},
  266. {extra_src_dirs, [{"test", [{recursive, true}]}]},
  267. {project_app_dirs, project_app_dirs()}
  268. ]}
  269. ].
  270. %% RelType: cloud (full size)
  271. %% PkgType: bin | pkg
  272. %% Edition: ce (opensource) | ee (enterprise)
  273. relx(Vsn, RelType, PkgType, Edition) ->
  274. [
  275. {include_src, false},
  276. {include_erts, true},
  277. {extended_start_script, false},
  278. {generate_start_script, false},
  279. {sys_config, false},
  280. {vm_args, false},
  281. {release, {emqx, Vsn}, relx_apps(RelType, Edition)},
  282. {overlay, relx_overlay(RelType, Edition)},
  283. {overlay_vars_values,
  284. build_info() ++
  285. [
  286. {emqx_description, emqx_description(RelType, Edition)}
  287. | overlay_vars(RelType, PkgType, Edition)
  288. ]}
  289. ].
  290. %% Make a HOCON compatible format
  291. build_info() ->
  292. Os = os_cmd("./scripts/get-distro.sh"),
  293. [
  294. {build_info_arch, erlang:system_info(system_architecture)},
  295. {build_info_wordsize, rebar_utils:wordsize()},
  296. {build_info_os, Os},
  297. {build_info_erlang, rebar_utils:otp_release()},
  298. {build_info_elixir, none},
  299. {build_info_relform, relform()}
  300. ].
  301. relform() ->
  302. case os:getenv("EMQX_REL_FORM") of
  303. false -> "tgz";
  304. Other -> Other
  305. end.
  306. emqx_description(cloud, ee) -> "EMQX Enterprise";
  307. emqx_description(cloud, ce) -> "EMQX".
  308. overlay_vars(cloud, PkgType, Edition) ->
  309. [
  310. {emqx_default_erlang_cookie, "emqxsecretcookie"}
  311. ] ++
  312. overlay_vars_pkg(PkgType) ++
  313. overlay_vars_edition(Edition).
  314. overlay_vars_edition(ce) ->
  315. [
  316. {emqx_schema_mod, emqx_conf_schema},
  317. {is_enterprise, "no"},
  318. {emqx_configuration_doc,
  319. "https://www.emqx.io/docs/en/latest/configuration/configuration.html"},
  320. {emqx_configuration_doc_log, "https://www.emqx.io/docs/en/latest/configuration/logs.html"}
  321. ];
  322. overlay_vars_edition(ee) ->
  323. [
  324. {emqx_schema_mod, emqx_enterprise_schema},
  325. {is_enterprise, "yes"},
  326. {emqx_configuration_doc,
  327. "https://docs.emqx.com/en/enterprise/latest/configuration/configuration.html"},
  328. {emqx_configuration_doc_log,
  329. "https://docs.emqx.com/en/enterprise/latest/configuration/logs.html"}
  330. ].
  331. %% vars per packaging type, bin(zip/tar.gz/docker) or pkg(rpm/deb)
  332. overlay_vars_pkg(bin) ->
  333. [
  334. {platform_data_dir, "data"},
  335. {platform_etc_dir, "etc"},
  336. {platform_plugins_dir, "plugins"},
  337. {runner_bin_dir, "$RUNNER_ROOT_DIR/bin"},
  338. {emqx_etc_dir, "$RUNNER_ROOT_DIR/etc"},
  339. {runner_lib_dir, "$RUNNER_ROOT_DIR/lib"},
  340. {runner_log_dir, "$RUNNER_ROOT_DIR/log"},
  341. {runner_user, ""},
  342. {is_elixir, "no"}
  343. ];
  344. overlay_vars_pkg(pkg) ->
  345. [
  346. {platform_data_dir, "/var/lib/emqx"},
  347. {platform_etc_dir, "/etc/emqx"},
  348. {platform_plugins_dir, "/var/lib/emqx/plugins"},
  349. {runner_bin_dir, "/usr/bin"},
  350. {emqx_etc_dir, "/etc/emqx"},
  351. {runner_lib_dir, "$RUNNER_ROOT_DIR/lib"},
  352. {runner_log_dir, "/var/log/emqx"},
  353. {runner_user, "emqx"},
  354. {is_elixir, "no"}
  355. ].
  356. relx_apps(ReleaseType, Edition) ->
  357. {ok, [
  358. #{
  359. db_apps := DBApps,
  360. system_apps := SystemApps,
  361. common_business_apps := CommonBusinessApps,
  362. ee_business_apps := EEBusinessApps,
  363. ce_business_apps := CEBusinessApps
  364. }
  365. ]} = file:consult("apps/emqx_machine/priv/reboot_lists.eterm"),
  366. EditionSpecificApps =
  367. case Edition of
  368. ee -> EEBusinessApps;
  369. ce -> CEBusinessApps
  370. end,
  371. BusinessApps = CommonBusinessApps ++ EditionSpecificApps,
  372. Apps =
  373. (SystemApps ++
  374. %% EMQX starts the DB and the business applications:
  375. [{App, load} || App <- DBApps] ++
  376. [emqx_machine] ++
  377. [{App, load} || App <- BusinessApps]),
  378. lists:foldl(fun proplists:delete/2, Apps, excluded_apps(ReleaseType)).
  379. excluded_apps(_ReleaseType) ->
  380. OptionalApps = [
  381. {quicer, is_quicer_supported()},
  382. {jq, is_jq_supported()},
  383. {observer, is_app(observer)},
  384. {mnesia_rocksdb, is_rocksdb_supported()}
  385. ],
  386. [App || {App, false} <- OptionalApps].
  387. is_app(Name) ->
  388. case application:load(Name) of
  389. ok -> true;
  390. {error, {already_loaded, _}} -> true;
  391. _ -> false
  392. end.
  393. relx_overlay(ReleaseType, Edition) ->
  394. [
  395. {mkdir, "log/"},
  396. {mkdir, "data/"},
  397. {mkdir, "plugins"},
  398. {mkdir, "data/mnesia"},
  399. {mkdir, "data/configs"},
  400. {mkdir, "data/patches"},
  401. {mkdir, "data/scripts"},
  402. {template, "rel/emqx_vars", "releases/emqx_vars"},
  403. {template, "rel/BUILD_INFO", "releases/{{release_version}}/BUILD_INFO"},
  404. {copy, "bin/emqx", "bin/emqx"},
  405. {copy, "bin/emqx_ctl", "bin/emqx_ctl"},
  406. {copy, "bin/emqx_cluster_rescue", "bin/emqx_cluster_rescue"},
  407. {copy, "bin/node_dump", "bin/node_dump"},
  408. {copy, "bin/install_upgrade.escript", "bin/install_upgrade.escript"},
  409. {copy, "bin/emqx", "bin/emqx-{{release_version}}"},
  410. {copy, "bin/emqx_ctl", "bin/emqx_ctl-{{release_version}}"},
  411. {copy, "bin/install_upgrade.escript", "bin/install_upgrade.escript-{{release_version}}"},
  412. {copy, "apps/emqx_gateway_lwm2m/lwm2m_xml", "etc/lwm2m_xml"},
  413. {copy, "apps/emqx_auth/etc/acl.conf", "etc/acl.conf"},
  414. {template, "bin/emqx.cmd", "bin/emqx.cmd"},
  415. {template, "bin/emqx_ctl.cmd", "bin/emqx_ctl.cmd"},
  416. {copy, "bin/nodetool", "bin/nodetool"},
  417. {copy, "bin/nodetool", "bin/nodetool-{{release_version}}"}
  418. ] ++ etc_overlay(ReleaseType, Edition).
  419. etc_overlay(ReleaseType, Edition) ->
  420. Templates = emqx_etc_overlay(ReleaseType),
  421. [
  422. {mkdir, "etc/"},
  423. {copy, "{{base_dir}}/lib/emqx/etc/certs", "etc/"}
  424. | copy_examples(Edition)
  425. ] ++
  426. lists:map(
  427. fun
  428. ({From, To}) -> {template, From, To};
  429. (FromTo) -> {template, FromTo, FromTo}
  430. end,
  431. Templates
  432. ).
  433. copy_examples(ce) ->
  434. [{copy, "rel/config/examples", "etc/"}];
  435. copy_examples(ee) ->
  436. [
  437. {copy, "rel/config/examples", "etc/"},
  438. {copy, "rel/config/ee-examples/*", "etc/examples/"}
  439. ].
  440. emqx_etc_overlay(ReleaseType) ->
  441. emqx_etc_overlay_per_rel(ReleaseType) ++
  442. emqx_etc_overlay().
  443. emqx_etc_overlay_per_rel(cloud) ->
  444. [{"{{base_dir}}/lib/emqx/etc/vm.args.cloud", "etc/vm.args"}].
  445. emqx_etc_overlay() ->
  446. [
  447. {"{{base_dir}}/lib/emqx/etc/ssl_dist.conf", "etc/ssl_dist.conf"},
  448. {"{{base_dir}}/lib/emqx_conf/etc/emqx.conf.all", "etc/emqx.conf"}
  449. ].
  450. get_vsn(Profile) ->
  451. case os:getenv("PKG_VSN") of
  452. false ->
  453. os_cmd("pkg-vsn.sh " ++ atom_to_list(Profile));
  454. Vsn ->
  455. Vsn
  456. end.
  457. %% to make it compatible to Linux and Windows,
  458. %% we must use bash to execute the bash file
  459. %% because "./" will not be recognized as an internal or external command
  460. os_cmd(Cmd) ->
  461. Output = os:cmd("bash " ++ Cmd),
  462. re:replace(Output, "\n", "", [{return, list}]).
  463. maybe_dump(Config) ->
  464. is_debug() andalso
  465. file:write_file("rebar.config.rendered", [io_lib:format("~p.\n", [I]) || I <- Config]),
  466. Config.
  467. is_debug() -> is_debug("DEBUG") orelse is_debug("DIAGNOSTIC").
  468. is_debug(VarName) ->
  469. case os:getenv(VarName) of
  470. false -> false;
  471. "" -> false;
  472. _ -> true
  473. end.
  474. erl_opts_i() ->
  475. [{i, "apps"}] ++
  476. [{i, Dir} || Dir <- filelib:wildcard(filename:join(["apps", "*", "include"]))].
  477. dialyzer(Config) ->
  478. {dialyzer, OldDialyzerConfig} = lists:keyfind(dialyzer, 1, Config),
  479. AppsToAnalyse =
  480. case os:getenv("DIALYZER_ANALYSE_APP") of
  481. false ->
  482. [];
  483. Value ->
  484. [list_to_atom(App) || App <- string:tokens(Value, ",")]
  485. end,
  486. AppNames = app_names(),
  487. KnownApps = [Name || Name <- AppsToAnalyse, lists:member(Name, AppNames)],
  488. AppsToExclude = AppNames -- KnownApps,
  489. Extra =
  490. [system_monitor, tools, covertool] ++
  491. [jq || is_jq_supported()] ++
  492. [quicer || is_quicer_supported()],
  493. NewDialyzerConfig =
  494. OldDialyzerConfig ++
  495. [{exclude_apps, AppsToExclude} || length(AppsToAnalyse) > 0] ++
  496. [{plt_extra_apps, Extra} || length(Extra) > 0],
  497. lists:keystore(
  498. dialyzer,
  499. 1,
  500. Config,
  501. {dialyzer, NewDialyzerConfig}
  502. ).
  503. coveralls() ->
  504. case {os:getenv("GITHUB_ACTIONS"), os:getenv("GITHUB_TOKEN")} of
  505. {"true", Token} when is_list(Token) ->
  506. Cfgs = [
  507. {coveralls_repo_token, Token},
  508. {coveralls_service_job_id, os:getenv("GITHUB_RUN_ID")},
  509. {coveralls_commit_sha, os:getenv("GITHUB_SHA")},
  510. {coveralls_coverdata, "_build/test/cover/*.coverdata"},
  511. {coveralls_parallel, true},
  512. {coveralls_service_name, "github"}
  513. ],
  514. case
  515. os:getenv("GITHUB_EVENT_NAME") =:= "pull_request" andalso
  516. string:tokens(os:getenv("GITHUB_REF"), "/")
  517. of
  518. [_, "pull", PRNO, _] ->
  519. [{coveralls_service_pull_request, PRNO} | Cfgs];
  520. _ ->
  521. Cfgs
  522. end;
  523. _ ->
  524. []
  525. end.
  526. app_names() -> list_dir("apps").
  527. list_dir(Dir) ->
  528. case filelib:is_dir(Dir) of
  529. true ->
  530. {ok, Names} = file:list_dir(Dir),
  531. [list_to_atom(Name) || Name <- Names, filelib:is_dir(filename:join([Dir, Name]))];
  532. false ->
  533. []
  534. end.