-
Notifications
You must be signed in to change notification settings - Fork 46
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
ci(server): mongo update 7 #1326
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request updates the GitHub Actions CI workflow configuration for the server testing environment. The primary modifications include upgrading the MongoDB service image from version 5 to version 7 and adding a cache dependency path for the server's Go dependencies. These changes aim to improve the consistency and performance of the continuous integration pipeline by using a more recent MongoDB version and implementing dependency caching. Changes
Possibly related PRs
Suggested labels
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
✅ Deploy Preview for reearth-web canceled.
|
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.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
.github/workflows/ci_server.yml (1)
Replica set configuration should be kept in CI environment
The review comment is valid. From the search results, we can see that:
- The docker-compose.yml uses MongoDB with replica set configuration:
command: ["mongod", "--replSet", "rs0"]
- The application's default configuration in various environments (development, docker) consistently includes replica set setup
- The CI environment (.github/workflows/ci_server.yml) is the only place where replica set configuration is missing
The suggested change to include replica set configuration in CI would make it consistent with other environments and ensure proper testing of MongoDB-dependent features.
🔗 Analysis chain
Line range hint
41-42
: Review MongoDB connection configurationThe test environment uses a simple MongoDB URL without replica set configuration. This might not properly test the application's behavior with a replica set.
Consider updating the connection string to match production configuration:
env: - REEARTH_DB: mongodb://localhost + REEARTH_DB: mongodb://localhost:27017/?replicaSet=rs0
Let me gather more information about the MongoDB configuration in the codebase to verify if replica set configuration is necessary.
This will help us understand:
- How MongoDB connections are configured across the codebase
- Whether replica sets are used in other environments
- If there are any specific MongoDB client initialization patterns
🏁 Scripts executed
The following scripts were executed for the analysis:
Error: No shell scripts found
Script:
#!/bin/bash # Search for MongoDB connection strings and configuration patterns rg -i "mongodb://" -A 3 -B 3 # Search for MongoDB related configuration or setup files fd -e yaml -e yml -e json | xargs rg -i "mongodb|mongo" # Look for any MongoDB client initialization or connection setup code ast-grep --pattern 'mongodb://$$$'Length of output: 2690
🧰 Tools
🪛 actionlint (1.7.4)
33-33: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🧹 Nitpick comments (1)
docker-compose.yml (1)
23-24
: Review MongoDB replication configurationThe current replication setup appears incomplete:
- Single node replica set configuration without additional members
- No explicit configuration for replica set initialization timing
- Missing health check to ensure replica set is ready before application starts
Consider these improvements:
- Add healthcheck configuration to ensure replica set is properly initialized
- Add restart policy for proper startup ordering
- Consider adding additional replica set members for proper redundancy
Example additions:
command: ["mongod", "--replSet", "rs0"] + healthcheck: + test: mongosh --eval "rs.status().ok" + interval: 10s + timeout: 5s + retries: 5 + restart: always🧰 Tools
🪛 yamllint (1.35.1)
[error] 24-24: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.github/workflows/ci_server.yml
(1 hunks)docker-compose.yml
(1 hunks)mongo-init.js
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- mongo-init.js
🧰 Additional context used
🪛 yamllint (1.35.1)
docker-compose.yml
[error] 24-24: trailing spaces
(trailing-spaces)
🔇 Additional comments (2)
docker-compose.yml (2)
23-23
: Verify mongo-init.js script existence and permissions
The configuration mounts mongo-init.js
but this file is not included in the PR. Please ensure:
- The initialization script is provided
- It contains proper replica set initialization logic
✅ Verification successful
MongoDB initialization script is present and contains replica set configuration ✅
The mongo-init.js
file exists and includes the necessary replica set initialization logic:
- Initializes a replica set named "rs0"
- Configures a single member node at localhost:27017
- Includes status check command
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if mongo-init.js exists and verify its content
if [ -f mongo-init.js ]; then
echo "File exists. Content:"
cat mongo-init.js
else
echo "ERROR: mongo-init.js is missing"
exit 1
fi
Length of output: 195
18-18
: Verify MongoDB 7.x compatibility with the application
The upgrade to MongoDB 7 (focal) is a significant version change that might introduce breaking changes. Please ensure:
- The application is compatible with MongoDB 7.x
- All MongoDB driver versions in the application support MongoDB 7.x
Run this script to check MongoDB driver compatibility in the codebase:
✅ Verification successful
Let me gather more information about the MongoDB driver version being used.
MongoDB 7.x compatibility is verified
The application uses MongoDB Go Driver v1.13.1 which fully supports MongoDB 7.x. According to MongoDB's compatibility matrix, this driver version is compatible with MongoDB server versions 3.6 through 7.0. The upgrade to mongo:7-focal is safe to proceed.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for MongoDB driver/client version declarations
rg -g '*.go' 'mongo.Connect|mongo.NewClient|go.mongodb.org/mongo-driver' server/
Length of output: 4981
Script:
#!/bin/bash
# Check go.mod for MongoDB driver version
rg "go.mongodb.org/mongo-driver" server/go.mod -A 1
Length of output: 306
.github/workflows/ci_server.yml
Outdated
- name: Docker Compose start | ||
run: docker compose -f ../docker-compose.yml up -d reearth-mongo | ||
working-directory: server |
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.
Enhance MongoDB service initialization in CI
The current setup has several potential issues:
- No wait for MongoDB to be ready before tests
- No verification of replica set initialization
- Relative path
../docker-compose.yml
might be fragile in CI
Add proper initialization checks:
- name: Docker Compose start
run: docker compose -f ../docker-compose.yml up -d reearth-mongo
working-directory: server
+ - name: Wait for MongoDB
+ run: |
+ timeout 30s bash -c 'until mongosh --eval "rs.status().ok" > /dev/null 2>&1; do sleep 1; done'
+ working-directory: server
Also, consider using absolute paths with ${{ github.workspace }}
for more reliable file resolution:
- run: docker compose -f ../docker-compose.yml up -d reearth-mongo
+ run: docker compose -f ${{ github.workspace }}/docker-compose.yml up -d reearth-mongo
Committable suggestion skipped: line range outside the PR's diff.
mongo-init.js
Outdated
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.
Do we need this?
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.
command: ["mongod", "--replSet", "rs0"]
The idea is to set up the replica (rs0
) using the "mongod" startup option, and once it starts, the mongo-init.js
will be executed, enabling rs0
.
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.
We don't need replica, we can keep on using mongo the way we've been doing so far.
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.
Got it. I will remove it.
When running reearth-cloud locally, it needs to be configured individually.
a01ce11
to
73bfa3d
Compare
Overview
I will update the version of MongoDB used for development to version 7.
This will match the current cloud environment.
Additionally, I will set up a replica for MongoDB. This is necessary to enable complex transactions in MongoDB and is required when running reearth-cloud locally.
This will not affect reearth-visualizer.
What I've done
What I haven't done
How I tested
Which point I want you to review particularly
Memo
Summary by CodeRabbit