From 2b65a804d3543e7903f4de9048ac46c299e2598d Mon Sep 17 00:00:00 2001 From: Aleksey Sabilin Date: Fri, 17 Jul 2026 19:35:12 +0300 Subject: [PATCH] fix(ci): materialize rebar test src_dirs in shared test image. Refs EventHub/EventHubBack#36 --- docker/ApiTests.Dockerfile | 12 ++++++++++-- docker/ci-test-prepare.sh | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 docker/ci-test-prepare.sh diff --git a/docker/ApiTests.Dockerfile b/docker/ApiTests.Dockerfile index 9c2dfb5..261d440 100644 --- a/docker/ApiTests.Dockerfile +++ b/docker/ApiTests.Dockerfile @@ -10,9 +10,17 @@ COPY src/ src/ COPY test/unit/ test/unit/ COPY test/api_*_SUITE.erl test/ COPY test/api/ test/api/ +COPY docker/ci-test-prepare.sh /usr/local/bin/ci-test-prepare.sh +RUN chmod +x /usr/local/bin/ci-test-prepare.sh -# default profile: CT (test/api); test profile: EUnit (test/unit) -RUN rebar3 compile && rebar3 as test compile +# default profile: CT (test/api); test profile: EUnit (test/unit). +# rebar3 кладёт битые/symlink extra src_dirs; готовим реальные копии (как scripts/fix-rebar-unit-symlink.sh). +RUN rebar3 compile \ + && mkdir -p _build/test/lib/eventhub/test \ + && (rebar3 as test compile || true) \ + && ci-test-prepare.sh \ + && rebar3 as test compile # По умолчанию CT; для eunit: docker run … rebar3 eunit --sname ci_eunit --verbose +ENTRYPOINT ["ci-test-prepare.sh"] CMD ["rebar3", "ct", "--sname", "ci_api_test", "-v"] diff --git a/docker/ci-test-prepare.sh b/docker/ci-test-prepare.sh new file mode 100644 index 0000000..1d93e53 --- /dev/null +++ b/docker/ci-test-prepare.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# Replace rebar3 symlinks under _build/.../test with real copies (BusyBox cp -L fails on them). +set -eu +APP_ROOT="${APP_ROOT:-/app}" +DEST="${APP_ROOT}/_build/test/lib/eventhub/test" +mkdir -p "${DEST}" +rm -rf "${DEST}/unit" "${DEST}/api" +cp -a "${APP_ROOT}/test/unit" "${DEST}/unit" +cp -a "${APP_ROOT}/test/api" "${DEST}/api" +# shellcheck disable=SC2086 +cp -a ${APP_ROOT}/test/api_*_SUITE.erl "${DEST}/" 2>/dev/null || true + +if [ "$#" -gt 0 ]; then + exec "$@" +fi