Skip to content

Commit

Permalink
Add Github Actions CI
Browse files Browse the repository at this point in the history
With a few associated fixes to make sure it compiles on versions < 20
  • Loading branch information
nickva committed Jun 7, 2024
1 parent 9ea1b35 commit 0ebc7c2
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 34 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: ci

on:
workflow_dispatch:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
linux:
name: ${{matrix.os}}-${{matrix.otp_version}}-${{matrix.rebar}}
runs-on: ${{matrix.os}}

strategy:
fail-fast: false
matrix:
otp_version: [20,23,26,27]
os: [ubuntu-latest]
rebar: [rebar, rebar3]

container:
image: erlang:${{matrix.otp_version}}

steps:
- uses: actions/checkout@v4
- name: ${{matrix.rebar}} make check
run: |
make REBAR=${{matrix.rebar}} check
macos:
name: macos
runs-on: ${{matrix.os}}

strategy:
fail-fast: false
matrix:
os: [macos-12, macos-14]

steps:
- uses: actions/checkout@v4
- name: install erlang
run: |
brew install erlang
- name: install rebar3
run: |
brew install rebar3
- name: make check
run: |
make check
windows:
name: windows
runs-on: ${{matrix.os}}

strategy:
fail-fast: false
matrix:
os: [windows-2019, windows-2022]

steps:
- name: prevent git from messing up our json test files
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v4
- name: install erlang
run: |
choco install erlang
- name: install rebar3
run: |
choco install rebar3
- name: make check
run: |
$path = vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -nologo -nocolor -property installationPath
if ($path) {
$path = join-path $path '\VC\Auxiliary\Build\vcvars64.bat'
if (test-path $path) {
cmd /s /c """$path"" $args && set" | where { $_ -match '(\w+)=(.*)' } | foreach {
$null = new-item -force -path "Env:\$($Matches[1])" -value $Matches[2]
}
}
}
make check
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

12 changes: 2 additions & 10 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,9 @@
"CXXFLAGS", "$CXXFLAGS -Ic_src/ -g -Wall $FLTO_FLAG -Werror -O3"},

{"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin|gnu)",
"LDFLAGS", "$LDFLAGS $FLTO_FLAG -lstdc++"},
"LDFLAGS", "$LDFLAGS $FLTO_FLAG -lstdc++"}

%% OS X Leopard flags for 64-bit
{"darwin9.*-64$", "CXXFLAGS", "-m64"},
{"darwin9.*-64$", "LDFLAGS", "-arch x86_64"},

%% OS X Snow Leopard flags for 32-bit
{"darwin10.*-32$", "CXXFLAGS", "-m32"},
{"darwin10.*-32$", "LDFLAGS", "-arch i386"},

{"win32", "CXXFLAGS", "$CXXFLAGS /O2 /DNDEBUG"}
% {"win32", "CXXFLAGS", "$CXXFLAGS /O2 /DNDEBUG"}
]}.

{erl_opts, [
Expand Down
9 changes: 6 additions & 3 deletions rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ end,

IsRebar2 = case lists:keyfind(rebar, 1, application:loaded_applications()) of
{rebar, _Desc, Vsn} ->
case string:split(Vsn, ".") of
case string:tokens(Vsn, ".") of
["2" | _] -> true;
_ -> false
end;
Expand All @@ -53,8 +53,11 @@ case IsRebar2 of
Config2;
false ->
Config2 ++ [
{plugins, [{pc, "~> 1.0"}]},
{artifacts, ["priv/jiffy.so"]},
{plugins, [{pc, "~> 1.15"}]},
case os:type() of
{win32, _} -> {artifacts, ["priv/jiffy.dll"]};
{_, _} -> {artifacts, ["priv/jiffy.so"]}
end,
{provider_hooks, [
{post, [
{compile, {pc, compile}},
Expand Down
4 changes: 2 additions & 2 deletions test/jiffy_03_number_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ gen(error, J) ->
gen(floats, F) ->
NegF = -1.0 * F,
{msg("float round trip - ~p", [F]), [
{"Pos", ?_assertEqual(F, dec(enc(F)))},
{"Neg", ?_assertEqual(NegF, dec(enc(NegF)))}
{"Pos", ?_assert(F == dec(enc(F)))},
{"Neg", ?_assert(NegF == dec(enc(NegF)))}
]}.


Expand Down
8 changes: 4 additions & 4 deletions test/jiffy_17_copy_strings_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ check_binaries(_Bin) ->
copy_strings_test_() ->
Opts = [copy_strings],
Cases = [
<<"\"foo\"">>,
<<"[\"bar\"]">>,
<<"{\"foo\":\"bar\"}">>,
<<"{\"foo\":[\"bar\"]}">>
<<"\"xoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\"">>,
<<"[\"yoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\"]">>,
<<"{\"zoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\":\"woooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\"}">>,
<<"{\"koooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\":[\"loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\"]}">>
],
{"Test copy_strings", lists:map(fun(Json) ->
EJson = jiffy:decode(Json, Opts),
Expand Down
3 changes: 1 addition & 2 deletions test/jiffy_util.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ cases_path(Suffix) ->
".eunit" -> "..";
_ -> "."
end,
Path = "test/cases",
filename:join([Prefix, Path, Suffix]).
filename:join([Prefix, "test", "cases", Suffix]).

0 comments on commit 0ebc7c2

Please sign in to comment.