blob: 5ed984073daa78d819c9cd7d180c3f4e0cd70ea8 [file]
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# -------------------------------------------------------------
#
# CI Compatibility Rust Workflow
#
# This workflow runs compatibility tests for Rust code on the master branch for pull requests.
# This workflow is triggered by the ci-check-pr workflow. It checks if BREAKING_CHANGE in the PR body
# and commit messages and skips the compatibility tests if found.
#
name: backwards_compatibility
on:
workflow_call:
inputs:
pr_body:
description: 'Pull Request body'
required: true
type: string
jobs:
check_commit_message:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.check_skip.outputs.skip == 'true' }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Print the event payload
run: cat "$GITHUB_EVENT_PATH"
- name: Check if BREAKING_CHANGE is present in any commits body in the PR
id: check_commits
run: |
BREAKING_CHANGE_FOUND=false
COMMIT_RANGE=origin/master...HEAD
for COMMIT in $(git log --format=%H $COMMIT_RANGE); do
COMMIT_MSG=$(git log --format=%B -n 1 $COMMIT)
COMMIT_MSG_SUBJECT=$(echo "$COMMIT_MSG" | head -n 1)
COMMIT_MSG_BODY=$(echo "$COMMIT_MSG" | tail -n +3)
echo "Commit $COMMIT, subject: $COMMIT_MSG_SUBJECT, body: $COMMIT_MSG_BODY"
if echo "$COMMIT_MSG_BODY" | grep -q "BREAKING_CHANGE"; then
BREAKING_CHANGE_FOUND=true
break
fi
done
if $BREAKING_CHANGE_FOUND; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "'BREAKING_CHANGE' found in commit message, setting skip=true"
else
echo "skip=false" >> $GITHUB_OUTPUT
echo "'BREAKING_CHANGE' not found in commit message, setting skip=false"
fi
- name: Check if BREAKING_CHANGE is present in pull request body
id: check_pr_body
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ENV_PR_BODY: ${{ inputs.pr_body }}
run: |
PR_BODY="$ENV_PR_BODY"
echo "Pull Request body: $PR_BODY"
if [[ "$PR_BODY" == *"BREAKING_CHANGE"* ]]; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "'BREAKING_CHANGE' found in pull request body, setting skip=true"
else
echo "skip=false" >> $GITHUB_OUTPUT
echo "'BREAKING_CHANGE' not found in pull request body, setting skip=false"
fi
- name: Check For Skip Condition
id: check_skip
run: |
if ${{ steps.check_commits.outputs.skip == 'true' }} || ${{ steps.check_pr_body.outputs.skip == 'true' }}; then
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
build_and_test:
runs-on: ubuntu-latest
needs: check_commit_message
if: ${{ needs.check_commit_message.outputs.should_skip != 'true' }}
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
steps:
- run: echo "${{ needs.check_commit_message.outputs.should_skip == 'true' }}"
- name: Checkout code (origin/master)
uses: actions/checkout@v4
with:
ref: master
fetch-depth: 0
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
with:
key: "backwards-compatibility"
- name: Build iggy-server (origin/master)
run: IGGY_CI_BUILD=true cargo build
- uses: JarvusInnovations/background-action@v1
name: Run iggy-server in background (origin/master)
with:
run: |
target/debug/iggy-server &
wait-on: tcp:localhost:8090
wait-for: 1m
log-output: true
log-output-if: timeout
tail: true
- name: Run producer bench (origin/master)
timeout-minutes: 1
run: target/debug/iggy-bench --verbose --message-batches 50 --messages-per-batch 100 pinned-producer tcp
- name: Run consumer bench (origin/master)
timeout-minutes: 1
run: target/debug/iggy-bench --verbose --message-batches 50 --messages-per-batch 100 pinned-consumer tcp
- name: Stop iggy-server (origin/master)
timeout-minutes: 1
run: pkill -15 iggy-server && while pgrep -l iggy-server; do sleep 2; done;
- name: Print iggy-server logs (origin/master)
run: cat local_data/logs/iggy*
- name: Remove iggy-server logs (origin/master)
run: rm local_data/logs/iggy*
- name: Copy local_data directory (origin/master)
run: cp -r local_data ..
- name: Checkout code (PR)
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
clean: false
- name: Build iggy-server (PR)
run: IGGY_CI_BUILD=true cargo build
- name: Restore local_data directory (PR)
run: cp -r ../local_data .
- uses: JarvusInnovations/background-action@v1
name: Run iggy-server in background (PR)
with:
run: |
target/debug/iggy-server &
wait-on: tcp:localhost:8090
wait-for: 1m
log-output: true
log-output-if: timeout
tail: true
- name: Run consumer bench (PR)
timeout-minutes: 1
run: target/debug/iggy-bench --verbose --message-batches 50 --messages-per-batch 100 pinned-consumer tcp
- name: Stop iggy-server (PR)
timeout-minutes: 1
run: pkill iggy-server && while pgrep -l iggy-server; do sleep 1; done;
- name: Print server logs (PR)
run: cat local_data/logs/iggy*