Skip to content

Commit b939920

Browse files
authored
feat(repo): add check_db_entities workflow (#2174)
* feat(ci): add check_db_entities workflow * chore: test push for workflow * Revert "chore: test push for workflow" This reverts commit b13a456. * chore: minor changes * chore: more minor changes * chore: add path filter to run only for persistence * chore: temp changes * Revert "chore: temp changes" This reverts commit 29209a4.
1 parent cfcbd5a commit b939920

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: check_db_entities
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'packages/stream_chat_persistence/**'
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
check_entity_modifications:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: 📥 Checkout
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
- name: 🔎 Check DB Entity Changes
22+
id: check_entities
23+
run: |
24+
ENTITY_DIR="packages/stream_chat_persistence/lib/src/entity"
25+
TEMP_FILE="modified_entities"
26+
BASE_BRANCH="${{ github.base_ref }}"
27+
28+
echo "Using base branch: origin/$BASE_BRANCH for comparison"
29+
30+
# Check if any entity files have changed compared to the base branch
31+
git diff-index --name-only origin/$BASE_BRANCH -- $ENTITY_DIR | grep -E '\.dart$' > $TEMP_FILE || true
32+
33+
if [ ! -s "$TEMP_FILE" ]; then
34+
echo "✅ No entity files changed."
35+
echo "has_changes=false" >> $GITHUB_OUTPUT
36+
rm $TEMP_FILE
37+
exit 0
38+
fi
39+
40+
echo "⚠️ Entity files modified:"
41+
cat $TEMP_FILE
42+
43+
# Set modified files as output
44+
echo "modified_files<<EOF" >> $GITHUB_OUTPUT
45+
cat $TEMP_FILE >> $GITHUB_OUTPUT
46+
echo "EOF" >> $GITHUB_OUTPUT
47+
echo "has_changes=true" >> $GITHUB_OUTPUT
48+
49+
- name: 🔍 Find Comment
50+
if: steps.check_entities.outputs.has_changes == 'true'
51+
uses: peter-evans/find-comment@v2
52+
id: find_comment
53+
with:
54+
issue-number: ${{ github.event.pull_request.number }}
55+
comment-author: github-actions[bot]
56+
body-includes: Database Entity Files Modified
57+
58+
- name: 💬 Create or Update Comment
59+
if: steps.check_entities.outputs.has_changes == 'true'
60+
uses: peter-evans/create-or-update-comment@v2
61+
with:
62+
comment-id: ${{ steps.find_comment.outputs.comment-id }}
63+
issue-number: ${{ github.event.pull_request.number }}
64+
body: |
65+
## ⚠️ Database Entity Files Modified
66+
67+
The following database entity files have been modified in this PR:
68+
```
69+
${{ steps.check_entities.outputs.modified_files }}
70+
```
71+
72+
### 📝 Remember to:
73+
1. Update database version in `db/drift_chat_database.dart`.
74+
2. Update entity schema tests if necessary.
75+
76+
*Note: This comment is automatically generated by the CI workflow.*
77+
edit-mode: replace

0 commit comments

Comments
 (0)