Skip to content
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

Update local dev MongoDB versions #15334

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
CI: true
NODE_ENV: test
- run: npm run test:sanity

common:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -122,13 +122,13 @@ jobs:
CI: true
NODE_ENV: test
- run: npm run test:content

api-unit:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [21.x]
mongodb-version: [4.2]
mongodb-version: [7.0]
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -137,11 +137,13 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB ${{ matrix.mongodb-version }} Replica Set
uses: supercharge/mongodb-github-action@1.3.0
uses: supercharge/mongodb-github-action@1.11.0
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-replica-set: rs

- run: sudo apt update
- run: sudo apt -y install libkrb5-dev
- run: cp config.json.example config.json
Expand All @@ -151,15 +153,19 @@ jobs:
env:
CI: true
NODE_ENV: test

#- run: npm run mongo:dev -- -d
- run: npm run test:api:unit
env:
REQUIRES_SERVER=true: true

#- run: npm run mongo:dev:down
api-v3-integration:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [21.x]
mongodb-version: [4.2]
mongodb-version: [7.0]
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -169,10 +175,11 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- name: Start MongoDB ${{ matrix.mongodb-version }} Replica Set
uses: supercharge/mongodb-github-action@1.3.0
uses: supercharge/mongodb-github-action@1.11.0
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-replica-set: rs

- run: sudo apt update
- run: sudo apt -y install libkrb5-dev
- run: cp config.json.example config.json
Expand All @@ -182,15 +189,20 @@ jobs:
env:
CI: true
NODE_ENV: test

#- run: npm run mongo:dev -- -d
- run: npm run test:api-v3:integration
env:
REQUIRES_SERVER=true: true

#- run: npm run mongo:dev:down
api-v4-integration:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [21.x]
mongodb-version: [4.2]
mongodb-version: [7.0]

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -200,10 +212,11 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- name: Start MongoDB ${{ matrix.mongodb-version }} Replica Set
uses: supercharge/mongodb-github-action@1.3.0
uses: supercharge/mongodb-github-action@1.11.0
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-replica-set: rs

- run: sudo apt update
- run: sudo apt -y install libkrb5-dev
- run: cp config.json.example config.json
Expand All @@ -213,10 +226,13 @@ jobs:
env:
CI: true
NODE_ENV: test
#- run: npm run mongo:dev -- -d
- run: npm run test:api-v4:integration
env:
REQUIRES_SERVER=true: true


#- run: npm run mongo:dev:down
client-unit:
runs-on: ubuntu-latest
strategy:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ webpack.webstorm.config

# mongodb replica set for local dev
mongodb-*.tgz
/mongodb-data
/mongodb-data*
/.nyc_output
4 changes: 2 additions & 2 deletions config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"LOGGLY_TOKEN": "example-token",
"LOG_REQUESTS_EXCESSIVE_MODE": "false",
"MAINTENANCE_MODE": "false",
"NODE_DB_URI": "mongodb://localhost:27017/habitica-dev?replicaSet=rs",
"TEST_DB_URI": "mongodb://localhost:27017/habitica-test?replicaSet=rs",
"NODE_DB_URI": "mongodb://localhost:27017/habitica-dev?replicaSet=rs&directConnection=true&readPreference=secondary",
"TEST_DB_URI": "mongodb://localhost:27017/habitica-test?replicaSet=rs&directConnection=true&readPreference=secondary",
"MONGODB_POOL_SIZE": "10",
"MONGODB_SOCKET_TIMEOUT": "20000",
"NODE_ENV": "development",
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
- .:/usr/src/habitica
- /usr/src/habitica/node_modules
mongo:
image: mongo:5.0.23
image: mongo:7.0
restart: unless-stopped
command: ["--replSet", "rs", "--bind_ip_all", "--port", "27017"]
healthcheck:
Expand Down
37 changes: 37 additions & 0 deletions docker-compose.mongo-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# big thanks to https://pakisan.github.io/posts/docker-compose-mongodb-single-node-replica-set/ <3

version: "3.9"
networks:
mongodb-network:
name: "mongodb-network"
driver: bridge
services:
mongodb:
image: "mongo:7.0"
container_name: "mongodb"
networks:
- mongodb-network
hostname: "mongodb"
ports:
- "27017:27017"
restart: "unless-stopped"
volumes:
- "./mongodb-data:/data/db"
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs" ]
mongoinit:
image: "mongo:7.0"
container_name: "mongodb_replSet_initializer"
restart: "on-failure" # WITHOUT THIS, the initializer tries only once and fails
depends_on:
- mongodb
networks:
- mongodb-network

command: >
mongosh --host mongodb:27017 --eval "rs.initiate({
_id: \"rs\",
members: [
{_id: 0, host: \"mongodb\"}
]
})"

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ services:
- mongo

mongo:
image: mongo:3.6
image: mongo:7.0
ports:
- "27017:27017"
networks:
Expand Down
8 changes: 5 additions & 3 deletions gulp/gulp-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import path from 'path';
import babel from 'gulp-babel';
import os from 'os';
import fs from 'fs';
import spawn from 'cross-spawn'; // eslint-disable-line import/no-extraneous-dependencies
import clean from 'rimraf';
/* import spawn from 'cross-spawn'; // eslint-disable-line import/no-extraneous-dependencies
import clean from 'rimraf'; */

gulp.task('build:babel:server', () => gulp.src('website/server/**/*.js')
.pipe(babel())
Expand Down Expand Up @@ -51,7 +51,7 @@ gulp.task('build:prepare-mongo', async () => {
console.log('MongoDB data folder is missing, setting up.'); // eslint-disable-line no-console

// use run-rs without --keep, kill it as soon as the replica set starts
const runRsProcess = spawn('run-rs', ['-v', '4.1.1', '-l', 'ubuntu1804', '--dbpath', 'mongodb-data', '--number', '1', '--quiet']);
/* const runRsProcess = spawn('node', ['../scripts/start-local-mongo.mjs --build-db']);

for await (const chunk of runRsProcess.stdout) {
const stringChunk = chunk.toString();
Expand Down Expand Up @@ -79,6 +79,8 @@ gulp.task('build:prepare-mongo', async () => {

throw new Error(`Error running run-rs: ${error}`);
}

*/
});

gulp.task('build:dev', gulp.series(
Expand Down
5 changes: 5 additions & 0 deletions gulp/gulp-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
const mongooseOptions = getDefaultConnectionOptions();
const connectionUrl = getDevelopmentConnectionUrl(TEST_DB_URI);

console.info({

Check warning on line 62 in gulp/gulp-tests.js

View workflow job for this annotation

GitHub Actions / lint (21.x)

Unexpected console statement

Check warning on line 62 in gulp/gulp-tests.js

View workflow job for this annotation

GitHub Actions / lint (21.x)

Unexpected console statement
mongooseOptions,
connectionUrl,
});

mongoose.connect(connectionUrl, mongooseOptions)
.then(() => mongoose.connection.dropDatabase())
.then(() => mongoose.connection.close()).then(() => {
Expand Down
Loading
Loading