Skip to content

Commit

Permalink
Merge pull request #2990 from esl/gh-actions
Browse files Browse the repository at this point in the history
Gh actions
  • Loading branch information
arcusfelis committed Dec 29, 2020
2 parents 24f4236 + 644eb68 commit c2e3edd
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 3 deletions.
119 changes: 119 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: CI

on:
push:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
# required for run_common_test.erl
KEEP_COVER_RUNNING: '1'
SKIP_AUTO_COMPILE: 'true'

jobs:
small_tests:
name: small_tests on OTP ${{matrix.otp}}
strategy:
matrix:
otp: ['23.0.3', '22.3']
runs-on: ubuntu-20.04
env:
PRESET: 'small_tests'
steps:
- uses: actions/checkout@v2
- uses: ErlGang/[email protected]
with:
otp-version: ${{ matrix.otp }}
- uses: actions/cache@v2
with:
path: ~/.cache/rebar3
key: rebar3-${{ hashFiles('rebar.lock') }}
- name: create certificates
run: make certs
- name: run test
run: |
./rebar3 compile #required for coverage reporting
tools/travis-test.sh -p $PRESET -s true -e true
- name: report coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cp _build/test/cover/*.coverdata /tmp
./rebar3 coveralls send
big_tests:
name: ${{matrix.preset}} on OTP ${{matrix.otp}}
strategy:
matrix:
preset: [internal_mnesia, pgsql_mnesia, mysql_redis, odbc_mssql_mnesia,
ldap_mnesia, riak_mnesia, elasticsearch_and_cassandra_mnesia]
otp: ['23.0.3']
runs-on: ubuntu-20.04
env:
PRESET: ${{matrix.preset}}
steps:
- uses: actions/checkout@v2
- uses: ErlGang/[email protected]
with:
otp-version: ${{matrix.otp}}
- uses: actions/cache@v2
with:
path: ~/.cache/rebar3
key: rebar3-${{ hashFiles('rebar.lock') }}
- name: create certificates
run: make certs
- name: set required env variables for preset
run: tools/gh-actions-configure-preset.sh "$PRESET"
- if: ${{ matrix.preset == 'odbc_mssql_mnesia' }}
run: sudo apt-get install -y tdsodbc
- name: build releases
run: |
./rebar3 compile #required for coverage reporting
tools/build-releases.sh
- name: build big tests
run: tools/travis-build-tests.sh
- name: start backends
run: tools/travis-setup-db.sh
- name: run test
run: tools/travis-test.sh -p $PRESET -s false -e false
- name: report coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./rebar3 coveralls send

coveralls_webhook:
needs: [big_tests, small_tests]
runs-on: ubuntu-20.04
steps:
- name: Finish coveralls parallel build
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true

dialyzer:
name: dialyzer on OTP ${{matrix.otp}}
strategy:
matrix:
otp: [ '23.0.3']
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: ErlGang/[email protected]
with:
otp-version: ${{matrix.otp}}
- run: tools/travis-test.sh -p dialyzer_only

pkg:
name: ${{matrix.pkg}} package
strategy:
matrix:
pkg: [centos_7, debian_stretch]
runs-on: ubuntu-20.04
env:
ESL_ERLANG_PKG_VER: "22.3.4.9-1"
pkg_PLATFORM: ${{matrix.pkg}}
steps:
- uses: actions/checkout@v2
- run: tools/travis-test.sh -p pkg
4 changes: 4 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
{pc, "1.11.0"},
{provider_asn1, "0.2.3"},
{rebar3_codecov, {git, "https://github.com/esl/rebar3_codecov.git", {ref, "6bd31cc"}}},
{coveralls, "2.2.0"},
{rebar3_lint, "0.1.11"}
]}.

Expand Down Expand Up @@ -184,6 +185,9 @@
{cover_enabled, true}.
{cover_print_enabled, true}.
{cover_export_enabled, true}.
{coveralls_coverdata, "/tmp/*.coverdata"}.
{coveralls_service_name, "github"}.
{coveralls_parallel, true}.

{codecov_opts,
[
Expand Down
21 changes: 20 additions & 1 deletion rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,24 @@ MaybeFIPSSupport = fun(Config) ->
end
end,

Config1 = SetupIncludedApps(CONFIG, EnvApps),
MaybeConfigureCoveralls = fun(CONFIG) ->
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")} | 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
end,

Config0 = MaybeConfigureCoveralls(CONFIG),
Config1 = SetupIncludedApps(Config0, EnvApps),
MaybeFIPSSupport(Config1).
26 changes: 26 additions & 0 deletions tools/gh-actions-configure-preset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
## GITHUB_ENV=/dev/tty ./gh-actions-configure-preset.sh internal-mnesia

DB_ARRAY=( $(./tools/test_runner/presets_to_dbs.sh "$1" ) )
[ "${#DB_ARRAY[@]}" -gt 0 ] && export DB="${DB_ARRAY[@]}"

case "$1" in
internal_mnesia)
export REL_CONFIG="with-all" TLS_DIST=true ;;
odbc_mssql_mnesia)
export REL_CONFIG="with-odbc" ;;
mysql_redis)
export REL_CONFIG="with-mysql with-redis with-amqp_client" ;;
pgsql_mnesia)
export REL_CONFIG="with-pgsql" ;;
riak_mnesia)
export REL_CONFIG="with-riak" ;;
ldap_mnesia)
export REL_CONFIG="with-none" ;;
elasticsearch_and_cassandra_mnesia)
export REL_CONFIG="with-elasticsearch with-cassandra" TESTSPEC=mam.spec
esac

if [ ! -z "$GITHUB_ENV" ]; then
env | egrep "^(DB|REL_CONFIG|TLS_DIST)=" >> $GITHUB_ENV
fi
5 changes: 3 additions & 2 deletions tools/test_runner/presets_to_dbs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ main(Opts) ->
-spec presets_to_dbs(atom()) -> [atom()].
presets_to_dbs(PresetNames) ->
{ok, Config} = file:consult("big_tests/test.config"),
Presets = proplists:get_value(ejabberd_presets, Config, []),
Presets2 = lists:filter(fun({Name,_}) -> lists:member(Name, PresetNames) end, Presets),
Presets = proplists:get_value(presets, Config, []),
Toml = proplists:get_value(toml, Presets, []),
Presets2 = lists:filter(fun({Name,_}) -> lists:member(Name, PresetNames) end, Toml),
Dbs = lists:flatmap(fun({_,Opts}) -> proplists:get_value(dbs, Opts, []) end, Presets2),
lists:usort(Dbs).

Expand Down

0 comments on commit c2e3edd

Please sign in to comment.