YAML Lint Workflow Guide
📝 YAML File Validation
The YAML Lint workflow validates YAML files in your repository using yamllint to ensure proper formatting and syntax. This is a reusable workflow that can be called from other repositories.
📋 Table of Contents
🎯 Overview
Purpose: YAML file validation and formatting Key Features:
- yamllint integration
- Configurable rules
- Flexible path specification
- Exclude patterns support
- Strict mode option
- Detailed reporting
Use Case: YAML file quality and consistency enforcement
⚙️ Inputs
📁 File Selection
| Input | Description | Required | Default | Type |
|---|---|---|---|---|
paths |
Comma-separated list of paths to check | No | **/*.yml,**/*.yaml |
string |
exclude_patterns |
Comma-separated patterns to exclude | No | .git/**,node_modules/**,venv/**,.venv/** |
string |
⚙️ Configuration
| Input | Description | Required | Default | Type |
|---|---|---|---|---|
config_file |
Path to yamllint configuration file | No | .yamllint |
string |
strict_mode |
Enable strict mode (fail on warnings) | No | false |
boolean |
📤 Outputs
| Output | Description |
|---|---|
result |
YAML lint result (success/failure) |
files_checked |
Number of files checked |
issues_found |
Number of issues found |
🚀 Usage Examples
Basic Usage
1
2
3
4
5
name: YAML Lint
on: [push, pull_request]
jobs:
yamllint:
uses: N3b3x/hf-general-ci-tools/.github/workflows/yamllint-reusable.yml@v1
Advanced Usage
1
2
3
4
5
6
7
8
9
10
name: YAML Lint
on: [push, pull_request]
jobs:
yamllint:
uses: N3b3x/hf-general-ci-tools/.github/workflows/yamllint-reusable.yml@v1
with:
paths: '.github/workflows/*.yml,docs/*.yml'
config_file: '.yamllint'
strict_mode: true
exclude_patterns: '.git/**,node_modules/**,_site/**'
Workflow-Only Checking
1
2
3
4
5
6
7
8
name: Workflow YAML Lint
on: [push, pull_request]
jobs:
yamllint:
uses: N3b3x/hf-general-ci-tools/.github/workflows/yamllint-reusable.yml@v1
with:
paths: '.github/workflows/*.yml'
strict_mode: true
Comprehensive Configuration
1
2
3
4
5
6
7
8
9
10
name: Complete YAML Lint
on: [push, pull_request]
jobs:
yamllint:
uses: N3b3x/hf-general-ci-tools/.github/workflows/yamllint-reusable.yml@v1
with:
paths: '.github/workflows/*.yml,docs/*.yml,**/*.yaml'
config_file: '.yamllint'
strict_mode: true
exclude_patterns: '.git/**,node_modules/**,venv/**,.venv/**,_site/**'
⚙️ Configuration
.yamllint Configuration
Create a .yamllint file in your project root:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
extends: default
rules:
line-length:
max: 120
level: warning
indentation:
spaces: 2
comments:
min-spaces-from-content: 1
document-start:
present: true
truthy:
allowed-values: ['true', 'false', 'on', 'off']
Default Rules
The workflow uses yamllint with these default settings:
- Line length: 120 characters (warning)
- Indentation: 2 spaces
- Document start: Required
- Comments: Proper spacing
🔧 Troubleshooting
Common Issues
YAML Syntax Errors
- Check for proper indentation (2 spaces)
- Verify YAML syntax is valid
- Ensure proper document structure
Line Length Issues
- Adjust line length in
.yamllintconfiguration - Break long lines appropriately
- Use YAML’s line continuation features
Indentation Problems
- Use consistent 2-space indentation
- Avoid mixing tabs and spaces
- Check for proper nesting
Debug Mode
Enable debug output by checking the workflow logs in GitHub Actions.
📚 Related Workflows
- C/C++ Lint - Code quality checks
- Static Analysis - Security analysis
- Documentation - Documentation generation