Skip to content

Commit

Permalink
Make rabbitmq-server work with rules_erlang 3
Browse files Browse the repository at this point in the history
Also rework elixir dependency handling, so we no longer rely on mix to
fetch the rabbitmq_cli deps

Also:

- Specify ra version with a commit rather than a branch
- Fixup compilation options for erlang 23
- Add missing ra reference in MODULE.bazel
- Add missing flag in oci.yaml
- Reduce bazel rbe jobs to try to save memory
- Use bazel built erlang for erlang git master tests
- Use the same cache for all the workflows but windows
- Avoid using `mix local.hex --force` in elixir rules
  - Fetching seems blocked in CI, and this should reduce hex api usage in
    all builds, which is always nice
- Remove xref and dialyze tags since rules_erlang 3 includes them in
  the defaults
  • Loading branch information
HoloRin committed Jun 8, 2022
1 parent f0b0a4f commit 327f075
Show file tree
Hide file tree
Showing 85 changed files with 1,527 additions and 880 deletions.
36 changes: 17 additions & 19 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,32 @@ build:rbe --config=buildbuddy

build:rbe --remote_executor=grpcs://remote.buildbuddy.io

build:rbe --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1

build:rbe --@rules_erlang//:erlang_home=/usr/lib/erlang
build:rbe --//:elixir_home=/usr/local

build:rbe --spawn_strategy=remote
build:rbe --test_strategy=""
build:rbe --jobs=100
build:rbe --jobs=50

build:rbe-23 --config=rbe
build:rbe-23 --crosstool_top=@rbe_23//cc:toolchain
build:rbe-23 --extra_toolchains=@rbe_23//config:cc-toolchain
build:rbe --crosstool_top=@rbe//cc:toolchain
build:rbe --extra_toolchains=@rbe//config:cc-toolchain

build:rbe-23 --host_platform=@rbe_23//config:platform
build:rbe-23 --platforms=@rbe_23//config:platform
build:rbe-23 --extra_execution_platforms=@rbe_23//config:platform
build:rbe --host_platform=@rbe//config:platform

build:rbe-23 --@rules_erlang//:erlang_version=23
build:rbe --host_cpu=k8
build:rbe --cpu=k8

build:rbe-23 --config=rbe
build:rbe-23 --platforms=//bazel/platforms:erlang_23_platform
build:rbe-23 --extra_execution_platforms=//bazel/platforms:erlang_23_platform

build:rbe-24 --config=rbe
build:rbe-24 --crosstool_top=@rbe_24//cc:toolchain
build:rbe-24 --extra_toolchains=@rbe_24//config:cc-toolchain
build:rbe-24 --platforms=//bazel/platforms:erlang_24_platform
build:rbe-24 --extra_execution_platforms=//bazel/platforms:erlang_24_platform

build:rbe-24 --host_platform=@rbe_24//config:platform
build:rbe-24 --platforms=@rbe_24//config:platform
build:rbe-24 --extra_execution_platforms=@rbe_24//config:platform
build:rbe-25 --config=rbe
build:rbe-25 --platforms=//bazel/platforms:erlang_25_platform
build:rbe-25 --extra_execution_platforms=//bazel/platforms:erlang_25_platform

build:rbe-24 --@rules_erlang//:erlang_version=24
build:local --platforms=//bazel/platforms:erlang_external_platform
build:local --extra_execution_platforms=//bazel/platforms:erlang_external_platform

# Try importing a user specific .bazelrc
# You can create your own by copying and editing the template-user.bazelrc template:
Expand Down
59 changes: 26 additions & 33 deletions .github/workflows/oci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
workflow_dispatch:
env:
GENERIC_UNIX_ARCHIVE: ${{ github.workspace }}/bazel-bin/package-generic-unix.tar.xz
RABBITMQ_VERSION: ${{ github.sha }}
VERSION: ${{ github.sha }}
RABBITMQ_VERSION: ${{ github.event.pull_request.head.sha || github.sha }}
VERSION: ${{ github.event.pull_request.head.sha || github.sha }}
jobs:

