Skip to content

Commit

Permalink
Use mongo for CI with a env hack
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed Feb 28, 2020
1 parent 7574d14 commit 087683a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/deps_eager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ jobs:
matrix:
python-version: [3.6, 3.7, 3.8]

services:
mongo:
image: mongo

steps:
- uses: actions/checkout@v1

Expand All @@ -36,6 +40,8 @@ jobs:
- name: Run tests on updated packages
run: |
pytest -rs --cov=./optimade/
env:
OPTIMADE_CI_FORCE_MONGO=1

# deps_clean-install:
# runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/deps_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ jobs:
matrix:
python-version: [3.6, 3.7, 3.8]

services:
mongo:
image: mongo

steps:
- uses: actions/checkout@v1

Expand All @@ -158,6 +162,8 @@ jobs:
- name: Run tests
run: |
pytest -rs --cov=./optimade/ --cov-report=xml
env:
OPTIMADE_CI_FORCE_MONGO=1

- name: Upload coverage to Codecov
if: matrix.python-version == 3.7
Expand Down
9 changes: 8 additions & 1 deletion optimade/server/entry_collections.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from abc import abstractmethod
from typing import Collection, Tuple, List, Union

Expand All @@ -13,8 +14,14 @@
from .mappers import ResourceMapper
from .query_params import EntryListingQueryParams, SingleEntryQueryParams

ci_force_mongo = os.environ.get("OPTIMADE_CI_FORCE_MONGO", False)
try:
ci_force_mongo = bool(ci_force_mongo)
except Exception:
ci_force_mongo = False

if CONFIG.use_real_mongo:

if CONFIG.use_real_mongo or ci_force_mongo:
from pymongo import MongoClient

client = MongoClient(CONFIG.mongo_uri)
Expand Down

0 comments on commit 087683a

Please sign in to comment.