diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec3ec77f..92c3d2d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,38 +35,20 @@ jobs: - otp_version: 25 - otp_version: 24 - - - otp_version: 23 - - - otp_version: 22 - - - otp_version: 21 send_coverage: true - run_dialyzer: true steps: - uses: actions/checkout@v3 - - if: matrix.old_rebar - run: echo "REBAR3=./rebar3" >> $GITHUB_ENV - - if: matrix.erl_hist run: echo "XPROF_ERL_HIST=true" >> $GITHUB_ENV - - if: matrix.old_cowboy - run: echo "COWBOY_VERSION=1.1.2" >> $GITHUB_ENV - - name: Cache hex packages uses: actions/cache@v3 with: path: $HOME/.cache/rebar3 key: ${{ matrix.otp_version }}-rebar3-cache - # cowboy 2.7+ require OTP 20 and 2.11+ require OTP 24+. On OTP 19-23 pin to - # cowboy 2.6.3, last version that compiles fine on these old OTP versions. - - if: ${{ matrix.otp_version <= 23 && !matrix.old_cowboy }} - run: echo "COWBOY_VERSION=2.6.3" >> $GITHUB_ENV - - run: make test - if: matrix.run_dialyzer @@ -74,61 +56,11 @@ jobs: timeout-minutes: 8 - if: matrix.send_coverage && success() - run: ./rebar3 as test coveralls send + run: make send_coveralls env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} continue-on-error: true - # Same as the "test" job but for OTP 18-20, whose containers ship a glibc - # too old for the node20 runtime that actions/checkout and actions/cache - # now require. This job checks out with plain git and skips the cache. - test_legacy: - name: OTP ${{ matrix.otp_version }} (legacy) - runs-on: ubuntu-latest - container: erlang:${{ matrix.otp_version }} - - strategy: - fail-fast: false - matrix: - include: - - otp_version: 20 - - - otp_version: 19 - - - otp_version: 19 - erl_hist: true - - - otp_version: 18 - # old_rebar fails with "Package not found in registry: {<<"hdr_histogram">>,<<"0.5.0">>}." - # with hdr_histogram NIF: xprof_core_hist_SUITE: Segmentation fault (core dumped) - erl_hist: true - old_cowboy: true - - steps: - - name: Checkout with git (avoids node-based actions on old glibc) - run: | - git config --global --add safe.directory $GITHUB_WORKSPACE - git init -q - git remote add origin "https://github.com/${{ github.repository }}" - git fetch -q --depth 1 origin "${{ github.ref }}" - git checkout -q FETCH_HEAD - - - if: matrix.old_rebar - run: echo "REBAR3=./rebar3" >> $GITHUB_ENV - - - if: matrix.erl_hist - run: echo "XPROF_ERL_HIST=true" >> $GITHUB_ENV - - - if: matrix.old_cowboy - run: echo "COWBOY_VERSION=1.1.2" >> $GITHUB_ENV - - # cowboy 2.7+ require OTP 20 and 2.11+ require OTP 24+. On OTP 19-23 pin to - # cowboy 2.6.3, last version that compiles fine on these old OTP versions. - - if: ${{ matrix.otp_version <= 23 && !matrix.old_cowboy }} - run: echo "COWBOY_VERSION=2.6.3" >> $GITHUB_ENV - - - run: make test - test_json_lib: name: Test different json lib (${{ matrix.json_lib }} | OTP ${{ matrix.otp_version }}) runs-on: ubuntu-latest @@ -138,7 +70,7 @@ jobs: strategy: fail-fast: false matrix: - otp_version: [21] + otp_version: [24] json_lib: [jiffy, jsx, thoas] steps: @@ -150,11 +82,6 @@ jobs: path: $HOME/.cache/rebar3 key: ${{ matrix.otp_version }}-rebar3-cache-json-lib - # cowboy 2.7+ require OTP 20 and 2.11+ require OTP 24+. On OTP 19-23 pin to - # cowboy 2.6.3, last version that compiles fine on these old OTP versions. - - if: ${{ matrix.otp_version <= 23 && !matrix.old_cowboy }} - run: echo "COWBOY_VERSION=2.6.3" >> $GITHUB_ENV - - run: make test_${{ matrix.json_lib }} test_docs: @@ -263,26 +190,15 @@ jobs: elixir-version: ${{matrix.elixir}} rebar3-version: ${{matrix.rebar3}} - - if: matrix.old_rebar - run: echo "REBAR3=./rebar3" >> $GITHUB_ENV - - if: matrix.erl_hist run: echo "XPROF_ERL_HIST=true" >> $GITHUB_ENV - - if: matrix.old_cowboy - run: echo "COWBOY_VERSION=1.1.2" >> $GITHUB_ENV - - name: Cache hex packages uses: actions/cache@v3 with: path: $HOME/.cache/rebar3 key: ${{ matrix.otp_version }}-rebar3-cache - # cowboy 2.7+ require OTP 20 and 2.11+ require OTP 24+. On OTP 19-23 pin to - # cowboy 2.6.3, last version that compiles fine on these old OTP versions. - - if: ${{ matrix.otp_version <= 23 && !matrix.old_cowboy }} - run: echo "COWBOY_VERSION=2.6.3" >> $GITHUB_ENV - - run: make test test_front_end: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a9b518fe..00000000 --- a/.travis.yml +++ /dev/null @@ -1,43 +0,0 @@ -# Currently only travis can -# - run Elixir tests (OTP 18+) -# - run on old Erlang version (OTP R16B) -# - submit coveralls report - -language: erlang -branches: - only: - - master -matrix: - include: - - otp_release: 23.0 - env: - - NEW_REBAR=true - # hdr_histogram up to 0.4.0 fails to compile with OTP 23 - - XPROF_ERL_HIST=true - - ELIXIR_VERSION=1.10.3 - - otp_release: 22.3 - env: NEW_REBAR=true - - otp_release: 21.3 - env: NEW_REBAR=true - - otp_release: 20.3 - - otp_release: 19.3 - - otp_release: 19.3 - env: XPROF_ERL_HIST=true - - otp_release: 18.3 - dist: trusty - env: COWBOY_VERSION=1.1.2 -cache: - directories: - - $HOME/.cache/rebar3 - - $HOME/.kiex/ -install: - - if [ -n "$ELIXIR_VERSION" ]; then kiex use "$ELIXIR_VERSION" --default || (kiex install "$ELIXIR_VERSION" && kiex use "$ELIXIR_VERSION" --default); fi - - if [ -n "$NEW_REBAR" ]; then curl -O -L https://s3.amazonaws.com/rebar3/rebar3 && chmod +x ./rebar3 ; fi - - ./rebar3 --version - - ./rebar3 deps -script: - - kiex use "$ELIXIR_VERSION" && make test - - if [ $TRAVIS_OTP_RELEASE = "21.3" ]; then make doc dialyzer; fi - - if [ $TRAVIS_OTP_RELEASE = "18.3" ]; then make dialyzer; fi # run dialyzer with cowboy 1.x too -after_success: - - if [ $TRAVIS_OTP_RELEASE = "21.3" ]; then ./rebar3 as test coveralls send; fi diff --git a/Makefile b/Makefile index 239de544..3087d28a 100644 --- a/Makefile +++ b/Makefile @@ -2,23 +2,17 @@ JS_PRIV=apps/xprof_gui/priv BIN_DIR:=node_modules/.bin REBAR3?=$(shell which rebar3 || echo ./rebar3) -# this will update cowboy version based on rebar.config overwriting the lock file -ifdef COWBOY_VERSION - MAYBE_UPDATE_COWBOY = $(REBAR3) upgrade cowboy -endif ifdef XPROF_ERL_HIST MAYBE_UNLOCK_HIST = $(REBAR3) unlock hdr_histogram endif compile: - $(MAYBE_UPDATE_COWBOY) $(MAYBE_UNLOCK_HIST) $(REBAR3) compile dev: dev_front_end dev_back_end dev_back_end: - $(MAYBE_UPDATE_COWBOY) $(MAYBE_UNLOCK_HIST) $(REBAR3) as dev compile, shell @@ -37,28 +31,27 @@ build_prod_front_end: cd $(JS_PRIV); npm run build test: compile - $(MAYBE_UPDATE_COWBOY) $(MAYBE_UNLOCK_HIST) $(REBAR3) as test do cover --reset, eunit -c, ct -c, cover --verbose test_jiffy: - $(MAYBE_UPDATE_COWBOY) $(MAYBE_UNLOCK_HIST) export XPROF_JSON_LIB=jiffy; \ $(REBAR3) as test_jiffy do compile, dialyzer, cover --reset, ct -c, cover --verbose test_jsx: - $(MAYBE_UPDATE_COWBOY) $(MAYBE_UNLOCK_HIST) export XPROF_JSON_LIB=jsx; \ $(REBAR3) as test_jsx do compile, dialyzer, cover --reset, ct -c, cover --verbose test_thoas: - $(MAYBE_UPDATE_COWBOY) $(MAYBE_UNLOCK_HIST) export XPROF_JSON_LIB=thoas; \ $(REBAR3) as test_thoas do compile, dialyzer, cover --reset, ct -c, cover --verbose +send_coveralls: + $(REBAR3) as test coveralls send + doc: $(REBAR3) edoc @@ -68,7 +61,6 @@ doc: -e '1 s|\[!\[.*||' README.md > ./doc/src/readme.md gen_ex_doc: ./doc/src/readme.md - $(MAYBE_UPDATE_COWBOY) $(MAYBE_UNLOCK_HIST) $(REBAR3) as docs ex_doc --app xprof_core $(REBAR3) as docs ex_doc --app xprof_gui @@ -77,7 +69,6 @@ gen_ex_doc: ./doc/src/readme.md $(REBAR3) as docs ex_doc --app xprof dialyzer: - $(MAYBE_UPDATE_COWBOY) $(MAYBE_UNLOCK_HIST) $(REBAR3) dialyzer @@ -87,4 +78,4 @@ publish: publish_docs: gen_ex_doc $(REBAR3) as publish hex docs -.PHONY: compile dev dev_back_end dev_front_end npm bootstrap_front_end test_front_end build_prod_front_end test doc gen_ex_doc dialyzer publish publish_docs +.PHONY: compile dev dev_back_end dev_front_end npm bootstrap_front_end test_front_end build_prod_front_end test send_coveralls doc gen_ex_doc dialyzer publish publish_docs diff --git a/README.md b/README.md index 0074f97a..51c68341 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -XProf [![Build Status](https://travis-ci.org/Appliscale/xprof.svg?branch=master)](https://travis-ci.org/Appliscale/xprof) [![Coverage Status](https://coveralls.io/repos/github/Appliscale/xprof/badge.svg?branch=master)](https://coveralls.io/github/Appliscale/xprof?branch=master) [![Hex.pm](https://img.shields.io/hexpm/v/xprof.svg?style=flat-square)](https://hex.pm/packages/xprof) [![Hex.pm](https://img.shields.io/hexpm/dt/xprof.svg?style=flat-square)](https://hex.pm/packages/xprof) [![Gitter](https://badges.gitter.im/Appliscale/xprof.svg)](https://gitter.im/Appliscale/xprof?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) +XProf [![Coverage Status](https://coveralls.io/repos/github/Appliscale/xprof/badge.svg?branch=master)](https://coveralls.io/github/Appliscale/xprof?branch=master) [![Hex.pm](https://img.shields.io/hexpm/v/xprof.svg?style=flat-square)](https://hex.pm/packages/xprof) [![Hex.pm](https://img.shields.io/hexpm/dt/xprof.svg?style=flat-square)](https://hex.pm/packages/xprof) [![Gitter](https://badges.gitter.im/Appliscale/xprof.svg)](https://gitter.im/Appliscale/xprof?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) ===== *XProf* is a visual tracer and profiler that allows you to track execution of Elixir / Erlang @@ -50,7 +50,7 @@ The preferred way is to add the `xprof` *Hex* package as a dependency to your re {deps, [ ... - {xprof, "2.0.0-rc.5"} + {xprof, "2.0.0"} ]}. ``` @@ -60,7 +60,7 @@ The preferred way is to add the `xprof` *Hex* package as a dependency to your re defp deps do [ ... - {:xprof, "~> 2.0.0-rc.5"} + {:xprof, "~> 2.0.0"} ] end ``` @@ -70,15 +70,15 @@ You can also fetch from the github repository (not recommended, only for develop ```erlang {deps, [ ... - {xprof_core, {git_subdir, "https://github.com/Appliscale/xprof.git", {tag, "2.0.0-rc.5"}, "apps/xprof_core"}}, - {xprof_gui, {git_subdir, "https://github.com/Appliscale/xprof.git", {tag, "2.0.0-rc.5"}, "apps/xprof_gui"}}, - {xprof, {git_subdir, "https://github.com/Appliscale/xprof.git", {tag, "2.0.0-rc.5"}, "apps/xprof"}} + {xprof_core, {git_subdir, "https://github.com/Appliscale/xprof.git", {tag, "2.0.0"}, "apps/xprof_core"}}, + {xprof_gui, {git_subdir, "https://github.com/Appliscale/xprof.git", {tag, "2.0.0"}, "apps/xprof_gui"}}, + {xprof, {git_subdir, "https://github.com/Appliscale/xprof.git", {tag, "2.0.0"}, "apps/xprof"}} ]}. ``` ## Supported Versions -XProf currently supports Erlang/OTP 18 - 29 and Elixir 1.11-1.20. +XProf currently supports Erlang/OTP 24 - 29 and Elixir 1.11-1.20. Newer OTP versions (if any) might work but are not tested. ## Syntax mode @@ -138,12 +138,6 @@ library. If you have compilation problems you can choose to use a native Erlang histogram implementation by defining the OS env var `XPROF_ERL_HIST` when compiling `xprof_core`. -`COWBOY_VERSION` - By default XProf uses Cowboy version 2.x. This -version is only supported from Erlang/OTP 19 and is not backwards -compatible with older Cowboy versions. If for some reason you would -like to use Cowboy version 1.x you can define the OS env var -`COWBOY_VERSION=1` when compiling `xprof_gui`. - `XPROF_JSON_LIB` - By default XProf uses the `jsone` library. If you would like to use a different json library you can define the OS env var `XPROF_JSON_LIB` when compiling `xprof_gui`. It is assumed that @@ -155,7 +149,6 @@ Examples ``` export XPROF_ERL_HIST=true -export COWBOY_VERSION=1 export XPROF_JSON_LIB='Elixir.Jason' export XPROF_JSON_ENC_FUN='encode!' ``` diff --git a/apps/xprof/src/xprof.app.src b/apps/xprof/src/xprof.app.src index ee0e06a0..d2d2b6aa 100644 --- a/apps/xprof/src/xprof.app.src +++ b/apps/xprof/src/xprof.app.src @@ -1,6 +1,6 @@ {application, xprof, [{description, "Visual tracer and profiler for BEAM languages"} - ,{vsn, "2.0.0-rc.5"} + ,{vsn, "2.0.0"} ,{registered, []} ,{applications, [kernel, diff --git a/apps/xprof_core/rebar.config b/apps/xprof_core/rebar.config index 5dcc2738..b20fa78b 100644 --- a/apps/xprof_core/rebar.config +++ b/apps/xprof_core/rebar.config @@ -2,6 +2,4 @@ [{hdr_histogram, "~> 0.5"} ]}. -{erl_opts, [debug_info, - {platform_define, "^[^R1]", ceil_floor} %% from OTP 20 - ]}. +{erl_opts, [debug_info]}. diff --git a/apps/xprof_core/rebar.config.script b/apps/xprof_core/rebar.config.script index e220defa..8fabcf95 100644 --- a/apps/xprof_core/rebar.config.script +++ b/apps/xprof_core/rebar.config.script @@ -30,18 +30,4 @@ ErlHist = end end. -Rebar2 = - fun(Config0) -> - case erlang:function_exported(rebar3, main, 1) of - true -> % rebar3 - Config0; - false -> % rebar 2.x or older - %% Only include app names for deps. - %% Top level app should declare source and version. - Deps = proplists:get_value(deps, Config0, []), - NewDeps = [element(1, Dep)||Dep <- Deps], - lists:keystore(deps, 1, Config0, {deps, NewDeps}) - end - end. - -Rebar2(ErlHist(CONFIG)). +ErlHist(CONFIG). diff --git a/apps/xprof_core/src/xprof_core.app.src b/apps/xprof_core/src/xprof_core.app.src index 1cceb948..103914f5 100644 --- a/apps/xprof_core/src/xprof_core.app.src +++ b/apps/xprof_core/src/xprof_core.app.src @@ -1,6 +1,6 @@ {application, xprof_core, [{description, "Visual BEAM tracer/profiler tracer core"} - ,{vsn, "2.0.0-rc.5"} + ,{vsn, "2.0.0"} ,{registered, []} ,{mod, {'xprof_core_app', []}} ,{applications, diff --git a/apps/xprof_core/src/xprof_core_erlang_syntax.erl b/apps/xprof_core/src/xprof_core_erlang_syntax.erl index 24f66f3e..63c41706 100644 --- a/apps/xprof_core/src/xprof_core_erlang_syntax.erl +++ b/apps/xprof_core/src/xprof_core_erlang_syntax.erl @@ -24,17 +24,6 @@ %% exported to fool dialyzer about breaking an opaque type -export([id/1]). -%% in OTP 21 `format_exception/7' was moved from `lib' module to `erl_error' --ifdef(OTP_RELEASE). --if(?OTP_RELEASE >= 21). -%% in OTP 21 or hifher --define(ERL_ERROR_MOD, erl_error). --endif. --else. -%% in OTP 20 or lower --define(ERL_ERROR_MOD, lib). --endif. - %% @doc Parse a query string that represents either an xprof-flavoured %% match-spec fun or an extended xprof query in Erlang syntax. %% @@ -364,8 +353,8 @@ fmt_exception(Class, Reason) -> PrettyFun = fun(Term, _Indent) -> do_fmt_term(Term) end, Encoding = unicode, unicode:characters_to_binary( - ["** "|?ERL_ERROR_MOD:format_exception(1, Class, Reason, Stacktrace, - SkipFun, PrettyFun, Encoding)]). + ["** "|erl_error:format_exception(1, Class, Reason, Stacktrace, + SkipFun, PrettyFun, Encoding)]). fmt_term(Term) -> unicode:characters_to_binary(do_fmt_term(Term)). diff --git a/apps/xprof_core/src/xprof_core_hist.erl b/apps/xprof_core/src/xprof_core_hist.erl index 279caedf..f0ba5bf3 100644 --- a/apps/xprof_core/src/xprof_core_hist.erl +++ b/apps/xprof_core/src/xprof_core_hist.erl @@ -510,27 +510,8 @@ count_at_index(It, Index) -> %% Index is zero based element(Index + ?TOTAL_COUNT_INDEX + 1, It#it.counts). -%% ceil/1 and floor/1 were introduced in OTP 20 --ifdef(ceil_floor). - int_ceil(F) -> erlang:ceil(F). int_floor(F) -> erlang:floor(F). - --else. - -int_ceil(F) -> - R = round(F), - if R < F -> R + 1; - true -> R - end. - -int_floor(F) -> - R = round(F), - if R > F -> R - 1; - true -> R - end. - --endif. diff --git a/apps/xprof_core/src/xprof_core_ms.erl b/apps/xprof_core/src/xprof_core_ms.erl index 365e1e98..aa08ccbf 100644 --- a/apps/xprof_core/src/xprof_core_ms.erl +++ b/apps/xprof_core/src/xprof_core_ms.erl @@ -36,16 +36,8 @@ default_ms() -> %% (the transform_from_shell api does not support recods as the shell %% already expanded records before it passes the fun clauses as input) ms(Clauses, RecDefs) -> - IsEmptyArgs = (get_arity(Clauses) =:= 0), - ERR_DBG_HEAD = 3, ERR_HEADMATCH = 4, case ms_transform(Clauses, RecDefs) of - {error,[{_, [{_, ms_transform, ERR_DBG_HEAD}|_]}|_], _} when IsEmptyArgs -> - %% A bug in ms_trasform that was only fixed in OTP 19.2 prevents - %% empty list as head in "dbg:fun2ms(fun([]) -> ..." - %% (see https://github.com/erlang/otp/commit/8db6c68b) - workaround_empty_args_ms( - ms(workaround_empty_args_cl(Clauses), RecDefs)); {error,[{_, [{_Loc ,ms_transform, ERR_HEADMATCH}]}], _} -> %% Before OTP 24.0 the column of a match expression was %% the column of the `=' sign. Since OTP 24.0 erl_parse @@ -92,13 +84,6 @@ build_list([Arg|Args]) -> Loc = element(2, Arg), {cons, Loc, Arg, build_list(Args)}. -workaround_empty_args_cl(Clauses) -> - [{clause, Loc, [{var, 0, '_'}], Guards, Body} - ||{clause, Loc, [], Guards, Body} <- Clauses]. - -workaround_empty_args_ms(Ms) -> - [{[], G, B} || {['_'], G, B} <- Ms]. - %% @doc The match spec fun clauses are wrapped into a form list %% which contains the record definitions from module M %% followed by the below function definition diff --git a/apps/xprof_core/src/xprof_core_vm_info.erl b/apps/xprof_core/src/xprof_core_vm_info.erl index 79c18e83..0117caae 100644 --- a/apps/xprof_core/src/xprof_core_vm_info.erl +++ b/apps/xprof_core/src/xprof_core_vm_info.erl @@ -218,65 +218,5 @@ ensure_mfa({Mod, Fun, Arity}) -> xprof_core_lib:fmt_err("Undefined module ~s", [ModeCB:fmt_mod(Mod)]) end. --ifdef(OTP_RELEASE). -%% OTP 21 or newer supports -if directive --if(?OTP_RELEASE >= 23). --define(HAS_ALL_AVAILABLE, true). --endif. --endif. - --ifdef(HAS_ALL_AVAILABLE). all_available() -> code:all_available(). - --else. - -%% copy of code:all_available from OTP 23 --spec all_available() -> [{Module, Filename, Loaded}] when - Module :: string(), - Filename :: file:filename() | atom(), - Loaded :: boolean(). -all_available() -> - case code:get_mode() of - interactive -> - all_available(code:get_path(), maps:new()); - embedded -> - all_available([], maps:new()) - end. -all_available([Path|Tail], Acc) -> - case erl_prim_loader:list_dir(Path) of - {ok, Files} -> - all_available(Tail, all_available(Path, Files, Acc)); - _Error -> - all_available(Tail, Acc) - end; -all_available([], AllModules) -> - AllLoaded = [{atom_to_list(M),Path,true} || {M,Path} <- code:all_loaded()], - AllAvailable = - maps:fold( - fun(File, Path, Acc) -> - [{filename:rootname(File), filename:append(Path, File), false} | Acc] - end, [], AllModules), - OrderFun = fun F({A,_,_},{B,_,_}) -> - F(A,B); - F(A,B) -> - A =< B - end, - lists:umerge(OrderFun, lists:sort(OrderFun, AllLoaded), lists:sort(OrderFun, AllAvailable)). - -all_available(Path, [File | T], Acc) -> - case filename:extension(File) of - ".beam" -> - case maps:is_key(File, Acc) of - false -> - all_available(Path, T, Acc#{ File => Path }); - true -> - all_available(Path, T, Acc) - end; - _Else -> - all_available(Path, T, Acc) - end; -all_available(_Path, [], Acc) -> - Acc. - --endif. diff --git a/apps/xprof_gui/priv/package-lock.json b/apps/xprof_gui/priv/package-lock.json index 964c6c8b..474b45a2 100644 --- a/apps/xprof_gui/priv/package-lock.json +++ b/apps/xprof_gui/priv/package-lock.json @@ -1,6 +1,6 @@ { "name": "xprof-gui", - "version": "2.0.0-rc.5", + "version": "2.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/apps/xprof_gui/priv/package.json b/apps/xprof_gui/priv/package.json index a397ee01..7d532370 100644 --- a/apps/xprof_gui/priv/package.json +++ b/apps/xprof_gui/priv/package.json @@ -1,6 +1,6 @@ { "name": "xprof-gui", - "version": "2.0.0-rc.5", + "version": "2.0.0", "description": "XProf - Visual tracer and profiler for BEAM languages", "repository": { "type": "git", diff --git a/apps/xprof_gui/rebar.config.script b/apps/xprof_gui/rebar.config.script index af7c8fcd..a5b519fd 100644 --- a/apps/xprof_gui/rebar.config.script +++ b/apps/xprof_gui/rebar.config.script @@ -28,14 +28,6 @@ DeleteDep = lists:keystore(deps, 1, Config0, {deps, DepsCleared}) end. -ReplaceDep = - fun(NewDep, OldDep, Config0) -> - Deps = proplists:get_value(deps, Config0, []), - DepsCleared = lists:keydelete(OldDep, 1, Deps), - NewDeps = [NewDep|DepsCleared], - lists:keystore(deps, 1, Config0, {deps, NewDeps}) - end. - JsonLib = fun(Config0) -> case os:getenv("XPROF_JSON_LIB") of @@ -49,37 +41,4 @@ JsonLib = end end. -%% The COWBOY_VERSION env var selects the cowboy dependency version: -%% * unset -> keep the default version from rebar.config -%% * "1"/"1.x" -> cowboy 1.1.2 (the last 1.x release); its API differs -%% from 2.x so the COWBOY_VERSION_1 macro is also defined -%% * any other -> used verbatim, e.g. an older 2.x that still supports -%% the OTP release being tested (cowboy 2.11+ need OTP 24+) -CowboyVsn = - fun(Config0) -> - case os:getenv("COWBOY_VERSION") of - false -> - Config0; - "1" ++ _ -> - Config1 = EnsureMacro('COWBOY_VERSION_1', true, Config0), - ReplaceDep({cowboy, "1.1.2"}, cowboy, Config1); - Vsn -> - ReplaceDep({cowboy, Vsn}, cowboy, Config0) - end - end. - -Rebar2 = - fun(Config0) -> - case erlang:function_exported(rebar3, main, 1) of - true -> % rebar3 - Config0; - false -> % rebar 2.x or older - %% Only include app names for deps. - %% Top level app should declare source and version. - Deps = proplists:get_value(deps, Config0, []), - NewDeps = [element(1, Dep)||Dep <- Deps], - lists:keystore(deps, 1, Config0, {deps, NewDeps}) - end - end. - -Rebar2(CowboyVsn(JsonLib(CONFIG))). +JsonLib(CONFIG). diff --git a/apps/xprof_gui/src/xprof_gui.app.src b/apps/xprof_gui/src/xprof_gui.app.src index 187b9166..636b3093 100644 --- a/apps/xprof_gui/src/xprof_gui.app.src +++ b/apps/xprof_gui/src/xprof_gui.app.src @@ -1,6 +1,6 @@ {application, xprof_gui, [{description, "Visual BEAM tracer/profiler GUI"} - ,{vsn, "2.0.0-rc.5"} + ,{vsn, "2.0.0"} ,{registered, []} ,{mod, {'xprof_gui_app', []}} ,{applications, diff --git a/apps/xprof_gui/src/xprof_gui_app.erl b/apps/xprof_gui/src/xprof_gui_app.erl index 9fcac0c2..5018d183 100644 --- a/apps/xprof_gui/src/xprof_gui_app.erl +++ b/apps/xprof_gui/src/xprof_gui_app.erl @@ -12,11 +12,7 @@ -define(DEF_WEB_IF_IP, any). -define(DEF_WEB_IF_PORT, 7890). -define(LISTENER, xprof_http_listener). --ifdef(COWBOY_VERSION_1). --define(HANDLER_MOD, xprof_gui_cowboy1_handler). --else. -define(HANDLER_MOD, xprof_gui_cowboy2_handler). --endif. %% Application callbacks diff --git a/apps/xprof_gui/src/xprof_gui_cowboy1_handler.erl b/apps/xprof_gui/src/xprof_gui_cowboy1_handler.erl deleted file mode 100644 index 84bede8f..00000000 --- a/apps/xprof_gui/src/xprof_gui_cowboy1_handler.erl +++ /dev/null @@ -1,54 +0,0 @@ -%%% @doc Cowboy 1.x compatible HTTP handler --module(xprof_gui_cowboy1_handler). - --ifdef(COWBOY_VERSION_1). - --behavior(cowboy_http_handler). - -%% xprof_gui_app callback --export([start_listener/4]). - -%% Cowboy 1.x callbacks --export([init/3, - handle/2, - terminate/3 - ]). - --define(HDR_JSON, [{<<"content-type">>, <<"application/json">>}, - {<<"access-control-allow-origin">>,<<$*>>}]). - -%% In case an XHR receives no content with no content-type Firefox will emit -%% the following error: "XML Parsing Error: no root element found..." -%% As a workaround always return a content-type of octet-stream with -%% 204 No Content responses --define(HDR_NO_CONTENT, [{<<"content-type">>, <<"application/octet-stream">>}, - {<<"access-control-allow-origin">>,<<$*>>}]). - -%% xprof_gui_app callback - -start_listener(Name, IP, Port, Dispatch) -> - cowboy:start_http(Name, 100, [{ip, IP}, {port, Port}], - [{env, [{dispatch, Dispatch}]}]). - -%% Cowboy 1.x callbacks - -init(_Type, Req, _Opts) -> - {ok, Req, no_state}. - -handle(Req0, State) -> - {What, _} = cowboy_req:binding(what, Req0), - {Params, _} = cowboy_req:qs_vals(Req0), - {ok, Req} = - case xprof_gui_rest:handle_req(What, Params) of - {StatusCode, Json} when is_integer(StatusCode), is_binary(Json) -> - cowboy_req:reply(StatusCode, ?HDR_JSON, Json, Req0); - StatusCode when is_integer(StatusCode) -> - cowboy_req:reply(StatusCode, ?HDR_NO_CONTENT, Req0) - end, - - {ok, Req, State}. - -terminate(_Reason, _Req, _State) -> - ok. - --endif. diff --git a/apps/xprof_gui/src/xprof_gui_cowboy2_handler.erl b/apps/xprof_gui/src/xprof_gui_cowboy2_handler.erl index c5b2329f..5f7153ab 100644 --- a/apps/xprof_gui/src/xprof_gui_cowboy2_handler.erl +++ b/apps/xprof_gui/src/xprof_gui_cowboy2_handler.erl @@ -1,8 +1,6 @@ %%% @doc Cowboy 2.x compatible HTTP handler -module(xprof_gui_cowboy2_handler). --ifndef(COWBOY_VERSION_1). - -behavior(cowboy_handler). %% xprof_gui_app callback @@ -38,5 +36,3 @@ init(Req0, State) -> cowboy_req:reply(StatusCode, ?HDR_NO_CONTENT, Req0) end, {ok, Req, State}. - --endif. diff --git a/apps/xprof_gui/test/xprof_http_e2e_SUITE.erl b/apps/xprof_gui/test/xprof_http_e2e_SUITE.erl index 504358d5..6b0592c3 100644 --- a/apps/xprof_gui/test/xprof_http_e2e_SUITE.erl +++ b/apps/xprof_gui/test/xprof_http_e2e_SUITE.erl @@ -476,20 +476,5 @@ sort_json(Json) -> Json. --ifdef(OTP_RELEASE). -%% uri_string module was introduced in OTP 21 proplist_to_query_string(PL) -> uri_string:compose_query(PL). - --else. -%% pre-OTP 21 -%% http_uri module is deprecated in OTP 23 -%% and scheduled for removal in OTP 25 -proplist_to_query_string([]) -> - ""; -proplist_to_query_string([{K, V}]) -> - K ++ "=" ++ http_uri:encode(V); -proplist_to_query_string([{K, V} | Rest]) -> - K ++ "=" ++ http_uri:encode(V) ++ "&" ++ proplist_to_query_string(Rest). - --endif. diff --git a/rebar.config b/rebar.config index 153d3586..09e1708d 100644 --- a/rebar.config +++ b/rebar.config @@ -7,12 +7,18 @@ {cover_excl_mods, [test_module]}. +%% Suppress dialyzer "unknown function" warnings for calls into the optional, +%% dynamically-loaded Elixir runtime (see xprof_core_elixir_syntax). +{dialyzer, [{warnings, [no_unknown]}]}. + {shell, [{apps, [xprof]}]}. +{project_plugins, [rebar3_ex_doc]}. + {profiles, [{test, [{deps, [ {meck, "0.8.12"} ]}, - {plugins, [ {coveralls, "1.3.0"} ]} + {plugins, [ {coveralls, "2.2.0"} ]} ]}, {test_jiffy, %% jiffy 1.1.1 rebar.config.script uses string:split added in OTP 20 @@ -27,14 +33,6 @@ {dev, [ %% {deps, [ {sync, "0.1.3"} ]} ]}, - {docs, - %% rebar3_ex_doc is only needed to generate docs (make gen_ex_doc) and - %% does not compile on older OTP, so it is scoped to this profile rather - %% than declared as a global project plugin. Move back to project_plugins when - %% OTP 23 and below dropped. - [{minimum_otp_vsn, "24.0"}, %% edoc can generate doc chunks since OTP 24 - {plugins, [rebar3_ex_doc]} - ]}, {publish, [{plugins, [ {rebar3_hex, {git, "https://github.com/gomoripeti/rebar3_hex.git", {tag, "deps-4"}}} ]} ]} diff --git a/rebar.config.script b/rebar.config.script index 63098351..e3a01889 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -1,17 +1,4 @@ -Travis = - fun(Config) -> - case os:getenv("TRAVIS") of - "true" -> - JobId = os:getenv("TRAVIS_JOB_ID"), - - [{coveralls_service_name, "travis-ci"}, - {coveralls_service_job_id, JobId} | Config]; - _ -> - Config - end - end. - GithubActions = fun(Config) -> case {os:getenv("GITHUB_ACTIONS"), os:getenv("GITHUB_TOKEN")} of @@ -37,23 +24,4 @@ GithubActions = end end. -%% Suppress dialyzer "unknown function" warnings for calls into the optional, -%% dynamically-loaded Elixir runtime (see xprof_core_elixir_syntax). The -%% `no_unknown` warning and the underlying behaviour of failing on unknown -%% functions were introduced in OTP 24; on older releases the option is -%% rejected and unknown functions don't affect the exit status anyway. -DialyzerNoUnknown = - fun(Config) -> - case list_to_integer(erlang:system_info(otp_release)) of - Rel when Rel >= 24 -> - Dialyzer = proplists:get_value(dialyzer, Config, []), - Warnings = proplists:get_value(warnings, Dialyzer, []), - Dialyzer1 = lists:keystore(warnings, 1, Dialyzer, - {warnings, [no_unknown | Warnings]}), - lists:keystore(dialyzer, 1, Config, {dialyzer, Dialyzer1}); - _ -> - Config - end - end. - -DialyzerNoUnknown(GithubActions(Travis(CONFIG))). +GithubActions(CONFIG).