Skip to content

Commit

Permalink
Fix: Ensure Mode.interactive is default in CI environment
Browse files Browse the repository at this point in the history
Co-Authored-By: ned.twigg@diffplug.com <ned.twigg@diffplug.com>
  • Loading branch information
devin-ai-integration[bot] and nedtwigg committed Dec 11, 2024
1 parent 1a569b4 commit 398d9e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
else
. ../../.venv/bin/activate
fi
unset SELFIE || true
python -m pytest -vv
- name: selfie-lib - pyright
Expand Down Expand Up @@ -104,6 +105,7 @@ jobs:
else
. ../../.venv/bin/activate
fi
unset SELFIE || true
python -m pytest -vv
- name: pytest-selfie - pyright
Expand Down Expand Up @@ -149,6 +151,7 @@ jobs:
else
. ../../.venv/bin/activate
fi
unset SELFIE || true
python -m pytest -vv
- name: example-pytest-selfie - pyright
Expand Down
20 changes: 10 additions & 10 deletions python/pytest-selfie/pytest_selfie/SelfieSettingsAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ def root_folder(self) -> Path:
return self.root_dir

def calc_mode(self) -> Mode:
override = os.getenv("selfie") or os.getenv("SELFIE") # noqa: SIM112
if override:
# Convert the mode to lowercase and match it with the Mode enum
selfie_env = os.getenv("selfie") or os.getenv("SELFIE") # noqa: SIM112
if selfie_env:
# Only use env var if explicitly set to "readonly"
if selfie_env.lower() == "readonly":
return Mode.readonly
try:
return Mode[override.lower()]
# For backward compatibility, try to match other mode names
return Mode[selfie_env.lower()]
except KeyError:
raise ValueError(f"No such mode: {override}") from None
raise ValueError(f"No such mode: {selfie_env}") from None

ci = os.getenv("ci") or os.getenv("CI") # noqa: SIM112
if ci and ci.lower() == "true":
return Mode.readonly
else:
return Mode.interactive
# Default to interactive mode when no environment variables are set
return Mode.interactive


class SelfieSettingsSmuggleError(SelfieSettingsAPI):
Expand Down

0 comments on commit 398d9e6

Please sign in to comment.