Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 23 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ name: CI
on:
push:
branches: [ master ]
# Validate changes to the CI's own config on pull requests that touch it
pull_request:
paths:
- '.github/workflows/ci.yml'
- '.github/actions/big-tests/**'
- '.circleci/presets.config'
- 'tools/generate-presets'
Comment thread
mdbrnowski marked this conversation as resolved.
Outdated
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Expand Down Expand Up @@ -60,55 +67,30 @@ jobs:
if: ${{ failure() }}
run: tools/gh-upload-to-s3.sh _build/test/logs test_logs

big_tests:
name: ${{matrix.preset}} on OTP ${{matrix.otp}}
strategy:
fail-fast: false
matrix:
preset: [internal_mnesia, pgsql_mnesia, mysql_cets,
ldap_mnesia, elasticsearch_and_cassandra_mnesia]
otp: [ '29.0.3' ]
include:
- test-spec: "default.spec"
- preset: elasticsearch_and_cassandra_mnesia
test-spec: "mam.spec"
- preset: ldap_mnesia
test-spec: "default.spec"
otp: '28.4.2'
- preset: pgsql_mnesia
test-spec: "default.spec"
otp: '28.4.2'
# The big-test presets are defined once in .circleci/presets.config and shared with
# CircleCI; this job turns them into a GitHub Actions matrix consumed by big_tests below.
generate_matrix:
name: generate big tests matrix
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.gen.outputs.matrix }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
- uses: ./.github/actions/big-tests
- uses: erlef/setup-beam@v1.16.0
with:
otp: ${{matrix.otp}}
preset: ${{matrix.preset}}
gh-token: ${{secrets.GITHUB_TOKEN}}
test-spec: ${{matrix.test-spec}}
- name: upload common test results on failure
if: ${{ failure() }}
run: tools/gh-upload-to-s3.sh big_tests/ct_report
- name: upload big_tests results to GA4
if: ${{ !cancelled() && github.ref_name == 'master' }}
run: tools/gh-report-failing-testcases-to-ga4.sh
otp-version: '28.4.2'
- id: gen
# Arguments map the presets' latest/legacy executors to OTP versions
Comment thread
mdbrnowski marked this conversation as resolved.
Outdated
run: echo "matrix=$(tools/generate-presets .circleci/presets.config github 29.0.3 28.4.2)" >> "$GITHUB_OUTPUT"

dynamic_domains_big_tests:
name: dynamic domains ${{matrix.preset}} on OTP ${{matrix.otp}}
big_tests:
name: ${{matrix.name}}
needs: generate_matrix
strategy:
fail-fast: false
matrix:
preset: [pgsql_mnesia, mysql_cets]
otp: [ '29.0.3' ]
test-spec: ["dynamic_domains.spec"]
include:
- preset: pgsql_mnesia
otp: '28.4.2'
test-spec: "dynamic_domains.spec"
matrix: ${{ fromJSON(needs.generate_matrix.outputs.matrix) }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
Expand All @@ -129,7 +111,7 @@ jobs:
run: tools/gh-report-failing-testcases-to-ga4.sh

coveralls_webhook:
needs: [big_tests, small_tests, dynamic_domains_big_tests]
needs: [big_tests, small_tests]
runs-on: ubuntu-22.04
steps:
- name: Finish coveralls parallel build
Expand Down
2 changes: 1 addition & 1 deletion tools/circle-generate-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ CERTS_CACHE_KEY=$(cat certs_cache_key)
# Matches plugins list in the rebar.config
REBAR_PLUGINS_HASH=$(cat rebar.config | sed -n '/^{plugins/,/]}./p' | sha1sum | awk '{print $1}')

BIG_TESTS="$(./tools/circle-generate-presets .circleci/presets.config | "$SED" 's/^/ /')"
BIG_TESTS="$(./tools/generate-presets .circleci/presets.config circleci | "$SED" 's/^/ /')"
BIG_TESTS_LIST="$(awk '$1 == "name:" {print "-", $2}' <<< "$BIG_TESTS" | "$SED" 's/^/ /')"

env \
Expand Down
43 changes: 0 additions & 43 deletions tools/circle-generate-presets

This file was deleted.

78 changes: 78 additions & 0 deletions tools/generate-presets
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env escript

%% Generates the big-test job list from the presets file for both CIs, so they share a
%% single source of truth.
%%
%% generate-presets <presets.config> circleci
%% generate-presets <presets.config> github <latest-otp> <legacy-otp>

main([Path, "circleci"]) ->
print_circleci(load(Path));
main([Path, "github", LatestOtp, LegacyOtp]) ->
print_github(load(Path), #{latest => LatestOtp, legacy => LegacyOtp});
main(_Args) ->
halt(1).

load(Path) ->
{ok, Presets} = file:consult(Path),
parse_presets(Presets).

parse_presets(Presets) ->
maps:from_list([maps:take(name, maps:from_list(P)) || P <- Presets]).

resolve_include(Opts, Presets) ->
case maps:take(include, Opts) of
error -> Opts;
{Include, Opts1} -> maps:merge(maps:get(Include, Presets), Opts1)
end.

%% CircleCI: workflow job YAML fragment

print_circleci(Presets) ->
maps:foreach(
fun(Name, Opts) ->
print_circleci_preset(Name, resolve_include(Opts, Presets))
Comment thread
kamilwaz marked this conversation as resolved.
Outdated
end,
Presets
).

print_circleci_preset(Name, #{executor := Executor, preset := Preset, requires := Requires} = Opts) ->
MaybeSpec =
case maps:get(spec, Opts, undefined) of
undefined -> "";
Spec -> [io_lib:nl(), " spec: ", Spec]
end,
io:format(
"""
- big_tests_in_docker:
name: ~s
executor: ~s
preset: ~s
requires: ~p~s
context: mongooseim-org
filters: *all_tags~n
""",
[Name, Executor, Preset, Requires, MaybeSpec]
).

%% GitHub Actions: strategy matrix JSON. The presets' latest/legacy executors are
%% mapped to the OTP versions given as arguments.

print_github(Presets, Otp) ->
Objs = [github_object(Name, resolve_include(maps:get(Name, Presets), Presets), Otp)
|| Name <- lists:sort(maps:keys(Presets))],
io:format("~s", [["{\"include\":[", lists:join(",", Objs), "]}"]]).

github_object(Name, #{executor := Executor, preset := Preset} = Opts, Otp) ->
Fields = [kv("name", Name), kv("preset", Preset),
kv("otp", otp_version(Executor, Otp)),
kv("test-spec", maps:get(spec, Opts, "default.spec"))],
["{", lists:join(",", Fields), "}"].

kv(Key, Value) -> ["\"", Key, "\":\"", to_str(Value), "\""].

to_str(A) when is_atom(A) -> atom_to_list(A);
to_str(L) -> L.
Comment thread
kamilwaz marked this conversation as resolved.
Outdated

otp_version("latest_otp" ++ _, #{latest := V}) -> V;
otp_version("legacy_otp" ++ _, #{legacy := V}) -> V.
Loading