Skip to content

Commit 36fd837

Browse files
authored
Merge pull request #39 from microbiomedata/issue-32-ci-mongo-service
CI: spin up MongoDB service so live-DB tests actually run (closes #32)
2 parents e4a047a + 4f7aac3 commit 36fd837

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

.github/workflows/main.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@ jobs:
3737
matrix:
3838
python-version: [ '3.9', '3.10', '3.11', '3.12' ]
3939

40+
services:
41+
# Spin up a MongoDB the live-DB tests can connect to. The host port is
42+
# 27022 to match the value hardcoded in
43+
# tests/test_linkml_store_client_connections.py (which on `main` still
44+
# reads `MONGO_PORT = 27022` as a module-level constant); the env-reading
45+
# tests also pick up port 27022 via the MONGO_PORT env on the test step.
46+
# After #22's port-from-env change lands on `main`, this port choice
47+
# becomes arbitrary and can move to 27017.
48+
mongo:
49+
image: mongo:7
50+
ports:
51+
- 27022:27017
52+
env:
53+
MONGO_INITDB_ROOT_USERNAME: admin
54+
MONGO_INITDB_ROOT_PASSWORD: testpass
55+
options: >-
56+
--health-cmd "mongosh -u admin -p testpass --authenticationDatabase admin --eval 'db.adminCommand({ping:1})' --quiet"
57+
--health-interval 10s
58+
--health-timeout 5s
59+
--health-retries 10
60+
4061
steps:
4162
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4263

@@ -54,4 +75,12 @@ jobs:
5475
run: poetry install --all-extras
5576

5677
- name: Run test suite
78+
env:
79+
MONGO_HOST: localhost
80+
MONGO_PORT: '27022'
81+
MONGO_USERNAME: admin
82+
MONGO_PASSWORD: testpass
83+
MONGO_DBNAME: nmdc
84+
MONGO_DB: nmdc
85+
ENABLE_DB_TESTS: 'true'
5786
run: make test

0 commit comments

Comments
 (0)