diff options
Diffstat (limited to 'ci')
-rw-r--r-- | ci/dockerfiles/22.3/erlang_elixir | 18 | ||||
-rw-r--r-- | ci/dockerfiles/23.1/erlang_elixir | 18 | ||||
-rw-r--r-- | ci/dockerfiles/ci | 42 | ||||
-rw-r--r-- | ci/dockerfiles/ci-base | 20 | ||||
-rw-r--r-- | ci/dockerfiles/ci-dep | 19 | ||||
-rwxr-xr-x | ci/scripts/collect.sh | 7 | ||||
-rwxr-xr-x | ci/scripts/ct-suite.sh | 28 | ||||
-rwxr-xr-x | ci/scripts/dialyze.sh | 8 | ||||
-rwxr-xr-x | ci/scripts/fetch_secondary_umbrellas.sh | 45 | ||||
-rwxr-xr-x | ci/scripts/finish.sh | 5 | ||||
-rwxr-xr-x | ci/scripts/package_generic_unix.sh | 14 | ||||
-rwxr-xr-x | ci/scripts/rabbitmq_cli.sh | 49 | ||||
-rwxr-xr-x | ci/scripts/tests.sh | 26 | ||||
-rwxr-xr-x | ci/scripts/validate-workflow.sh | 26 | ||||
-rwxr-xr-x | ci/scripts/xref.sh | 8 |
15 files changed, 333 insertions, 0 deletions
diff --git a/ci/dockerfiles/22.3/erlang_elixir b/ci/dockerfiles/22.3/erlang_elixir new file mode 100644 index 0000000000..524d9af685 --- /dev/null +++ b/ci/dockerfiles/22.3/erlang_elixir @@ -0,0 +1,18 @@ +FROM erlang:22.3 + +ENV ERLANG_VERSION 22.3 + +# elixir expects utf8. +ENV ELIXIR_VERSION="v1.10.4" \ + LANG=C.UTF-8 + +RUN set -xe \ + && ELIXIR_DOWNLOAD_URL="https://github.com/elixir-lang/elixir/archive/${ELIXIR_VERSION}.tar.gz" \ + && ELIXIR_DOWNLOAD_SHA256="8518c78f43fe36315dbe0d623823c2c1b7a025c114f3f4adbb48e04ef63f1d9f" \ + && curl -fSL -o elixir-src.tar.gz $ELIXIR_DOWNLOAD_URL \ + && echo "$ELIXIR_DOWNLOAD_SHA256 elixir-src.tar.gz" | sha256sum -c - \ + && mkdir -p /usr/local/src/elixir \ + && tar -xzC /usr/local/src/elixir --strip-components=1 -f elixir-src.tar.gz \ + && rm elixir-src.tar.gz \ + && cd /usr/local/src/elixir \ + && make install clean diff --git a/ci/dockerfiles/23.1/erlang_elixir b/ci/dockerfiles/23.1/erlang_elixir new file mode 100644 index 0000000000..8fbefe953b --- /dev/null +++ b/ci/dockerfiles/23.1/erlang_elixir @@ -0,0 +1,18 @@ +FROM erlang:23.1 + +ENV ERLANG_VERSION 23.1 + +# elixir expects utf8. +ENV ELIXIR_VERSION="v1.10.4" \ + LANG=C.UTF-8 + +RUN set -xe \ + && ELIXIR_DOWNLOAD_URL="https://github.com/elixir-lang/elixir/archive/${ELIXIR_VERSION}.tar.gz" \ + && ELIXIR_DOWNLOAD_SHA256="8518c78f43fe36315dbe0d623823c2c1b7a025c114f3f4adbb48e04ef63f1d9f" \ + && curl -fSL -o elixir-src.tar.gz $ELIXIR_DOWNLOAD_URL \ + && echo "$ELIXIR_DOWNLOAD_SHA256 elixir-src.tar.gz" | sha256sum -c - \ + && mkdir -p /usr/local/src/elixir \ + && tar -xzC /usr/local/src/elixir --strip-components=1 -f elixir-src.tar.gz \ + && rm elixir-src.tar.gz \ + && cd /usr/local/src/elixir \ + && make install clean diff --git a/ci/dockerfiles/ci b/ci/dockerfiles/ci new file mode 100644 index 0000000000..fda59d27d8 --- /dev/null +++ b/ci/dockerfiles/ci @@ -0,0 +1,42 @@ +ARG ERLANG_VERSION + +FROM eu.gcr.io/cf-rabbitmq-core/ci-base:${ERLANG_VERSION} + +ARG GITHUB_RUN_ID +ARG BUILDEVENT_APIKEY + +ARG GITHUB_SHA + +ARG base_rmq_ref +ARG current_rmq_ref + +ARG RABBITMQ_VERSION + +ENV GITHUB_RUN_ID $GITHUB_RUN_ID +ENV GITHUB_SHA $GITHUB_SHA + +ENV base_rmq_ref $base_rmq_ref +ENV current_rmq_ref $current_rmq_ref + +ENV RABBITMQ_VERSION $RABBITMQ_VERSION + +ENV BUILDEVENT_CIPROVIDER GitHubActions + +WORKDIR /workspace/rabbitmq + +COPY . . + +ENV UNPRIVILEGED_USER=rabbitmq +RUN useradd \ + --create-home \ + --comment 'CI unprivileged user' \ + ${UNPRIVILEGED_USER} + +RUN chown --recursive ${UNPRIVILEGED_USER} /workspace + +USER ${UNPRIVILEGED_USER} + +RUN BUILDEVENT_APIKEY=${BUILDEVENT_APIKEY} \ + buildevents cmd ${GITHUB_RUN_ID} ${GITHUB_RUN_ID}-prepare deps -- \ + make deps test-deps \ + RABBITMQ_VERSION=${RABBITMQ_VERSION} diff --git a/ci/dockerfiles/ci-base b/ci/dockerfiles/ci-base new file mode 100644 index 0000000000..0eb4624030 --- /dev/null +++ b/ci/dockerfiles/ci-base @@ -0,0 +1,20 @@ +ARG ERLANG_VERSION + +FROM eu.gcr.io/cf-rabbitmq-core/erlang_elixir:${ERLANG_VERSION} + +RUN apt-get update && apt-get install -y rsync zip + +RUN curl -L -o buildevents https://github.com/honeycombio/buildevents/releases/latest/download/buildevents-linux-amd64 +RUN chmod 755 buildevents +RUN mv buildevents /usr/bin/ + +WORKDIR /workspace + +COPY ci/scripts/fetch_secondary_umbrellas.sh . + +# If we clone the monorepo at a ref when the monorepo was still rabbitmq-server, +# then we just get rabbitmq-server (not the monorepo as it would have looked, had +# it existed at that time). So for the time being, secondary umbrellas will derive +# from rabbitmq-public-umbrella (as they always have) +ARG SECONDARY_UMBRELLA_GITREFS +RUN bash fetch_secondary_umbrellas.sh ${SECONDARY_UMBRELLA_GITREFS}
\ No newline at end of file diff --git a/ci/dockerfiles/ci-dep b/ci/dockerfiles/ci-dep new file mode 100644 index 0000000000..602f7e3cdd --- /dev/null +++ b/ci/dockerfiles/ci-dep @@ -0,0 +1,19 @@ +ARG IMAGE_TAG + +FROM eu.gcr.io/cf-rabbitmq-core/ci:${IMAGE_TAG} + +ARG BUILDEVENT_APIKEY +ARG project + +WORKDIR /workspace/rabbitmq/deps/${project} + +RUN BUILDEVENT_APIKEY=${BUILDEVENT_APIKEY} \ + buildevents cmd ${GITHUB_RUN_ID} ${GITHUB_RUN_ID}-${project} test-build -- \ + make test-build + +RUN BUILDEVENT_APIKEY=${BUILDEVENT_APIKEY} \ + buildevents cmd ${GITHUB_RUN_ID} ${GITHUB_RUN_ID}-${project} tests -- \ + make eunit \ + FULL= \ + FAIL_FAST=1 \ + SKIP_AS_ERROR=1 diff --git a/ci/scripts/collect.sh b/ci/scripts/collect.sh new file mode 100755 index 0000000000..8ebbe0e8b4 --- /dev/null +++ b/ci/scripts/collect.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -euo pipefail + +echo "Recording buildevents step finish for ${project} started at ${STEP_START}..." +buildevents step ${GITHUB_RUN_ID} ${GITHUB_RUN_ID}-${project} ${STEP_START} ${project} +echo "done." diff --git a/ci/scripts/ct-suite.sh b/ci/scripts/ct-suite.sh new file mode 100755 index 0000000000..a8e47c995c --- /dev/null +++ b/ci/scripts/ct-suite.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -euo pipefail + +cd /workspace/rabbitmq/deps/$project + +! test -d ebin || touch ebin/* + +trap 'catch $?' EXIT + +catch() { + if [ "$1" != "0" ]; then + make ct-logs-archive && mv *-ct-logs-*.tar.xz /workspace/ct-logs/ + fi +} + +CMD=ct-${CT_SUITE} +SECONDARY_UMBRELLA_ARGS="" +if [[ "${SECONDARY_UMBRELLA_VERSION:-}" != "" ]]; then + CMD=ct-${CT_SUITE}-mixed-${SECONDARY_UMBRELLA_VERSION} + SECONDARY_UMBRELLA_ARGS="SECONDARY_UMBRELLA=/workspace/rabbitmq-${SECONDARY_UMBRELLA_VERSION} RABBITMQ_FEATURE_FLAGS=" +fi + +buildevents cmd ${GITHUB_RUN_ID} ${GITHUB_RUN_ID}-${project} ${CMD} -- \ + make ct-${CT_SUITE} \ + FULL= \ + FAIL_FAST=1 \ + SKIP_AS_ERROR=1 ${SECONDARY_UMBRELLA_ARGS} diff --git a/ci/scripts/dialyze.sh b/ci/scripts/dialyze.sh new file mode 100755 index 0000000000..fbb8e6dc54 --- /dev/null +++ b/ci/scripts/dialyze.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -euo pipefail + +cd /workspace/rabbitmq/deps/$project + +buildevents cmd ${GITHUB_RUN_ID} ${GITHUB_RUN_ID}-dialyze ${project} -- \ + make dialyze diff --git a/ci/scripts/fetch_secondary_umbrellas.sh b/ci/scripts/fetch_secondary_umbrellas.sh new file mode 100755 index 0000000000..466ef4a765 --- /dev/null +++ b/ci/scripts/fetch_secondary_umbrellas.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +set -euo pipefail + +refs="$@" + +for version in ${refs}; do + umbrella="umbrellas/$version" + if ! test -d "$umbrella" || + ! make -C "$umbrella/deps/rabbit" test-dist; then + rm -rf "$umbrella" + + # Fetch the master Umbrella; the final umbrellas are created from + # the master copy. + if ! test -d umbrellas/master; then + git config --global advice.detachedHead false + git clone \ + https://github.com/rabbitmq/rabbitmq-public-umbrella.git \ + umbrellas/master + make -C umbrellas/master co # To get RabbitMQ components. + fi + + # We copy the master Umbrella and checkout the appropriate tag. + cp -a umbrellas/master "$umbrella" + git -C "$umbrella" checkout "master" + make -C "$umbrella" up BRANCH="$version" + # To remove third-party deps which were checked out when the + # projects were on the `master` branch. Thus, possibly not the + # version pinning we expect. We update the Umbrella one last time + # to fetch the correct third-party deps. + make -C "$umbrella" clean-3rd-party-repos + make -C "$umbrella" up + make -C "$umbrella/deps/rabbit" test-dist + rm -rf "$umbrella"/deps/rabbitmq_website + rm -rf "$umbrella"/deps/rabbitmq_prometheus/docker + rm -rf "$umbrella"/deps/*/{.git,test} "$umbrella"/.git + fi +done + +for version in ${refs}; do + umbrella="umbrellas/$version" + mv ${umbrella} rabbitmq-${version} +done + +rm -fr umbrellas diff --git a/ci/scripts/finish.sh b/ci/scripts/finish.sh new file mode 100755 index 0000000000..c6047e1681 --- /dev/null +++ b/ci/scripts/finish.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -euo pipefail + +buildevents build ${GITHUB_RUN_ID} ${BUILD_START} ${BUILD_RESULT} diff --git a/ci/scripts/package_generic_unix.sh b/ci/scripts/package_generic_unix.sh new file mode 100755 index 0000000000..820821ab30 --- /dev/null +++ b/ci/scripts/package_generic_unix.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -euo pipefail + +cd /workspace/rabbitmq + +trap 'catch $?' EXIT + +catch() { + buildevents step ${GITHUB_RUN_ID} ${GITHUB_RUN_ID}-packaging ${STEP_START} packaging +} + +buildevents cmd ${GITHUB_RUN_ID} ${GITHUB_RUN_ID}-packaging package-generic-unix -- \ + make package-generic-unix diff --git a/ci/scripts/rabbitmq_cli.sh b/ci/scripts/rabbitmq_cli.sh new file mode 100755 index 0000000000..d21608df22 --- /dev/null +++ b/ci/scripts/rabbitmq_cli.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +set -euo pipefail + +cd /workspace/rabbitmq/deps/$project + +trap 'catch $?' EXIT + +SPAN_ID=${GITHUB_RUN_ID}-${project} + +catch() { + buildevents cmd ${GITHUB_RUN_ID} ${SPAN_ID} stop-node -- \ + make stop-node -C ../.. \ + DEPS_DIR=/workspace/rabbitmq/deps \ + PLUGINS='rabbitmq_federation rabbitmq_stomp' + + if [ "$1" != "0" ]; then + tar -c -f - /tmp/rabbitmq-test-instances/*/log | \ + xz > /workspace/broker-logs/broker-logs.tar.xz + fi + + buildevents step ${GITHUB_RUN_ID} ${SPAN_ID} ${STEP_START} ${project} +} + +buildevents cmd ${GITHUB_RUN_ID} ${SPAN_ID} make -- \ + make DEPS_DIR=/workspace/rabbitmq/deps + +buildevents cmd ${GITHUB_RUN_ID} ${SPAN_ID} start-background-broker -- \ + make start-background-broker \ + -C ../.. \ + DEPS_DIR=/workspace/rabbitmq/deps \ + PLUGINS='rabbitmq_federation rabbitmq_stomp' + +buildevents cmd ${GITHUB_RUN_ID} ${SPAN_ID} rebar -- \ + mix local.rebar --force + +# due to https://github.com/elixir-lang/elixir/issues/7699 we +# "run" the tests, but skip them all, in order to trigger +# compilation of all *_test.exs files before we actually run themq +buildevents cmd ${GITHUB_RUN_ID} ${SPAN_ID} compile-tests -- \ + make tests \ + MIX_TEST_OPTS="--exclude test" \ + DEPS_DIR=/workspace/rabbitmq/deps + +# rabbitmq-diagnostics erlang-cookie-sources reads USER from then env +export USER=$(whoami) +buildevents cmd ${GITHUB_RUN_ID} ${SPAN_ID} tests -- \ + make tests \ + DEPS_DIR=/workspace/rabbitmq/deps diff --git a/ci/scripts/tests.sh b/ci/scripts/tests.sh new file mode 100755 index 0000000000..abf4bc865d --- /dev/null +++ b/ci/scripts/tests.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -euo pipefail + +cd /workspace/rabbitmq/deps/$project + +trap 'catch $?' EXIT + +SPAN_ID=${GITHUB_RUN_ID}-${project} + +catch() { + if [ "$1" != "0" ]; then + make ct-logs-archive && mv *-ct-logs-*.tar.xz /workspace/ct-logs/ + fi + + buildevents step ${GITHUB_RUN_ID} ${SPAN_ID} ${STEP_START} ${project} +} + +buildevents cmd ${GITHUB_RUN_ID} ${SPAN_ID} test-build -- \ + make test-build + +buildevents cmd ${GITHUB_RUN_ID} ${SPAN_ID} tests -- \ + make tests \ + FULL= \ + FAIL_FAST=1 \ + SKIP_AS_ERROR=1 diff --git a/ci/scripts/validate-workflow.sh b/ci/scripts/validate-workflow.sh new file mode 100755 index 0000000000..3614953ee3 --- /dev/null +++ b/ci/scripts/validate-workflow.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -euo pipefail + +cd deps/${project} + +trap 'catch $?' EXIT + +catch() { + rm expected_suites.txt actual_suites.txt +} + +touch expected_suites.txt +for arg in "$@"; do + echo "test/${arg}_SUITE.erl" >> expected_suites.txt +done +sort -o expected_suites.txt expected_suites.txt + +touch actual_suites.txt +for f in test/*_SUITE.erl; do + echo "$f" >> actual_suites.txt +done +sort -o actual_suites.txt actual_suites.txt + +set -x +diff actual_suites.txt expected_suites.txt diff --git a/ci/scripts/xref.sh b/ci/scripts/xref.sh new file mode 100755 index 0000000000..5e37ca833d --- /dev/null +++ b/ci/scripts/xref.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -euo pipefail + +cd /workspace/rabbitmq/deps/$project + +buildevents cmd ${GITHUB_RUN_ID} ${GITHUB_RUN_ID}-xref ${project} -- \ + make xref |