ci(fix): actually fail check for missing reboot apps

This commit is contained in:
Thales Macedo Garitezi 2023-07-11 20:07:16 -03:00
parent 0fc4a9291b
commit bc76e818dc
3 changed files with 44 additions and 9 deletions

View File

@ -99,7 +99,7 @@ static_checks:
@$(REBAR) as check do xref, dialyzer
@if [ "$${PROFILE}" = 'emqx-enterprise' ]; then $(REBAR) ct --suite apps/emqx/test/emqx_static_checks --readable $(CT_READABLE); fi
./scripts/check-i18n-style.sh
./scripts/check_missing_reboot_apps.exs --profile $(PROFILE)
./scripts/check_missing_reboot_apps.exs
APPS=$(shell $(SCRIPTS)/find-apps.sh)

21
mix.exs
View File

@ -443,13 +443,32 @@ defmodule EMQXUmbrella.MixProject do
def check_profile!() do
valid_envs = [
:dev,
:emqx,
:"emqx-pkg",
:"emqx-enterprise",
:"emqx-enterprise-pkg"
]
if Mix.env() == :dev do
env_profile = System.get_env("PROFILE")
if env_profile do
# copy from PROFILE env var
System.get_env("PROFILE")
|> String.to_atom()
|> Mix.env()
else
IO.puts(
IO.ANSI.format([
:yellow,
"Warning: env var PROFILE is unset; defaulting to emqx"
])
)
Mix.env(:emqx)
end
end
if Mix.env() not in valid_envs do
formatted_envs =
valid_envs

View File

@ -1,19 +1,33 @@
#!/usr/bin/env elixir
{parsed, _argv, _errors = []} =
OptionParser.parse(
System.argv(),
strict: [profile: :string]
)
alias EMQXUmbrella.MixProject
profile = Keyword.fetch!(parsed, :profile)
{:ok, _} = Application.ensure_all_started(:mix)
# note: run from the project root
File.cwd!()
|> Path.join("mix.exs")
|> Code.compile_file()
inputs = MixProject.check_profile!()
profile = Mix.env()
# need to use this information because we might have compiled all
# applications in the test profile, and thus filter what's in the
# release lib directory.
rel_apps = MixProject.applications(inputs.edition_type)
apps =
rel_apps
|> Keyword.keys()
|> Enum.filter(&(to_string(&1) =~ "emqx"))
|> Enum.reject(&(&1 in [:emqx_mix]))
:xref.start(:xref)
:xref.set_default(:xref, warnings: false)
rel_dir = '_build/#{profile}/lib/'
:xref.add_release(:xref, rel_dir)
{:ok, calls} = :xref.q(:xref, '(App) (XC || "mria":"create_table"/".*")')
{:ok, calls} = :xref.q(:xref, '(App) (XC | [#{Enum.join(apps, ",")}] || mria:create_table/_)')
emqx_calls =
calls
@ -59,4 +73,6 @@ if MapSet.size(missing_reboot_apps) != 0 do
" otherwise, when a node joins a cluster, it might lose tables.\n"
])
)
System.halt(1)
end