Skip to content

Commit 04f7f88

Browse files
committed
Add support for installing mongosh when mongodb is greater than 6.0
1 parent 58e5311 commit 04f7f88

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

.github/workflows/github-actions.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ env:
3434

3535
MAIN_PYTHON_VERSION: 3.9
3636

37+
MONGOSH: 2.2.15 # Needed for MongoDB 6.0+
38+
3739
jobs:
3840
linting:
3941
# Run pre-commit (https://pre-commit.com/)
@@ -96,6 +98,7 @@ jobs:
9698
- name: install mongo and ci dependencies
9799
run: |
98100
bash .github/workflows/install_mongo.sh ${{ matrix.MONGODB }}
101+
bash .github/workflows/install_mongosh.sh ${{ matrix.MONGODB }} ${{ env.MONGOSH }}
99102
bash .github/workflows/install_ci_python_dep.sh
100103
bash .github/workflows/start_mongo.sh ${{ matrix.MONGODB }}
101104
- name: tox dry-run (to pre-install venv)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
MONGODB=$1
4+
MONGOSH=$2
5+
6+
if (( $(echo "$MONGODB < 6.0" | bc -l) )); then
7+
echo "mongosh is not needed for MongoDB versions less than 6.0"
8+
exit 0
9+
fi
10+
11+
wget https://downloads.mongodb.com/compass/mongosh-${MONGOSH}-linux-x64.tgz
12+
tar xzf mongosh-${MONGOSH}-linux-x64.tgz
13+
14+
mongosh_dir=$(find ${PWD}/ -type d -name "mongosh-${MONGOSH}-linux-x64")
15+
$mongosh_dir/bin/mongosh --version

.github/workflows/start_mongo.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@ mongodb_dir=$(find ${PWD}/ -type d -name "mongodb-linux-x86_64*")
66

77
mkdir $mongodb_dir/data
88
$mongodb_dir/bin/mongod --dbpath $mongodb_dir/data --logpath $mongodb_dir/mongodb.log --fork
9-
mongo --eval 'db.version();' # Make sure mongo is awake
9+
10+
if (( $(echo "$MONGODB < 6.0" | bc -l) )); then
11+
mongo --quiet --eval 'db.runCommand("ping").ok' # Make sure mongo is awake
12+
else
13+
mongosh --quiet --eval 'db.runCommand("ping").ok' # Make sure mongo is awake
14+
fi

tox.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = pypy3-{mg34,mg36,mg39,mg311,mg312,mg4,mg432,mg441,mg460}
2+
envlist = pypy3-{mg34,mg36,mg39,mg311,mg312,mg4,mg432,mg441,mg462,mg473,mg480}
33
skipsdist = True
44

55
[testenv]
@@ -14,5 +14,7 @@ deps =
1414
mg433: pymongo>=4.3,<4.4
1515
mg441: pymongo>=4.4,<4.5
1616
mg462: pymongo>=4.6,<4.7
17+
mg473: pymongo>=4.7,<4.8
18+
mg480: pymongo>=4.8,<4.9
1719
setenv =
1820
PYTHON_EGG_CACHE = {envdir}/python-eggs

0 commit comments

Comments
 (0)