Fix BREAKING_CHANGE string detection in commit msg / PR body #35
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: backwards_compatibility | |
on: | |
pull_request: | |
branches: | |
- master | |
types: [opened, synchronize, reopened, edited] | |
jobs: | |
check_commit_message: | |
runs-on: ubuntu-latest | |
outputs: | |
should_skip: ${{ steps.check_commits.outputs.skip || steps.check_pr_body.outputs.skip }} | |
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: ${{ github.event.pull_request.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 | |
build_and_test: | |
runs-on: ubuntu-latest | |
needs: check_commit_message | |
if: ${{ needs.check_commit_message.outputs.should_skip != 'true' }} | |
steps: | |
- run: echo "${{ needs.check_commit_message.outputs.should_skip }}" | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
fetch-depth: 0 | |
- name: Cache cargo & target directories | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: "v2" | |
- name: Build (PR) | |
run: cargo build | |
- 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 | |
tail: true | |
- name: Run send bench (PR) | |
timeout-minutes: 1 | |
run: target/debug/iggy-bench --warmup-time 0 --verbose send --message-batches 25 --messages-per-batch 25 tcp | |
- name: Stop iggy-server | |
timeout-minutes: 1 | |
run: pkill iggy-server && while pgrep -l iggy-server; do sleep 1; done; | |
- name: Reset to origin/master | |
run: git reset --hard origin/master | |
- name: Build (origin/master) | |
run: 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 | |
tail: true | |
- name: Run poll bench (origin/master) | |
timeout-minutes: 1 | |
run: target/debug/iggy-bench --warmup-time 0 --verbose poll --message-batches 25 --messages-per-batch 25 tcp | |
- name: Run send bench (origin/master) | |
timeout-minutes: 1 | |
run: target/debug/iggy-bench --warmup-time 0 --verbose send --message-batches 25 --messages-per-batch 25 tcp | |
- name: Stop iggy-server | |
timeout-minutes: 1 | |
run: pkill iggy-server && while pgrep -l iggy-server; do sleep 1; done; | |