# This job will build one docker image per supported Erlang major version.
Expand All @@ -30,43 +30,28 @@ jobs:
image_tag_suffix:
- otp-min
- otp-max
#! - otp-rc
include:
- image_tag_suffix: otp-min
skip_otp_verify: false
- image_tag_suffix: otp-max
skip_otp_verify: false
#! - image_tag_suffix: otp-rc
#! skip_otp_verify: true
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Load version info
id: load-info
run: |
# TODO: de-duplicate the info these files and MODULE.bazel
FILE=packaging/docker-image/otp-versions/${{ matrix.image_tag_suffix }}.yaml
echo "::set-output name=otp::$(yq eval '.otp' $FILE)"
echo "::set-output name=otp_major::$(yq eval '.otp_major' $FILE)"
echo "::set-output name=otp_sha256::$(yq eval '.otp_sha256' $FILE)"
echo "::set-output name=elixir::$(yq eval '.elixir' $FILE)"
- name: Set up Erlang & Elixir
uses: erlef/[email protected]
with:
otp-version: ${{ steps.load-info.outputs.otp }}
elixir-version: ${{ steps.load-info.outputs.elixir }}
version-type: strict

- name: MOUNT BAZEL CACHE
uses: actions/[email protected]
- name: Mount Bazel Cache
uses: actions/[email protected]
with:
path: "/home/runner/repo-cache/"
key: repo-cache

