Skip to content

Commit

Permalink
Switch from Travis to Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
badlop committed Jun 19, 2021
1 parent 3107c84 commit 9908344
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 37 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI

on: [push, pull_request]

jobs:

tests:
name: Tests
strategy:
fail-fast: false
matrix:
otp: ['19.3', '22.3', 24]
runs-on: ubuntu-20.04
container:
image: erlang:${{ matrix.otp }}

steps:

- uses: actions/checkout@v2

- name: Cache rebar3
uses: actions/cache@v2
with:
path: |
~/.cache/rebar3/
key: ${{matrix.otp}}-${{hashFiles('rebar.config')}}

- run: rebar3 compile
- run: rebar3 xref
- run: rebar3 dialyzer
- run: rebar3 eunit -v

- name: Send to Coveralls
if: matrix.otp == 24
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
COVERALLS=true rebar3 as test coveralls send
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"}}'
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# p1_pgsql

[![Build Status](https://travis-ci.org/processone/p1_pgsql.svg?branch=master)](https://travis-ci.org/processone/p1_pgsql) [![Coverage Status](https://coveralls.io/repos/processone/p1_pgsql/badge.svg?branch=master&service=github)](https://coveralls.io/github/processone/p1_pgsql?branch=master) [![Hex version](https://img.shields.io/hexpm/v/p1_pgsql.svg "Hex version")](https://hex.pm/packages/p1_pgsql)
[![CI](https://github.com/processone/p1_pgsql/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/processone/p1_pgsql/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/processone/p1_pgsql/badge.svg?branch=master&service=github)](https://coveralls.io/github/processone/p1_pgsql?branch=master)
[![Hex version](https://img.shields.io/hexpm/v/p1_pgsql.svg "Hex version")](https://hex.pm/packages/p1_pgsql)

Pure Erlang PostgreSQL driver

Expand Down
2 changes: 2 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

{cover_enabled, true}.
{cover_export_enabled, true}.
{coveralls_coverdata , "_build/test/cover/eunit.coverdata"}.
{coveralls_service_name , "github"}.

{xref_checks, [undefined_function_calls, undefined_functions, deprecated_function_calls, deprecated_functions]}.

Expand Down
33 changes: 22 additions & 11 deletions rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ IsRebar3 = case application:get_key(rebar, vsn) of
lists:keymember(mix, 1, application:loaded_applications())
end,

JobId = case os:getenv("TRAVIS_JOB_ID") of false -> ""; V -> V end,

ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) ->
{OldVal,PartCfg} = case lists:keytake(Key, 1, Cfg) of
{value, {_, V1}, V2} -> {V1, V2};
Expand Down Expand Up @@ -95,25 +93,38 @@ GlobalDepsFilter = fun(Deps) ->
end, DepNames)
end,

GithubConfig = 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_service_number, os:getenv("GITHUB_RUN_NUMBER")}],
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;
_ ->
[]
end,

Rules = [
{[deps], IsRebar3,
Rebar3DepsFilter, []},
{[plugins], IsRebar3,
AppendList([rebar3_hex, pc]), []},
{[deps], os:getenv("TRAVIS") == "true",
AppendList([{coveralls, ".*", {git, "https://github.com/markusn/coveralls-erl.git", "master"}}]), []},
{[plugins], os:getenv("TRAVIS") == "true",
AppendList([coveralls]), []},
{[coveralls_coverdata], os:getenv("TRAVIS") == "true",
AppendList(["_build/test/cover/eunit.coverdata"]), []},
{[coveralls_service_name], os:getenv("TRAVIS") == "true",
AppendList(["travis-ci"]), []},
{[plugins], os:getenv("COVERALLS") == "true",
AppendList([{coveralls, {git,
"https://github.com/RoadRunnr/coveralls-erl.git",
{branch, "feature/git-info"}}} ]), []},
{[deps], os:getenv("USE_GLOBAL_DEPS") /= false,
GlobalDepsFilter, []}
],


Config = FilterConfig(FilterConfig, CONFIG, Rules),
Config = FilterConfig(FilterConfig, CONFIG, Rules) ++ GithubConfig,

%io:format("Rules:~n~p~n~nCONFIG:~n~p~n~nConfig:~n~p~n", [Rules, CONFIG, Config]),

Expand Down

0 comments on commit 9908344

Please sign in to comment.