Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
67 changes: 67 additions & 0 deletions .github/workflows/validate-deployments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Lint DGD

on:
pull_request:
paths:
- 'recipes/**/*.yaml'
- 'recipes/**/*.yml'
- 'examples/**/*.yaml'
- 'examples/**/*.yml'
- 'deploy/utils/validate_deployments.py'
- 'deploy/cloud/operator/config/crd/bases/nvidia.com_dynamographdeployments.yaml'
push:
branches:
- main
paths:
- 'recipes/**/*.yaml'
- 'recipes/**/*.yml'
- 'examples/**/*.yaml'
- 'examples/**/*.yml'
- 'deploy/utils/validate_deployments.py'
- 'deploy/cloud/operator/config/crd/bases/nvidia.com_dynamographdeployments.yaml'

jobs:
validate:
name: Validate DynamoGraphDeployment YAMLs
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyyaml jsonschema

- name: Validate deploy.yaml files
run: |
python3 deploy/utils/validate_deployments.py --verbose

- name: Summary
if: success()
run: |
echo "✅ All deploy.yaml files are valid against the CRD schema!"

11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,14 @@ repos:
# NOTE: pyright may be able to find other classes of errors not covered above,
# but would require some configuring and venv setup to properly eliminate noise
# and give it visiblity into all the local and third_party packages expected.

# Validate DynamoGraphDeployment YAML files
- repo: local
hooks:
- id: validate-deploy-yaml
name: Validate DynamoGraphDeployment YAMLs
entry: python3 deploy/utils/validate_deployments.py
language: python
files: '(recipes|examples|tests|deploy)/.*\.(yaml|yml)$'
pass_filenames: true
additional_dependencies: [pyyaml, jsonschema]
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ metadata:
app.kubernetes.io/managed-by: kustomize
name: dynamographdeployment-sample
spec:
services:
Frontend:
dynamoNamespace: agg
VllmDecodeWorker:
dynamoNamespace: agg
# TODO(user): Add fields here
# EXAMPLE: dynamoComponent: basic:dev
95 changes: 95 additions & 0 deletions deploy/utils/README_VALIDATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Deploy YAML Validation

Validates `deploy.yaml` files against the DynamoGraphDeployment CRD schema without requiring kubectl or a Kubernetes cluster.

## Features

- **Dynamic validation** from the CRD OpenAPI v3 schema - adapts automatically when the schema changes
- **Schema validation**: Types, enums, required fields, constraints
- **Structural linting**: Detects indentation errors and misplaced properties
- **Line numbers**: Pinpoints exact locations of schema violations

## Quick Start

```bash
# Install dependencies
pip install pyyaml jsonschema

# Validate all deploy files
python3 deploy/utils/validate_deployments.py

# Validate specific files
python3 deploy/utils/validate_deployments.py recipes/*/deploy.yaml

# Verbose output
python3 deploy/utils/validate_deployments.py --verbose
```

## Integration

### Pre-commit Hook

Automatically validates on commit:

```bash
pre-commit install
pre-commit run validate-deploy-yaml --all-files
```

### CI Workflow

Runs on every PR via `.github/workflows/validate-deployments.yml`.

## Example Output

**Valid files:**
```
✅ recipes/qwen3-32b-fp8/trtllm/agg/deploy.yaml: Valid
✅ All 2 file(s) are valid!
```

**Validation errors:**
```
❌ recipes/example/deploy.yaml: 3 error(s)
- Line 8: spec.backendFramework: value 'invalid' must be one of: 'sglang', 'vllm', 'trtllm'
- Line 26: spec.services.Frontend.replicas: expected type 'integer', got 'str'
- spec.services.Worker.unknownField: unexpected property 'unknownField' (not defined in schema - check indentation)
```

## How It Works

1. Extracts OpenAPI v3 schema from the CRD:
```
deploy/cloud/operator/config/crd/bases/nvidia.com_dynamographdeployments.yaml
```
2. Validates using JSON Schema (Draft 7)
3. Performs additional structural checks for indentation errors

## Schema Updates

When the CRD schema changes (via kubebuilder annotations), validation automatically adapts:

```bash
cd deploy/cloud/operator
make manifests # Regenerate CRD
```

No code changes needed in the validator!

## Troubleshooting

**Missing dependencies:**
```bash
pip install pyyaml jsonschema
```

**CRD not found:**
```bash
python3 deploy/utils/validate_deployments.py --crd path/to/crd.yaml
```

**Pre-commit not running:**
```bash
pip install pre-commit
pre-commit install
```
Loading
Loading