Skip to content

Commit e02c807

Browse files
committed
- Add codecov.yaml
- Mock out XSD retrieval from omg.org to prevent DOSing the schema server when testing - Add caching mechanism for XSD retrievals during validation - Clean up CLI handling of common error
1 parent d50a2f0 commit e02c807

11 files changed

Lines changed: 6411 additions & 109 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@ USER $USERNAME
9292

9393
# Copy CLAUDE.md and settings to Claude config directory
9494
COPY CLAUDE.md /home/$USERNAME/.claude/
95-
COPY claude-settings.json /home/$USERNAME/.claude/.claude.json
95+
COPY claude-settings.json /home/$USERNAME/.claude/settings.json

.devcontainer/claude-settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"model": "sonnet",
23
"autoUpdates": true,
34
"hasCompletedOnboarding": false,
45
"shiftEnterKeyBindingInstalled": true,

.devcontainer/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@
2727
"github.copilot",
2828
"github.copilot-chat",
2929
"anthropic.claude-code",
30-
"GitHub.vscode-pull-request-github"
30+
"GitHub.vscode-pull-request-github",
31+
"github.vscode-github-actions"
3132
],
3233
"settings": {
3334
"dev.containers.copyGitConfig": true,
3435
"python.terminal.activateEnvironment": false,
3536
"python-envs.terminal.autoActivationType": "off",
3637
"python.defaultInterpreterPath": "python",
38+
"python.REPL.enableREPLSmartSend": false,
3739
"python.testing.pytestEnabled": true,
3840
"python.testing.unittestEnabled": false,
3941
"python.testing.pytestArgs": [

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ Thumbs.db
6060
.idea
6161
.project
6262
.run
63+
.vscode
64+
core
65+
# Sometimes devcontainers create a core dump file when restarting
6366

6467
# Virtual environment #
6568
#######################

codecov.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Codecov configuration for space_packet_parser
2+
# https://docs.codecov.com/docs/codecovyml-reference
3+
4+
coverage:
5+
status:
6+
project:
7+
default:
8+
target: 95% # Target coverage percentage
9+
threshold: 5% # Allow 5% drop without failing
10+
if_no_uploads: error # Fail if no coverage data
11+
only_pulls: false # Check coverage on all commits
12+
patch:
13+
default:
14+
target: 85% # Lower threshold for new code
15+
threshold: 5%
16+
only_pulls: true # Only check patch coverage on PRs
17+
18+
ignore:
19+
- "tests/**/*" # Don't include test files in coverage
20+
- "scripts/**/*" # Don't include utility scripts
21+
- "examples/**/*" # Don't include examples
22+
- "docs/**/*" # Don't include documentation
23+
- "**/__init__.py" # Ignore init files
24+
- "**/conftest.py" # Ignore pytest configuration

docs/source/users.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ This equation can be implemented in XTCE by referencing the packet length field
378378

379379
## XTCE Document Validation
380380

381-
Space Packet Parser provides comprehensive validation capabilities for XTCE documents to help ensure they are correct and will work properly for parsing packets. The validation system operates in two modes:
381+
Space Packet Parser provides comprehensive validation capabilities for XTCE documents to help ensure they are correct and will work properly for parsing packets. The validation system operates in three modes: "schema", "structure", and a default mode of "all" (both schema and structure validation).
382382

383383
- **Schema Validation**: Validates the XML document against the in-document referenced XTCE XSD schema
384384
- **Structural Validation**: Validates XTCE-specific structure and reference integrity
@@ -394,7 +394,13 @@ e.g.
394394
https://www.omg.org/spec/XTCE/20180204/SpaceSystem.xsd">
395395
```
396396

397-
### Basic Validation Usage
397+
### CLI Validation
398+
399+
```shell
400+
spp --log-level=DEBUG validate my_xtce.xml --local-schema my_xsd.xml --level all
401+
```
402+
403+
### Programmatic Validation
398404

399405
```python
400406
from space_packet_parser import validate_xtce

space_packet_parser/cli.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,24 @@ def parse(
220220
help="Validation level to perform",
221221
)
222222
@click.option("--timeout", type=int, default=30, help="Timeout in seconds for schema downloads")
223-
def validate(file_path: Path, level: str, timeout: int) -> None:
223+
@click.option("--local-xsd", type=click.Path(exists=True, path_type=Path), help="Local XSD file for schema validation")
224+
def validate(file_path: Path, level: str, timeout: int, local_xsd: Path) -> None:
224225
"""Validate an XTCE document."""
225-
logging.debug(f"Validating XTCE file: {file_path}")
226-
logging.debug(f"Validation level: {level}")
227-
228-
result = validate_xtce(file_path, level=level.lower(), timeout=timeout)
226+
logging.info(f"Validating XTCE file: {file_path}")
227+
logging.info(f"Validation level: {level}")
228+
logging.debug(f"Timeout: {timeout}")
229+
logging.debug(f"Local XSD: {local_xsd}")
230+
231+
result = validate_xtce(
232+
file_path,
233+
level=level.lower(),
234+
timeout=timeout,
235+
print_results=False,
236+
raise_on_error=False,
237+
local_xsd=local_xsd,
238+
)
229239

240+
# Display results in rich format (complementing the print_results from validate_xtce)
230241
if result.valid:
231242
console.print(f"[bold green]✓ VALID[/bold green] ({result.validation_level.value} level)")
232243
else:
@@ -244,7 +255,9 @@ def validate(file_path: Path, level: str, timeout: int) -> None:
244255
console.print(f"\n[bold red]Errors ({len(result.errors)}):[/bold red]")
245256
for error in result.errors:
246257
console.print(f" {error}")
258+
if error.context:
259+
console.print(f" - Additional context: {error.context}")
247260

248-
# Exit with error code if validation failed
261+
# Exit with error code if validation failed (unless raise_on_error is True, which already raised)
249262
if not result.valid:
250263
raise click.ClickException("Validation failed")

0 commit comments

Comments
 (0)