Skip to content

fix(llc): Don't upsert out-of-window messages on message.updated/message.deleted events #856

fix(llc): Don't upsert out-of-window messages on message.updated/message.deleted events

fix(llc): Don't upsert out-of-window messages on message.updated/message.deleted events #856

name: check_db_entities
on:
pull_request_target:
concurrency:
# Use PR number — github.ref is the base branch under pull_request_target.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# pull_request_target needs explicit perms; fork PRs default to read-only.
permissions:
contents: read
issues: write
pull-requests: write
jobs:
# Centralizes every gating decision for this workflow — currently just a
# path filter. Downstream jobs only need a single
# `if: needs.gate.outputs.should_run == 'true'`. A job skipped this way
# reports `success` to branch protection (vs. `on.paths` filtering, which
# hangs forever) — see
# https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks
gate:
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.filter.outputs.persistence }}
steps:
- name: 📥 Checkout
uses: actions/checkout@v6
- name: 🛤️ Detect Path Changes
uses: dorny/paths-filter@v4
id: filter
with:
filters: |
persistence:
- 'packages/stream_chat_persistence/**'
- '.github/workflows/check_db_entities.yml'
check_entity_modifications:
needs: gate
if: needs.gate.outputs.should_run == 'true'
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: 🔎 Check DB Entity Changes
id: check_entities
run: |
ENTITY_DIR="packages/stream_chat_persistence/lib/src/entity"
TEMP_FILE="modified_entities"
BASE_BRANCH="${{ github.base_ref }}"
PR_HEAD_SHA="${{ github.event.pull_request.head.sha }}"
echo "Using base branch: origin/$BASE_BRANCH for comparison"
# Fetch PR head (refs only; full history needed for merge-base).
git fetch --no-tags origin "$PR_HEAD_SHA"
# Check if any entity files have changed compared to the base branch
git diff --name-only "origin/$BASE_BRANCH...$PR_HEAD_SHA" -- $ENTITY_DIR > $TEMP_FILE.raw
grep -E '\.dart$' $TEMP_FILE.raw > $TEMP_FILE || [ $? -eq 1 ]
if [ ! -s "$TEMP_FILE" ]; then
echo "✅ No entity files changed."
echo "has_changes=false" >> $GITHUB_OUTPUT
rm $TEMP_FILE
exit 0
fi
echo "⚠️ Entity files modified:"
cat $TEMP_FILE
# Set modified files as output
echo "modified_files<<EOF" >> $GITHUB_OUTPUT
cat $TEMP_FILE >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "has_changes=true" >> $GITHUB_OUTPUT
- name: 🔍 Find Comment
if: steps.check_entities.outputs.has_changes == 'true'
uses: peter-evans/find-comment@v4
id: find_comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: github-actions[bot]
body-includes: Database Entity Files Modified
- name: 💬 Create or Update Comment
if: steps.check_entities.outputs.has_changes == 'true'
uses: peter-evans/create-or-update-comment@v5
with:
comment-id: ${{ steps.find_comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## ⚠️ Database Entity Files Modified
The following database entity files have been modified in this PR:
```
${{ steps.check_entities.outputs.modified_files }}
```
### 📝 Remember to:
1. Update database version in `db/drift_chat_database.dart`.
2. Update entity schema tests if necessary.
*Note: This comment is automatically generated by the CI workflow.*
edit-mode: replace