-
Notifications
You must be signed in to change notification settings - Fork 13.5k
chore: document db #39415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
chore: document db #39415
Changes from all commits
0342058
46e6c2a
8c7cc95
3414526
ce461de
7a422b3
4d1d8b4
29146f6
2a7302a
ed16451
589e967
14e43e4
c54acf4
2d5eadb
81a380b
1a9ee44
4f3e6dd
f936cee
d573692
0c1f0c4
c3617a8
97989f0
3839fae
2f6959f
5a06c52
59cf90a
3410339
87da79a
7af0e7d
52162e2
548141b
c4b2dcb
6032a7b
0b92d82
d98a502
3d30c8c
032175a
a98fb66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,14 @@ on: | |
| required: false | ||
| CODECOV_TOKEN: | ||
| required: false | ||
| CI_MONGO_URL: | ||
| required: false | ||
| NETBIRD_SETUP_KEY: | ||
| required: false | ||
| NETBIRD_PSK: | ||
| required: false | ||
| NETBIRD_TEST_IP: | ||
| required: false | ||
| REPORTER_JIRA_ROCKETCHAT_API_KEY: | ||
| required: false | ||
|
|
||
|
|
@@ -71,10 +79,12 @@ jobs: | |
| runs-on: ubuntu-24.04 | ||
|
|
||
| env: | ||
| # secrets are not available in step `if:`; use for steps that must run only with CI_MONGO_URL | ||
| HAS_CI_MONGO_URL: ${{ secrets.CI_MONGO_URL != '' && 'true' || 'false' }} | ||
| # if building for production on develop branch or release, add suffix for coverage images | ||
| DOCKER_TAG_SUFFIX_ROCKETCHAT: ${{ inputs.coverage == matrix.mongodb-version && (github.event_name == 'release' || github.ref == 'refs/heads/develop') && '-cov' || '' }} | ||
| MONGODB_VERSION: ${{ matrix.mongodb-version }} | ||
| COVERAGE_DIR: '/tmp/coverage/${{ startsWith(inputs.type, ''api'') && ''api'' || inputs.type }}' | ||
| COVERAGE_DIR: "/tmp/coverage/${{ startsWith(inputs.type, 'api') && 'api' || inputs.type }}" | ||
| COVERAGE_FILE_NAME: '${{ inputs.type }}-${{ matrix.shard }}.json' | ||
| COVERAGE_REPORTER: ${{ inputs.coverage == matrix.mongodb-version && 'json' || '' }} | ||
|
|
||
|
|
@@ -155,6 +165,29 @@ jobs: | |
| # List loaded images | ||
| docker images | ||
|
|
||
| - name: Connect to NetBird | ||
| if: env.HAS_CI_MONGO_URL == 'true' | ||
| uses: RocketChat/netbird-connect@main | ||
| with: | ||
| setup-key: ${{ secrets.NETBIRD_SETUP_KEY }} | ||
| preshared-key: ${{ secrets.NETBIRD_PSK }} | ||
| test-ip: ${{ secrets.NETBIRD_TEST_IP }} | ||
|
|
||
| - name: Configure external MongoDB URL | ||
| env: | ||
| CI_MONGO_URL: ${{ secrets.CI_MONGO_URL }} | ||
| if: env.CI_MONGO_URL != '' | ||
| run: | | ||
| DB_NAME="rocketchat_${{ inputs.type }}_${{ matrix.shard }}_${{ github.run_id }}_${{ github.run_attempt }}" | ||
| BASE="${CI_MONGO_URL%%\?*}" | ||
| BASE="${BASE%/}" | ||
| QUERY="${CI_MONGO_URL#"$BASE"}" | ||
cubic-dev-ai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| FULL_URL="${BASE}/${DB_NAME}${QUERY}" | ||
| echo "MONGO_URL=${FULL_URL}" >> $GITHUB_ENV | ||
| echo "DOCKER_MONGO_URL=${FULL_URL}" >> $GITHUB_ENV | ||
| echo "EXTERNAL_MONGO=true" >> $GITHUB_ENV | ||
|
Comment on lines
+176
to
+188
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check if there's any cleanup mechanism for external MongoDB databases in the workflow or elsewhere
rg -n "drop.*database|dropDatabase|cleanup.*mongo|mongo.*cleanup" .github/Repository: RocketChat/Rocket.Chat Length of output: 48 🏁 Script executed: #!/bin/bash
# Get the full workflow file to check for any cleanup steps or jobs
cat .github/workflows/ci-test-e2e.yml | tail -100Repository: RocketChat/Rocket.Chat Length of output: 4310 🏁 Script executed: #!/bin/bash
# Search entire repository (not just .github/) for MongoDB cleanup patterns
rg -i "mongodump|mongodb.*cleanup|cleanup.*mongodb|drop.*db|dropdb|truncate.*collection" --type yaml --type sh --type jsRepository: RocketChat/Rocket.Chat Length of output: 200 🏁 Script executed: #!/bin/bash
# Check if there's a separate cleanup workflow or script
fd -e yml -e yaml -e sh | xargs grep -l "cleanup\|teardown\|mongo" | head -20Repository: RocketChat/Rocket.Chat Length of output: 268 🏁 Script executed: #!/bin/bash
# Check the docker-compose-ci.yml for any cleanup or teardown configurations
head -50 docker-compose-ci.ymlRepository: RocketChat/Rocket.Chat Length of output: 1840 🏁 Script executed: #!/bin/bash
# Check if there are any cleanup hooks or scripts referenced
grep -r "external.*mongo\|CI_MONGO_URL" . --include="*.yml" --include="*.yaml" -B 2 -A 2 | head -50Repository: RocketChat/Rocket.Chat Length of output: 2956 🏁 Script executed: #!/bin/bash
# Search for any comments or documentation about external MongoDB cleanup expectations
rg -i "external.*mongo.*cleanup|cleanup.*external.*mongo|external.*mongo.*manual" --type md --type txt --type ymlRepository: RocketChat/Rocket.Chat Length of output: 93 🏁 Script executed: #!/antml/bin/bash
# Check if there are any GitHub issues or discussion references
grep -r "cleanup\|orphan" .github/workflows/ | grep -i "mongo\|database"Repository: RocketChat/Rocket.Chat Length of output: 48 🏁 Script executed: #!/bin/bash
# Look at the full "Configure external MongoDB URL" step and surrounding context
sed -n '155,175p' .github/workflows/ci-test-e2e.ymlRepository: RocketChat/Rocket.Chat Length of output: 880 Add database cleanup for external MongoDB test runs. When using an external MongoDB (via Consider adding a cleanup step (or job) that drops the test database after tests complete, especially for external MongoDB configurations. 🤖 Prompt for AI Agents |
||
| echo "DOCUMENTDB=true" >> $GITHUB_ENV | ||
|
|
||
| - name: Set DEBUG_LOG_LEVEL (debug enabled) | ||
| if: runner.debug == '1' | ||
| run: echo "DEBUG_LOG_LEVEL=2" >> $GITHUB_ENV | ||
|
|
@@ -175,15 +208,23 @@ jobs: | |
| if: inputs.release == 'ce' | ||
| run: | | ||
| # when we are testing CE, we only need to start the rocketchat container | ||
| DEBUG_LOG_LEVEL=${DEBUG_LOG_LEVEL:-0} docker compose -f docker-compose-ci.yml up -d rocketchat --wait | ||
| EXTRA_ARGS="" | ||
| if [ "$EXTERNAL_MONGO" = "true" ]; then | ||
| EXTRA_ARGS="--scale mongo=0" | ||
| fi | ||
| DEBUG_LOG_LEVEL=${DEBUG_LOG_LEVEL:-0} docker compose -f docker-compose-ci.yml up -d rocketchat $EXTRA_ARGS --wait | ||
|
|
||
| - name: Start containers for EE | ||
| if: inputs.release == 'ee' | ||
| env: | ||
| ENTERPRISE_LICENSE: ${{ inputs.enterprise-license }} | ||
| TRANSPORTER: ${{ inputs.transporter }} | ||
| run: | | ||
| DEBUG_LOG_LEVEL=${DEBUG_LOG_LEVEL:-0} docker compose -f docker-compose-ci.yml up -d --wait | ||
| EXTRA_ARGS="" | ||
| if [ "$EXTERNAL_MONGO" = "true" ]; then | ||
| EXTRA_ARGS="--scale mongo=0" | ||
| fi | ||
| DEBUG_LOG_LEVEL=${DEBUG_LOG_LEVEL:-0} docker compose -f docker-compose-ci.yml up -d $EXTRA_ARGS --wait | ||
|
|
||
| - uses: ./.github/actions/setup-playwright | ||
| if: inputs.type == 'ui' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -543,42 +543,28 @@ API.v1.addRoute( | |
| ] | ||
| : []; | ||
|
|
||
| const result = await Users.col | ||
| .aggregate<{ sortedResults: IUser[]; totalCount: { total: number }[] }>([ | ||
| { | ||
| $match: nonEmptyQuery, | ||
| }, | ||
| { | ||
| $project: inclusiveFields, | ||
| }, | ||
| { | ||
| $addFields: { | ||
| nameInsensitive: { | ||
| $toLower: '$name', | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| $facet: { | ||
| sortedResults: [ | ||
| { | ||
| $sort: actualSort, | ||
| }, | ||
| { | ||
| $skip: offset, | ||
| }, | ||
| ...limit, | ||
| ], | ||
| totalCount: [{ $group: { _id: null, total: { $sum: 1 } } }], | ||
| const baseQuery = [ | ||
| { | ||
| $match: nonEmptyQuery, | ||
| }, | ||
| { | ||
| $project: inclusiveFields, | ||
| }, | ||
| { | ||
| $addFields: { | ||
| nameInsensitive: { | ||
| $toLower: '$name', | ||
| }, | ||
| }, | ||
| ]) | ||
| .toArray(); | ||
| }, | ||
| ]; | ||
|
|
||
| const [users, countResult] = await Promise.all([ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: (Based on your team's feedback about concurrency changes affecting behavior.) Prompt for AI agents |
||
| Users.col.aggregate<IUser>([...baseQuery, { $sort: actualSort }, { $skip: offset }, ...limit]).toArray(), | ||
| Users.col.aggregate<{ total: number }>([...baseQuery, { $count: 'total' }]).toArray(), | ||
| ]); | ||
|
|
||
| const { | ||
| sortedResults: users, | ||
| totalCount: [{ total } = { total: 0 }], | ||
| } = result[0]; | ||
| const total = countResult[0]?.total || 0; | ||
|
|
||
| return API.v1.success({ | ||
| users, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Pin the NetBird GitHub Action to an immutable commit SHA instead of
@mainto avoid supply-chain risk and non-reproducible CI runs.Prompt for AI agents