- name: CONFIGURE BAZEL
- name: Configure Bazel
run: |
ERLANG_HOME="$(dirname $(dirname $(which erl)))"
ELIXIR_HOME="$(dirname $(dirname $(which iex)))"
if [ -n "${{ secrets.BUILDBUDDY_API_KEY }}" ]; then
cat << EOF >> user.bazelrc
build:buildbuddy --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_API_KEY }}
Expand All @@ -75,20 +60,29 @@ jobs:
cat << EOF >> user.bazelrc
build:buildbuddy --build_metadata=ROLE=CI
build:buildbuddy --build_metadata=VISIBILITY=PRIVATE
build:buildbuddy --remote_instance_name=buildbuddy-io/buildbuddy/ci-oci
build:buildbuddy --repository_cache=/home/runner/repo-cache/
build:buildbuddy --color=yes
build:buildbuddy --disk_cache=
build --@rules_erlang//:erlang_version=${{ steps.load-info.outputs.otp }}
build --@rules_erlang//:erlang_home=${ERLANG_HOME}
build --//:elixir_home=${ELIXIR_HOME}
build:buildbuddy --remote_download_toplevel
EOF
- name: Check for otp & elixir version exact match
run: |
bazelisk build :otp_version --config=rbe-${{ steps.load-info.outputs.otp_major }}
if [ ! "$(cat bazel-bin/otp_version.txt)" == "${{ steps.load-info.outputs.otp }}" ]; then
exit 1
fi
bazelisk build :elixir_version --config=rbe-${{ steps.load-info.outputs.otp_major }}
if [ ! "$(cat bazel-bin/elixir_version.txt)" == "${{ steps.load-info.outputs.elixir }}" ]; then
exit 1
fi
- name: Build generic unix package
run: |
sed -i"_orig" -E '/APP_VERSION/ s/3\.[0-9]+\.[0-9]+/${{ github.sha }}/' rabbitmq.bzl
bazelisk build :package-generic-unix
sed -i"_orig" -E '/APP_VERSION/ s/3\.[0-9]+\.[0-9]+/${{ github.event.pull_request.head.sha || github.sha }}/' rabbitmq.bzl
bazelisk build :package-generic-unix \
--config=rbe-${{ steps.load-info.outputs.otp_major }}
- name: Resolve generic unix package path
run: |
Expand All @@ -108,7 +102,7 @@ jobs:
uses: actions/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-${{ matrix.image_tag_suffix }}-buildx-${{ github.sha }}
key: ${{ runner.os }}-${{ matrix.image_tag_suffix }}-buildx-${{ github.event.pull_request.head.sha || github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.image_tag_suffix }}-buildx-
Expand All @@ -131,12 +125,12 @@ jobs:
- name: Expand generic-unix-package
working-directory: packaging/docker-image
run: |
xzcat ${GENERIC_UNIX_ARCHIVE} | tar xvf -
xzcat ${{ steps.resolve-artifact-path.outputs.ARTIFACT_PATH }} | tar xvf -
- name: Compute image tags
id: compute-tags
run: |
echo "::set-output name=TAG_1::${{ github.sha }}-${{ matrix.image_tag_suffix }}"
echo "::set-output name=TAG_1::${{ github.event.pull_request.head.sha || github.sha }}-${{ matrix.image_tag_suffix }}"
echo "::set-output name=TAG_2::${GITHUB_REF##*/}-${{ matrix.image_tag_suffix }}"
- name: Build and push
Expand All @@ -152,8 +146,7 @@ jobs:
PGP_KEYSERVER=pgpkeys.eu
OTP_VERSION=${{ steps.load-info.outputs.otp }}
OTP_SHA256=${{ steps.load-info.outputs.otp_sha256 }}
SKIP_OTP_VERIFY=${{ matrix.skip_otp_verify }}
RABBITMQ_BUILD=rabbitmq_server-${{ github.sha }}
RABBITMQ_BUILD=rabbitmq_server-${{ github.event.pull_request.head.sha || github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/perform-bazel-execution-comparison.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
strategy:
matrix:
erlang_version:
- "24"
- "23"
include:
- erlang_version: "24"
- erlang_version: "23"
cache_name: ci-bazel-cache-analysis
timeout-minutes: 120
steps:
Expand Down Expand Up @@ -48,9 +48,9 @@ jobs:
strategy:
matrix:
erlang_version:
- "24"
- "23"
include:
- erlang_version: "24"
- erlang_version: "23"
cache_name: ci-bazel-cache-analysis
timeout-minutes: 120
steps:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/rabbitmq_peer_discovery_aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ jobs:
matrix:
include:
- image_tag_suffix: otp-max
erlang_version: "24"
rbe_default_branch: linux-erlang-24.1
erlang_version: "25"
timeout-minutes: 45
steps:
- name: CHECKOUT REPOSITORY
Expand All @@ -34,7 +33,6 @@ jobs:
build:buildbuddy --build_metadata=ROLE=CI
build:buildbuddy --build_metadata=VISIBILITY=PRIVATE
build:buildbuddy --remote_instance_name=buildbuddy-io/buildbuddy/ci-aws-${{ matrix.erlang_version }}
build:buildbuddy --repository_cache=/home/runner/repo-cache/
build:buildbuddy --color=yes
build:buildbuddy --disk_cache=
Expand Down
29 changes: 5 additions & 24 deletions .github/workflows/test-erlang-git.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,6 @@ jobs:
steps:
- name: CHECKOUT REPOSITORY
uses: actions/checkout@v3
- name: UPDATE RBE IMAGE SHA
env:
IMAGE: pivotalrabbitmq/rabbitmq-server-buildenv
TAG: linux-erlang-git-master
run: |
# buildbuddy caches the container image, so we must use a specific sha to ensure
# the latest is used
DIGEST="$(skopeo inspect --format '{{.Digest}}' docker://${IMAGE}:${TAG})"
echo "Will use ${IMAGE}@${DIGEST}"
sudo npm install --global --silent @bazel/buildozer
npx buildozer \
"dict_set exec_properties container-image:docker://${IMAGE}@${DIGEST}" \
//:erlang_git_platform
- name: MOUNT BAZEL CACHE
uses: actions/[email protected]
with:
Expand All @@ -39,28 +26,22 @@ jobs:
cat << EOF >> user.bazelrc
build:buildbuddy --build_metadata=ROLE=CI
build:buildbuddy --build_metadata=VISIBILITY=PUBLIC
build:buildbuddy --remote_instance_name=buildbuddy-io/buildbuddy/ci-erlang-git
build:buildbuddy --repository_cache=/home/runner/repo-cache/
build:buildbuddy --color=yes
build:buildbuddy --disk_cache=
build:rbe-git --config=rbe
build:rbe-git --crosstool_top=@buildbuddy_toolchain//:toolchain
build:rbe-git --extra_toolchains=@buildbuddy_toolchain//:cc_toolchain
build:rbe-git --host_platform=//:erlang_git_platform
build:rbe-git --platforms=//:erlang_git_platform
build:rbe-git --extra_execution_platforms=//:erlang_git_platform
build:rbe-git --@rules_erlang//:erlang_home=/usr/local/lib/erlang
build:rbe-git --@rules_erlang//:erlang_version=25
build:rbe --platforms=//bazel/platforms:erlang_git_master_platform
build:rbe --extra_execution_platforms=//bazel/platforms:erlang_git_master_platform
EOF
bazelisk info release
#! - name: Setup tmate session
#! uses: mxschmitt/action-tmate@v3
- name: RUN TESTS
run: |
sudo sysctl -w net.ipv4.tcp_keepalive_time=60
sudo ethtool -K eth0 tso off gso off gro off tx off rx off lro off
bazelisk test //... \
--config=rbe-git \
--config=rbe \
--test_tag_filters=-mixed-version-cluster,-exclusive,-aws \
--verbose_failures
20 changes: 11 additions & 9 deletions .github/workflows/test-mixed-versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
strategy:
fail-fast: false
matrix:
erlang_version:
- "23"
erlang_major:
- "24"
#! - "25"
timeout-minutes: 120
steps:
- name: CHECKOUT REPOSITORY
Expand All @@ -51,7 +51,6 @@ jobs:
cat << EOF >> user.bazelrc
build:buildbuddy --build_metadata=ROLE=CI
build:buildbuddy --build_metadata=VISIBILITY=PUBLIC
build:buildbuddy --remote_instance_name=buildbuddy-io/buildbuddy/ci-${{ matrix.erlang_version }}
build:buildbuddy --repository_cache=/home/runner/repo-cache/
build:buildbuddy --color=yes
build:buildbuddy --disk_cache=
Expand All @@ -63,17 +62,19 @@ jobs:
sudo sysctl -w net.ipv4.tcp_keepalive_time=60
sudo ethtool -K eth0 tso off gso off gro off tx off rx off lro off
bazelisk test //... \
--config=rbe-${{ matrix.erlang_version }} \
--config=rbe-${{ matrix.erlang_major }} \
--test_tag_filters=mixed-version-cluster,-exclusive,-aws \
--verbose_failures
test-exclusive-mixed-versions:
name: Test (Exclusive Tests with Mixed Version Cluster)
runs-on: ubuntu-latest
strategy:
matrix:
erlang_version:
- "23"
- "24"
include:
- erlang_version: "24"
elixir_version: 1.12.3
#! - erlang_version: "25"
#! elixir_version: 1.13.4
timeout-minutes: 60
steps:
- name: CHECKOUT REPOSITORY
Expand All @@ -82,7 +83,7 @@ jobs:
uses: erlef/[email protected]
with:
otp-version: ${{ matrix.erlang_version }}
elixir-version: 1.12.3
elixir-version: ${{ matrix.elixir_version }}
- name: MOUNT BAZEL CACHE
uses: actions/[email protected]
with:
Expand All @@ -100,14 +101,15 @@ jobs:
cat << EOF >> user.bazelrc
build:buildbuddy --build_metadata=ROLE=CI
build:buildbuddy --build_metadata=VISIBILITY=PRIVATE
build:buildbuddy --remote_instance_name=buildbuddy-io/buildbuddy/ci-exclusive-${{ matrix.erlang_version }}
build:buildbuddy --repository_cache=/home/runner/repo-cache/
build:buildbuddy --color=yes
build:buildbuddy --disk_cache=
build --@rules_erlang//:erlang_version=${{ matrix.erlang_version }}
build --@rules_erlang//:erlang_home=${ERLANG_HOME}
build --//:elixir_home=${ELIXIR_HOME}
build --platforms=//bazel/platforms:erlang_external_platform
build --extra_execution_platforms=//bazel/platforms:erlang_external_platform
EOF
#! - name: Setup tmate session
#! uses: mxschmitt/action-tmate@v3
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/test-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ jobs:
strategy:
fail-fast: false
matrix:
erlang_version:
#! - "23"
- "24"
include:
- erlang_version: "24"
elixir_version: 1.12.3
- erlang_version: "25"
elixir_version: 1.13.4
timeout-minutes: 120
steps:
- name: CHECKOUT REPOSITORY
Expand All @@ -21,7 +23,7 @@ jobs:
uses: erlef/[email protected]
with:
otp-version: ${{ matrix.erlang_version }}
elixir-version: 1.12.3
elixir-version: ${{ matrix.elixir_version }}
#! - name: MOUNT BAZEL CACHE
#! uses: actions/cache@v1
#! with:
Expand All @@ -42,14 +44,16 @@ jobs:
build:buildbuddy --build_metadata=ROLE=CI
build:buildbuddy --build_metadata=VISIBILITY=PUBLIC
build:buildbuddy --remote_instance_name=buildbuddy-io/buildbuddy/ci-windows-${{ matrix.erlang_version }}
build:buildbuddy --remote_instance_name=buildbuddy-io/buildbuddy/ci-windows
# build:buildbuddy --repository_cache=/home/runner/repo-cache/
build:buildbuddy --color=yes
build:buildbuddy --disk_cache=
build --@rules_erlang//:erlang_version=${{ matrix.erlang_version }}
build --@rules_erlang//:erlang_home="${ERL_PATH/\/bin\/erl/}"
build --//:elixir_home="${IEX_PATH/\/bin\/iex/}"
build --platforms=//bazel/platforms:erlang_external_platform
build --extra_execution_platforms=//bazel/platforms:erlang_external_platform
EOF
bazelisk info release
Expand Down
Loading

0 comments on commit 327f075

Please sign in to comment.