Skip to content

Commit

Permalink
Merge pull request #1 from DenysGonchar/gh-actions
Browse files Browse the repository at this point in the history
gh actions
  • Loading branch information
DenysGonchar committed Dec 31, 2020
2 parents 0b736f6 + 4048808 commit bd83855
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 5 deletions.
125 changes: 125 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,125 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
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/setup-erlang@v1.0.0
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: tools/travis-test.sh -p $PRESET -s true -e true
- name: prepare coverage report
run: ./rebar3 codecov analyze --lcov --json false
- name: report coverage
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: small_tests on OTP ${{matrix.otp}}
path-to-lcov: ./lcov.info
parallel: true

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/setup-erlang@v1.0.0
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: 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: prepare coverage report
run: ./rebar3 codecov analyze --lcov --json false
- name: report coverage
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: ${{matrix.preset}} on OTP ${{matrix.otp}}
path-to-lcov: ./lcov.info
parallel: true

coveralls_webhook:
needs: [big_tests, small_tests]
runs-on: ubuntu-20.04
steps:
- name: Finish coveralls parallel build
uses: coverallsapp/github-action@v1.1.2
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/setup-erlang@v1.0.0
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
5 changes: 4 additions & 1 deletion rebar.config
Expand Up @@ -153,7 +153,7 @@
[
{pc, "1.11.0"},
{provider_asn1, "0.2.3"},
{rebar3_codecov, {git, "https://github.com/esl/rebar3_codecov.git", {ref, "6bd31cc"}}},
{rebar3_codecov, {git, "https://github.com/esl/rebar3_codecov.git", {branch, "lcov"}}},
{rebar3_lint, "0.1.11"}
]}.

Expand Down Expand Up @@ -184,6 +184,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
4 changes: 2 additions & 2 deletions rebar.config.script
Expand Up @@ -84,5 +84,5 @@ MaybeFIPSSupport = fun(Config) ->
end
end,

Config1 = SetupIncludedApps(CONFIG, EnvApps),
MaybeFIPSSupport(Config1).
Config0 = SetupIncludedApps(CONFIG, EnvApps),
MaybeFIPSSupport(Config0).
26 changes: 26 additions & 0 deletions tools/gh-actions-configure-preset.sh
@@ -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
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 bd83855

Please sign in to comment.