diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..4def1620 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,52 @@ +name: CI + +on: + push: + pull_request: + branches: [ $default-branch ] + release: + types: + - created + +jobs: + test: + name: CI + runs-on: ubuntu-latest + strategy: + matrix: + otp: [21.3, 22.3, 23.0.4, 23.2.7.0] + container: + image: erlang:${{ matrix.otp }}-alpine + steps: + - name: Prepare + run: | + apk update + apk --no-cache upgrade + apk --no-cache add gcc git libc-dev libc-utils libgcc linux-headers make bash + - uses: actions/checkout@v2 + - name: Build + run: rebar3 compile + - name: Run tests + run: | + ./elvis rock --config elvis.config + rebar3 xref + rebar3 dialyzer + rebar3 eunit + - name: Coveralls + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_FLAG_NAME: ${{ matrix.otp }} + run: DEBUG=1 rebar3 as test coveralls send + + finish: + needs: test + runs-on: ubuntu-20.04 + if: always() + steps: + - name: Coveralls Finished + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + curl -v -k https://coveralls.io/webhook \ + --header "Content-Type: application/json" \ + --data "{\"repo_name\":\"$GITHUB_REPOSITORY\",\"repo_token\":\"$GITHUB_TOKEN\",\"payload\":{\"build_num\":$GITHUB_RUN_ID,\"status\":\"done\"}}" diff --git a/.gitignore b/.gitignore index 82681be3..cba84f51 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ erl_crash.dump logs _build /tmp +rebar3 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c9c8f1c5..00000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -sudo: false -language: erlang -install: 'true' -before_script: -- wget https://s3.amazonaws.com/rebar3/rebar3 -- wget https://github.com/rebar/rebar/wiki/rebar -- chmod +x rebar3 -- chmod +x rebar -env: PATH=$PATH:. -cache: - directories: - - $HOME/.cache/rebar3/ -otp_release: -- 21.3 -- 22.3 -script: "./bin/checks.sh && ./rebar3 as test coveralls send" diff --git a/README.md b/README.md index 886354cc..da8ebcd0 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ __Version:__ 4.8.1 [![Hex.pm](https://img.shields.io/hexpm/v/prometheus.svg?maxAge=2592000?style=plastic)](https://hex.pm/packages/prometheus) [![Hex.pm](https://img.shields.io/hexpm/dt/prometheus.svg?maxAge=2592000)](https://hex.pm/packages/prometheus) -[![Build Status](https://travis-ci.org/deadtrickster/prometheus.erl.svg?branch=version-3)](https://travis-ci.org/deadtrickster/prometheus.erl) +[![Build Status](https://img.shields.io/github/workflow/status/deadtrickster/prometheus.erl/CI?style=flat)](https://github.com/deadtrickster/prometheus.erl/actions/workflows/main.yml) [![Coverage Status](https://coveralls.io/repos/github/deadtrickster/prometheus.erl/badge.svg?branch=master)](https://coveralls.io/github/deadtrickster/prometheus.erl?branch=master) [Prometheus.io](https://prometheus.io) monitoring system and time series database client in Erlang. diff --git a/doc/README.md b/doc/README.md index 82c437b6..201b57cd 100644 --- a/doc/README.md +++ b/doc/README.md @@ -8,7 +8,7 @@ __Version:__ 4.8.1 [![Hex.pm](https://img.shields.io/hexpm/v/prometheus.svg?maxAge=2592000?style=plastic)](https://hex.pm/packages/prometheus) [![Hex.pm](https://img.shields.io/hexpm/dt/prometheus.svg?maxAge=2592000)](https://hex.pm/packages/prometheus) -[![Build Status](https://travis-ci.org/deadtrickster/prometheus.erl.svg?branch=version-3)](https://travis-ci.org/deadtrickster/prometheus.erl) +[![Build Status](https://img.shields.io/github/workflow/status/deadtrickster/prometheus.erl/CI?style=flat)](https://github.com/deadtrickster/prometheus.erl/actions/workflows/main.yml) [![Coverage Status](https://coveralls.io/repos/github/deadtrickster/prometheus.erl/badge.svg?branch=master)](https://coveralls.io/github/deadtrickster/prometheus.erl?branch=master) [Prometheus.io](https://prometheus.io) monitoring system and time series database client in Erlang. diff --git a/doc/overview.md b/doc/overview.md index 00efdbf0..77a82705 100644 --- a/doc/overview.md +++ b/doc/overview.md @@ -5,7 +5,7 @@ @doc [![Hex.pm](https://img.shields.io/hexpm/v/prometheus.svg?maxAge=2592000?style=plastic)](https://hex.pm/packages/prometheus) [![Hex.pm](https://img.shields.io/hexpm/dt/prometheus.svg?maxAge=2592000)](https://hex.pm/packages/prometheus) -[![Build Status](https://travis-ci.org/deadtrickster/prometheus.erl.svg?branch=version-3)](https://travis-ci.org/deadtrickster/prometheus.erl) +[![Build Status](https://img.shields.io/github/workflow/status/deadtrickster/prometheus.erl/CI?style=flat)](https://github.com/deadtrickster/prometheus.erl/actions/workflows/main.yml) [![Coverage Status](https://coveralls.io/repos/github/deadtrickster/prometheus.erl/badge.svg?branch=master)](https://coveralls.io/github/deadtrickster/prometheus.erl?branch=master) [Prometheus.io](https://prometheus.io) monitoring system and time series database client in Erlang. diff --git a/rebar.config b/rebar.config index 1fc840f9..1d1b63ba 100644 --- a/rebar.config +++ b/rebar.config @@ -27,7 +27,8 @@ ]}. {coveralls_coverdata, "_build/test/cover/eunit.coverdata"}. -{coveralls_service_name, "travis-ci"}. +{coveralls_service_name, "github"}. +{coveralls_parallel, true}. {xref_extra_paths, []}. {xref_ignores, [prometheus_model]}. @@ -45,7 +46,7 @@ "https://github.com/deadtrickster/prometheus.erl"}}]}]}, {test, [ {eunit_compile_opts, [{src_dirs, ["src", "test/eunit"]}]}, - {plugins, [{coveralls, "1.4.0"}]}]}, + {plugins, [{coveralls, {git, "https://github.com/RoadRunnr/coveralls-erl.git", {branch, "feature/git-info"}}}]}]}, {gpb, [{plugins, [{rebar3_gpb_plugin, "2.7.0"}]}, {provider_hooks, [{pre, [{compile, {protobuf, compile}}]}, {post, [{clean, {protobuf, clean}}]}]}, diff --git a/rebar.config.script b/rebar.config.script index e11ee515..ababb5db 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -1,14 +1,17 @@ -TravisConfig = case os:getenv("TRAVIS") of - "true" -> - JobId = os:getenv("TRAVIS_JOB_ID"), - lists:keystore(coveralls_service_job_id, 1, CONFIG, {coveralls_service_job_id, JobId}); - _ -> - CONFIG -end, - -case erlang:function_exported(rebar3, main, 1) of - true -> % rebar3 - lists:keystore(plugins, 1, TravisConfig, {plugins, [{rebar3_archive_plugin, "0.0.1"}]}); - false -> % rebar 2.x or older - lists:keystore(proto_opts, 1, TravisConfig, {proto_opts, [{src_dirs, []}]}) +%% -*- erlang -*- +case {os:getenv("GITHUB_ACTIONS"), os:getenv("GITHUB_TOKEN")} of + {"true", Token} when is_list(Token) -> + CONFIG1 = [{coveralls_repo_token, Token}, + {coveralls_service_job_id, os:getenv("GITHUB_RUN_ID")}, + {coveralls_commit_sha, os:getenv("GITHUB_SHA")}, + {coveralls_flag_name, os:getenv("COVERALLS_FLAG_NAME")} | CONFIG], + case os:getenv("GITHUB_EVENT_NAME") =:= "pull_request" + andalso string:tokens(os:getenv("GITHUB_REF"), "/") of + [_, "pull", PRNO, _] -> + [{coveralls_service_pull_request, PRNO} | CONFIG1]; + _ -> + CONFIG1 + end; + _ -> + CONFIG end.