Skip to content

Commit

Permalink
Update build scripts, using xmpp library as example
Browse files Browse the repository at this point in the history
  • Loading branch information
badlop committed Jan 7, 2025
1 parent 6074899 commit 954300b
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 30 deletions.
32 changes: 18 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,47 @@ jobs:
strategy:
fail-fast: false
matrix:
otp: ['19.3', '21.3', 24]
runs-on: ubuntu-20.04
otp: [20, 25, 26, 27]
runs-on: ubuntu-24.04
container:
image: erlang:${{ matrix.otp }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Prepare libraries
run: |
apt-get -qq update
apt-get -qq install libgd-dev libjpeg-dev libpng-dev libwebp-dev
- run: ./configure
- run: make
- run: rebar3 compile
- run: rebar3 xref
- run: rebar3 dialyzer
if: matrix.otp >= 22
- run: REBAR=rebar3 make
- run: REBAR=rebar3 make xref
- run: REBAR=rebar3 make dialyzer
- run: rebar3 eunit -v

cover:
name: Cover
needs: [tests]
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
container:
image: erlang:26
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Prepare libraries
run: |
sudo apt-get -qq update
sudo apt-get -qq install libgd-dev libjpeg-dev libpng-dev libwebp-dev
apt-get -qq update
apt-get -qq install libgd-dev libjpeg-dev libpng-dev libwebp-dev
- run: ./configure --enable-gcov
- run: rebar3 compile
- run: REBAR=rebar3 make
- run: rebar3 eunit -v
- run: pip install --user cpp-coveralls
- run: cpp-coveralls -b `pwd` --verbose --gcov-options '\-lp' --dump c.json
#- run: pip install --user cpp-coveralls
#- run: cpp-coveralls -b `pwd` --verbose --gcov-options '\-lp' --dump c.json
- name: Send to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ADDJSONFILE=c.json COVERALLS=true rebar3 as test coveralls send
#ADDJSONFILE=c.json COVERALLS=true rebar3 as test coveralls send
COVERALLS=true rebar3 as test coveralls send
curl -v -k https://coveralls.io/webhook \
--header "Content-Type: application/json" \
--data '{"repo_name":"$GITHUB_REPOSITORY",
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/hexpm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ on:

jobs:
release:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- name: Check out
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Generate documentation
run: rebar3 edoc
Expand Down Expand Up @@ -39,6 +39,6 @@ jobs:
echo "{plugins, [rebar3_hex]}." > ~/.config/rebar3/rebar.config
- name: Publish to hex.pm
run: DIAGNOSTIC=1 rebar3 hex publish --repo hexpm --yes ; head rebar3.crashdump
run: DEBUG=1 rebar3 hex publish --repo hexpm --yes
env:
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

{port_specs, [{"priv/bin/eimp", ["c_src/eimp.c"]}]}.

{deps, [{p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.26"}}}]}.
{deps, [{p1_utils, "~> 1.0.25", {git, "https://github.com/processone/p1_utils", {tag, "1.0.26"}}}]}.

{clean_files, ["c_src/eimp.gcda", "c_src/eimp.gcno"]}.

Expand Down
70 changes: 58 additions & 12 deletions rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,31 @@ AppendList = fun(Append) ->
end
end,

Rebar3DepsFilter = fun(DepsList) ->
lists:map(fun({DepName,_, {git,_, {tag,Version}}}) ->
{DepName, Version};
(Dep) ->
Dep
end, DepsList)
end,
% Convert our rich deps syntax to rebar2 format:
% https://github.com/rebar/rebar/wiki/Dependency-management
Rebar2DepsFilter =
fun(DepsList) ->
lists:map(fun({DepName, _HexVersion, Source}) ->
{DepName, ".*", Source}
end, DepsList)
end,

% Convert our rich deps syntax to rebar3 version definition format:
% https://rebar3.org/docs/configuration/dependencies/#dependency-version-handling
% https://hexdocs.pm/elixir/Version.html
Rebar3DepsFilter =
fun(DepsList) ->
lists:map(fun({DepName, HexVersion, {git, _, {tag, GitVersion}} = Source}) ->
case HexVersion == ".*" of
true ->
{DepName, GitVersion};
false ->
{DepName, HexVersion}
end;
({DepName, _HexVersion, Source}) ->
{DepName, ".*", Source}
end, DepsList)
end,

GlobalDepsFilter = fun(Deps) ->
DepNames = lists:map(fun({DepName, _, _}) -> DepName;
Expand All @@ -187,6 +205,30 @@ GlobalDepsFilter = fun(Deps) ->
end, DepNames)
end,

ResolveDepPath = case IsRebar3 of
true ->
fun("deps/" ++ Rest) ->
Slash = string:str(Rest, "/"),
"_build/default/lib/" ++
string:sub_string(Rest, 1, Slash - 1) ++
string:sub_string(Rest, Slash);
(Path) ->
Path
end;
_ ->
fun(P) ->
P
end
end,

ProcessErlOpt = fun(Vals) ->
lists:map(
fun({i, Path}) ->
{i, ResolveDepPath(Path)};
(ErlOpt) ->
ErlOpt
end, Vals)
end,
GithubConfig = case {os:getenv("GITHUB_ACTIONS"), os:getenv("GITHUB_TOKEN")} of
{"true", Token} when is_list(Token) ->
CONFIG1 = [{coveralls_repo_token, Token},
Expand Down Expand Up @@ -219,21 +261,25 @@ Rules = [
AppendStr("--coverage"), ""},
{[port_env, "CFLAGS"], CfgWithGCov == "true",
AppendStr("--coverage"), ""},
{[deps], (not IsRebar3),
Rebar2DepsFilter, []},
{[deps], IsRebar3,
Rebar3DepsFilter, []},
{[plugins], IsRebar3,
AppendList([pc]), []},
AppendList([{pc, "~> 1.15.0"}, provider_asn1]), []},
{[provider_hooks], IsRebar3,
AppendList([{pre, [
{compile, {pc, compile}},
{clean, {pc, clean}}
]}]), []},
{[plugins], os:getenv("COVERALLS") == "true",
AppendList([{coveralls, {git,
"https://github.com/processone/coveralls-erl.git",
{branch, "addjsonfile"}}} ]), []},
AppendList([{coveralls, ".*",
{git, "https://github.com/processone/coveralls-erl.git",
{branch, "addjsonfile"}}} ]), []},
{[deps], os:getenv("USE_GLOBAL_DEPS") /= false,
GlobalDepsFilter, []}
GlobalDepsFilter, []},
{[erl_opts], true,
ProcessErlOpt, []}
],


Expand Down

0 comments on commit 954300b

Please sign in to comment.