Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/fastapi_cloud_cli/commands/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def _should_exclude_entry(path: Path) -> bool:
if path.suffix == ".pyc":
return True

if path.name == ".env" or path.name.startswith(".env."):
return True

return False


Expand Down
6 changes: 3 additions & 3 deletions tests/test_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,13 @@ def test_archive_respects_fastapicloudignore_unignore(
}


def test_archive_includes_hidden_files(
def test_archive_includes_hidden_files_but_excludes_env(
src_path: Path, tar_path: Path, dst_path: Path
) -> None:
"""Should include hidden files in the archive by default."""
"""Should include hidden files but exclude .env files."""
(src_path / "main.py").write_text("print('hello')")
(src_path / ".env").write_text("SECRET_KEY=xyz")
(src_path / ".env.local").write_text("LOCAL_KEY=abc")
(src_path / ".config").mkdir()
(src_path / ".config" / "settings.json").write_text('{"setting": "value"}')

Expand All @@ -159,7 +160,6 @@ def test_archive_includes_hidden_files(

assert set(dst_path.glob("**/*")) == {
dst_path / "main.py",
dst_path / ".env",
dst_path / ".config",
dst_path / ".config" / "settings.json",
}
7 changes: 7 additions & 0 deletions tests/test_deploy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
Path(".venv"),
Path("__pycache__"),
Path("module.pyc"),
Path("/project/.env"),
Path("/project/.env.local"),
Path("/project/.env.production"),
Path(".env"),
Path(".env.development"),
],
)
def test_excludes_paths(path: Path) -> None:
Expand All @@ -37,6 +42,8 @@ def test_excludes_paths(path: Path) -> None:
Path("/project/src/module.pyx"), # similar to .pyc but different
Path("/project/config.json"),
Path("/project/README.md"),
Path("/project/.envrc"), # not a .env file
Path("/project/env.py"), # not a .env file
],
)
def test_includes_paths(path: Path) -> None:
Expand Down