Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer erlang app to mix project #2588

Merged
merged 2 commits into from
Jun 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/shelltests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Shell tests

on:
pull_request:
branches:
- 'master'
push:
branches:
- 'master'

jobs:
shelltests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
with:
otp-version: '24.0.1'
elixir-version: '1.12'
- name: Compile
run: ./bootstrap
- name: Install
run: cp ./rebar3 /usr/bin/

- name: Checkout shell tests
run: git checkout https://github.com/tsloughter/rebar3_tests

- name: Install and run shelltestrunner
run: |
apt-get update
apt-get install -y shelltestrunner build-essential
mix local.hex --force
./run_tests.sh
14 changes: 10 additions & 4 deletions src/rebar_app_discover.erl
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ app_dirs(LibDir, SrcDirs, State) ->
]),

EbinPath = filename:join([LibDir, "ebin", "*.app"]),
MixExsPath = filename:join([LibDir, "src", "mix.exs"]),
MixExsPath = filename:join([LibDir, "mix.exs"]),

lists:usort(lists:foldl(fun(Path, Acc) ->
Files = filelib:wildcard(rebar_utils:to_list(Path)),
Expand Down Expand Up @@ -350,7 +350,7 @@ find_app_(AppInfo, AppDir, SrcDirs, Validate, State) ->
end || SrcDir <- SrcDirs],
ResourceFiles = [
{app, filelib:wildcard(filename:join([AppDir, "ebin", "*.app"]))},
{mix_exs, filelib:wildcard(filename:join([AppDir, "src", "mix.exs"]))}
{mix_exs, filelib:wildcard(filename:join([AppDir, "mix.exs"]))}
| [{extension_type(Ext),
lists:append([filelib:wildcard(filename:join([AppDir, SrcDir, "*" ++ Ext]))
|| SrcDir <- NormSrcDirs])}
Expand Down Expand Up @@ -451,8 +451,14 @@ try_handle_resource_files(AppInfo, AppDir, [{app, AppFile} | Rest], Validate) ->
try_handle_resource_files(AppInfo, AppDir, [{Type, AppSrcFile} | _Rest], Validate)
when Type =:= app_src orelse Type =:= script ->
try_handle_app_src_file(AppInfo, AppDir, AppSrcFile, Validate);
try_handle_resource_files(AppInfo, _AppDir, [{mix_exs, _AppSrcFile} | _Rest], _Validate) ->
{true, rebar_app_info:project_type(AppInfo, mix)};
try_handle_resource_files(AppInfo, AppDir, [{mix_exs, _MixExs} | Rest], Validate) ->
%% prefer a rebar3 buildable app if both are found
case try_handle_resource_files(AppInfo, AppDir, Rest, Validate) of
false ->
{true, rebar_app_info:project_type(AppInfo, mix)};
{true, _}=Result ->
Result
end;
try_handle_resource_files(_AppInfo, _AppDir, [], _Validate) ->
false.

Expand Down