File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -139,11 +139,9 @@ jobs:
139139 - name : Run backend tests with coverage
140140 env :
141141 BACKEND_BASE_URL : https://127.0.0.1:443
142- MONGODB_URL : mongodb://${{ secrets.MONGO_ROOT_USER }}:${{ secrets.MONGO_ROOT_PASSWORD }}@127.0.0.1:27017/?authSource=admin
143142 run : |
144143 cd backend
145144 echo "Using BACKEND_BASE_URL=$BACKEND_BASE_URL"
146- echo "Using MONGODB_URL=$MONGODB_URL"
147145 python -m pytest tests/integration tests/unit -v --cov=app --cov-branch --cov-report=xml --cov-report=term --cov-report=term-missing
148146
149147 - name : Upload coverage to Codecov
Original file line number Diff line number Diff line change 4444os .environ .setdefault ("OTEL_TRACES_EXPORTER" , "none" )
4545
4646# Force localhost endpoints to avoid Docker DNS names like 'mongo'
47- os .environ .setdefault ("MONGODB_URL" , "mongodb://root:rootpassword@localhost:27017/?authSource=admin" )
47+ # Do not override if MONGODB_URL is already provided in the environment.
48+ if "MONGODB_URL" not in os .environ :
49+ from urllib .parse import quote_plus
50+ user = os .environ .get ("MONGO_ROOT_USER" , "root" )
51+ pwd = os .environ .get ("MONGO_ROOT_PASSWORD" , "rootpassword" )
52+ host = os .environ .get ("MONGODB_HOST" , "127.0.0.1" )
53+ port = os .environ .get ("MONGODB_PORT" , "27017" )
54+ try :
55+ u = quote_plus (user )
56+ p = quote_plus (pwd )
57+ except Exception :
58+ u = user
59+ p = pwd
60+ os .environ ["MONGODB_URL" ] = f"mongodb://{ u } :{ p } @{ host } :{ port } /?authSource=admin"
4861os .environ .setdefault ("KAFKA_BOOTSTRAP_SERVERS" , "localhost:9092" )
4962os .environ .setdefault ("REDIS_HOST" , "localhost" )
5063os .environ .setdefault ("REDIS_PORT" , "6379" )
You can’t perform that action at this time.
0 commit comments