Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 89b1c71e99 | |||
| 769dceca62 | |||
| c74330f33d | |||
| c136fc7f20 | |||
| 7c5d566d58 | |||
| 84c474a56e |
@@ -21,18 +21,28 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
pip install -e ".[dev]"
|
pip install -e ".[dev]"
|
||||||
|
|
||||||
- name: Run unit tests
|
- name: Run linting
|
||||||
run: pytest tests/unit/ -v
|
run: ruff check envschema/
|
||||||
|
|
||||||
- name: Run integration tests
|
- name: Run tests
|
||||||
run: pytest tests/integration/ -v
|
run: pytest tests/ -v
|
||||||
|
|
||||||
- name: Check code formatting
|
build:
|
||||||
run: |
|
runs-on: ubuntu-latest
|
||||||
pip install ruff
|
needs: test
|
||||||
ruff check envschema/
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Upload coverage
|
- name: Set up Python
|
||||||
run: |
|
uses: actions/setup-python@v5
|
||||||
pip install pytest-cov
|
with:
|
||||||
pytest --cov=envschema --cov-report=term-missing
|
python-version: '3.11'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pip install -e .
|
||||||
|
|
||||||
|
- name: Verify import
|
||||||
|
run: python -c "import envschema; print(envschema.__version__)"
|
||||||
|
|
||||||
|
- name: Verify CLI
|
||||||
|
run: envschema --version
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
"""CLI interface for EnvSchema."""
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from envschema import __version__
|
from envschema import __version__
|
||||||
from envschema.schema import load_schema_from_file, Schema
|
from envschema.schema import load_schema_from_file
|
||||||
from envschema.core import validate_environment
|
from envschema.core import validate_environment
|
||||||
from envschema.generator import generate_env_example_to_file
|
from envschema.generator import generate_env_example_to_file
|
||||||
from envschema.formatters import format_result
|
from envschema.formatters import format_result
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from envschema.schema import Schema, EnvVar
|
from envschema.schema import Schema
|
||||||
from envschema.loader import EnvLoader
|
from envschema.loader import EnvLoader
|
||||||
from envschema.validators import validate_value
|
from envschema.validators import validate_value
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"""Output formatters for validation results."""
|
"""Output formatters for validation results."""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from envschema.core import ValidationResult
|
from envschema.core import ValidationResult
|
||||||
|
|
||||||
|
|||||||
@@ -25,13 +25,10 @@ def generate_env_example(schema: Schema, include_descriptions: bool = True) -> s
|
|||||||
lines.append(f"# {var.description}")
|
lines.append(f"# {var.description}")
|
||||||
|
|
||||||
if var.required:
|
if var.required:
|
||||||
lines.append(f"# REQUIRED")
|
lines.append("# REQUIRED")
|
||||||
elif var.default is not None:
|
elif var.default is not None:
|
||||||
lines.append(f"# Default: {var.default}")
|
lines.append(f"# Default: {var.default}")
|
||||||
|
|
||||||
default_part = f"# {var.default}" if var.default else ""
|
|
||||||
type_part = f"[{var.type.value}]"
|
|
||||||
|
|
||||||
if var.required:
|
if var.required:
|
||||||
lines.append(f"{var.name}=")
|
lines.append(f"{var.name}=")
|
||||||
elif var.default is not None:
|
elif var.default is not None:
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class IntegerValidator:
|
|||||||
return True, None
|
return True, None
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False, ValidationError(
|
return False, ValidationError(
|
||||||
f"Invalid integer value",
|
"Invalid integer value",
|
||||||
value=value
|
value=value
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ class BooleanValidator:
|
|||||||
if value_lower in BooleanValidator.FALSE_VALUES:
|
if value_lower in BooleanValidator.FALSE_VALUES:
|
||||||
return True, None
|
return True, None
|
||||||
return False, ValidationError(
|
return False, ValidationError(
|
||||||
f"Invalid boolean value (expected: true, false, 1, 0, yes, no, on, off)",
|
"Invalid boolean value (expected: true, false, 1, 0, yes, no, on, off)",
|
||||||
value=value
|
value=value
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ class ListValidator:
|
|||||||
if "," in value:
|
if "," in value:
|
||||||
return True, None
|
return True, None
|
||||||
return False, ValidationError(
|
return False, ValidationError(
|
||||||
f"Invalid list value (expected comma-separated values)",
|
"Invalid list value (expected comma-separated values)",
|
||||||
value=value
|
value=value
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user