summaryrefslogtreecommitdiff
path: root/.github/workflows/test-mixed-versions.yaml
blob: 7fcc505d2be062002ad21724d12be3c3177b44dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name: Test Mixed Version Clusters
on:
  push:
    branches:
      - main
      - v3.11.x
      - v3.10.x
      - v3.9.x
      - v3.8.x
      - bump-otp-*
      - bump-elixir-*
      - bump-rbe-*
      - bump-rules_erlang
    paths:
      - 'deps/**'
      - 'scripts/**'
      - Makefile
      - plugins.mk
      - rabbitmq-components.mk
      - .bazelrc
      - .bazelversion
      - BUILD.*
      - '*.bzl'
      - '*.bazel'
      - .github/workflows/test-mixed-versions.yaml
  pull_request:
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true
jobs:
  ensure-mixed-version-archive:
    name: Prepare Artifacts
    runs-on: ubuntu-20.04
    env:
      # otp-min
      otp_version_id: 25_0
    steps:
    - name: CHECKOUT REPOSITORY
      uses: actions/checkout@v3
      with:
        path: primary-umbrella
    #! - name: Setup tmate session
    #!   uses: mxschmitt/action-tmate@v3
    - name: CHECK FOR ARCHIVE ON S3
      id: check
      working-directory: primary-umbrella
      run: |
        set -u

        ARCHIVE_URL="$(grep -Eo 'https://rabbitmq-github-actions.s3.eu-west-1.amazonaws.com.*.tar.xz' bazel/bzlmod/secondary_umbrella.bzl)"
        echo "ARCHIVE_URL: ${ARCHIVE_URL}"

        curl -LO "${ARCHIVE_URL}"

        if xzcat --test package-generic-unix-for-mixed-version-testing-v*.tar.xz; then
          exists=true
        else
          exists=false
        fi
        echo "exists=${exists}" | tee $GITHUB_ENV

        VERSION=${ARCHIVE_URL#*package-generic-unix-for-mixed-version-testing-v}
        VERSION=${VERSION%*.tar.xz}
        echo "version=${VERSION}" | tee $GITHUB_OUTPUT
    - name: CHECKOUT REPOSITORY (MIXED VERSION)
      if: env.exists != 'true'
      uses: actions/checkout@v3
      with:
        ref: v${{ steps.check.outputs.version }}
        path: secondary-umbrella
    - name: MOUNT BAZEL CACHE
      if: env.exists != 'true'
      uses: actions/cache@v3.3.1
      with:
        path: "/home/runner/repo-cache/"
        key: repo-cache-secondary-umbrella
    - name: BUILD SECONDARY UMBRELLA ARCHIVE
      if: env.exists != 'true'
      working-directory: secondary-umbrella
      run: |
        if [ -n "${{ secrets.BUILDBUDDY_API_KEY }}" ]; then
        cat << EOF >> user.bazelrc
          build:buildbuddy --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_API_KEY }}
        EOF
        fi
        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-secondary-umbrella
          build:buildbuddy --repository_cache=/home/runner/repo-cache/
          build:buildbuddy --color=yes
          build:buildbuddy --disk_cache=

          build:buildbuddy --remote_download_toplevel
        EOF

        sed -i"_orig" -E "/APP_VERSION/ s/3\.[0-9]+\.[0-9]+/${{ steps.check.outputs.version }}/" rabbitmq.bzl
        bazelisk build :package-generic-unix \
          --config=rbe-${{ env.otp_version_id }} \
          --test_build \
          --verbose_failures

        OUTPUT_DIR=${{ github.workspace }}/output
        mkdir ${OUTPUT_DIR}
        cp \
          bazel-bin/package-generic-unix.tar.xz \
          ${OUTPUT_DIR}/package-generic-unix-for-mixed-version-testing-v${{ steps.check.outputs.version }}.tar.xz
    - name: UPLOAD THE ARCHIVE TO S3
      if: env.exists != 'true'
      uses: jakejarvis/s3-sync-action@v0.5.1
      with:
        args: --acl public-read --follow-symlinks
      env:
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
        AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
        AWS_REGION: ${{ secrets.AWS_REGION }}
        SOURCE_DIR: output
        DEST_DIR: secondary-umbrellas

  test-mixed-versions:
    name: Test (Mixed Version Cluster)
    runs-on: ubuntu-20.04
    needs: ensure-mixed-version-archive
    strategy:
      fail-fast: false
      matrix:
        otp_version_id:
        - "25_3"
    timeout-minutes: 120
    steps:
    - name: CHECKOUT REPOSITORY
      uses: actions/checkout@v3
    - name: MOUNT BAZEL CACHE
      uses: actions/cache@v3.3.1
      with:
        path: "/home/runner/repo-cache/"
        key: repo-cache
    - name: CONFIGURE BAZEL
      run: |
        if [ -n "${{ secrets.BUILDBUDDY_API_KEY }}" ]; then
        cat << EOF >> user.bazelrc
          build:buildbuddy --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_API_KEY }}
        EOF
        fi
        cat << EOF >> user.bazelrc
          build:buildbuddy --build_metadata=ROLE=CI
          build:buildbuddy --build_metadata=VISIBILITY=PUBLIC
          build:buildbuddy --repository_cache=/home/runner/repo-cache/
          build:buildbuddy --color=yes
          build:buildbuddy --disk_cache=
        EOF
    #! - 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-${{ matrix.otp_version_id }} \
          --test_tag_filters=mixed-version-cluster,-exclusive,-aws,-docker \
          --build_tests_only \
          --verbose_failures
  test-exclusive-mixed-versions:
    name: Test (Exclusive Tests with Mixed Version Cluster)
    runs-on: ubuntu-20.04
    needs: ensure-mixed-version-archive
    strategy:
      matrix:
        include:
        - erlang_version: "25.3"
          elixir_version: 1.14.0
    timeout-minutes: 60
    steps:
    - name: CHECKOUT REPOSITORY
      uses: actions/checkout@v3
    - name: CONFIGURE OTP & ELIXIR
      uses: erlef/setup-beam@v1.15
      with:
        otp-version: ${{ matrix.erlang_version }}
        elixir-version: ${{ matrix.elixir_version }}
    - name: MOUNT BAZEL CACHE
      uses: actions/cache@v3.3.1
      with:
        path: "/home/runner/repo-cache/"
        key: repo-cache
    - 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 }}
        EOF
        fi
        cat << EOF >> user.bazelrc
          build:buildbuddy --build_metadata=ROLE=CI
          build:buildbuddy --build_metadata=VISIBILITY=PRIVATE
          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}
        EOF
    #! - name: Setup tmate session
    #!   uses: mxschmitt/action-tmate@v3
    - name: RUN EXCLUSIVE TESTS
      run: |
        MIXED_EXCLUSIVE_TESTS=$(bazel query 'attr(tags, "mixed-version-cluster", attr(tags, "exclusive", tests(//...)))')
        bazelisk test $MIXED_EXCLUSIVE_TESTS \
          --config=buildbuddy \
          --test_tag_filters=-aws,-docker \
          --build_tests_only \
          --test_env RABBITMQ_CT_HELPERS_DELETE_UNUSED_NODES=true \
          --verbose_failures
  summary-mixed-versions:
    needs:
    - test-mixed-versions
    - test-exclusive-mixed-versions
    runs-on: ubuntu-latest
    steps:
    - name: SUMMARY
      run: |
        echo "SUCCESS"