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 14 commits into
base: develop
Choose a base branch
from
Open
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",
"TEST_DB_URI": "mongodb://localhost:27017/habitica-test?replicaSet=rs&directConnection=true",
"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
15 changes: 15 additions & 0 deletions docker-compose.mongo-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
mongo:
image: mongo:7.0
restart: unless-stopped
command: ["--replSet", "rs", "--bind_ip_all", "--port", "27017"]
healthcheck:
test: echo "try { rs.status() } catch (err) { rs.initiate() }" | mongosh --port 27017 --quiet
interval: 10s
timeout: 30s
start_period: 0s
retries: 30
volumes:
- "./mongodb-data2:/data/db"
ports:
- "27017:27017"
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
4 changes: 3 additions & 1 deletion gulp/gulp-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
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

Check failure on line 8 in gulp/gulp-build.js

View workflow job for this annotation

GitHub Actions / lint (21.x)

'spawn' is defined but never used

Check failure on line 8 in gulp/gulp-build.js

View workflow job for this annotation

GitHub Actions / lint (21.x)

'spawn' is defined but never used
import clean from 'rimraf';

Check failure on line 9 in gulp/gulp-build.js

View workflow job for this annotation

GitHub Actions / lint (21.x)

'clean' is defined but never used

Check failure on line 9 in gulp/gulp-build.js

View workflow job for this annotation

GitHub Actions / lint (21.x)

'clean' is defined but never used

gulp.task('build:babel:server', () => gulp.src('website/server/**/*.js')
.pipe(babel())
Expand Down Expand Up @@ -51,7 +51,7 @@
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 @@

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