Skip to content

Commit

Permalink
Added GH Action
Browse files Browse the repository at this point in the history
Purposes of changes:
* Provided base GitHub Actions
* Added coveralls: used fork till merge/release markusn/coveralls-erl#36
* Added 'elvis' call to GH Actions
* Updated 'README': added GH Badges
* Remove '.travis.yml'
* Update 'rebar.config.script' based on GH Actions
* Add 'rebar3' to '.gitignore'
* Fix error for GH Action when tests running - {'EXIT',nodistribution}
* Fix dialyzer warning:
-------------------------------------------
src/metrics/prometheus_quantile_summary.erl
 307: The created fun has no local return
 346: The created fun has no local return
 487: Function quantile_merge/2 has no local return
 491: Record construction #quantile_estimator{samples_count::number(),data_count::'undefined',inserts_since_compression::'undefined',data::[#group{v::number(),g::number(),delta::number(),rank::number()}],invariant::fun()} violates the declared type of field data_count::number() and inserts_since_compression::number()
-------------------------------------------
  • Loading branch information
vkatsuba committed Apr 29, 2021
1 parent 86ac506 commit 4026b79
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 36 deletions.
52 changes: 52 additions & 0 deletions .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\"}}"
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -19,3 +19,4 @@ erl_crash.dump
logs
_build
/tmp
rebar3
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -8,7 +8,7 @@ __Version:__ 4.8.0

[![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.
Expand Down
2 changes: 1 addition & 1 deletion doc/README.md
Expand Up @@ -8,7 +8,7 @@ __Version:__ 4.8.0

[![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.
Expand Down
2 changes: 1 addition & 1 deletion doc/overview.md
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions rebar.config
Expand Up @@ -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]}.
Expand All @@ -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}}]}]},
Expand Down
29 changes: 16 additions & 13 deletions 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.
4 changes: 3 additions & 1 deletion src/metrics/prometheus_quantile_summary.erl
Expand Up @@ -491,5 +491,7 @@ quantile_merge(QE1, QE2) ->
quantile_estimator:compress(#quantile_estimator{
samples_count = N1 + N2,
data = Data1 ++ Data2,
invariant = Invariant
invariant = Invariant,
data_count = 0,
inserts_since_compression = 0
}).
Expand Up @@ -42,7 +42,7 @@ test_no_distribution(_) ->

prometheus_dist_on_test_() ->
{setup,
fun() -> os:cmd("epmd -daemon"),
fun() -> os:cmd("erl -sname test"),
{ok, _} = net_kernel:start([prometheus_dist_collector, shortnames]),
ct_slave:start(prometheus_dist_collector_peer) end,
fun(_) -> ct_slave:stop(prometheus_dist_collector_peer),
Expand Down

0 comments on commit 4026b79

Please sign in to comment.