Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:00:18 +08:00
commit 765529cd13
69 changed files with 18291 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
# CI/CD Integration for UV Scripts
> **Status**: 🚧 Placeholder - Content in development
## Overview
Integrating UV single-file scripts into CI/CD pipelines with GitHub Actions, GitLab CI, and other platforms.
## Topics to Cover
- [ ] GitHub Actions workflows
- [ ] GitLab CI configuration
- [ ] Pre-commit hooks integration
- [ ] Automated testing
- [ ] Security scanning
- [ ] Deployment strategies
- [ ] Version management
## Quick Example
### GitHub Actions
```yaml
name: Test UV Scripts
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Run script tests
run: |
uv run scripts/check_health.py --validate
uv run scripts/analyze_data.py --dry-run
```
### Pre-commit Hook
```yaml
# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: validate-uv-scripts
name: Validate UV Scripts
entry: uv run scripts/validate_all.py
language: system
pass_filenames: false
```
## TODO
This file will be expanded to include:
- Complete GitHub Actions examples
- GitLab CI patterns
- Pre-commit hook configurations
- Automated deployment workflows
- Security scanning integration

View File

@@ -0,0 +1,58 @@
# Team Adoption Guide
> **Status**: 🚧 Placeholder - Content in development
## Overview
Guide for rolling out UV single-file scripts across development teams, establishing standards, and ensuring adoption.
## Topics to Cover
- [ ] Introduction and training materials
- [ ] Team standards and conventions
- [ ] Code review guidelines
- [ ] Migration from existing scripts
- [ ] Tooling setup across platforms
- [ ] Documentation requirements
- [ ] Success metrics and tracking
## Adoption Roadmap
### Phase 1: Pilot (Week 1-2)
- Select 2-3 team members for initial trial
- Convert 3-5 existing scripts
- Gather feedback and iterate
### Phase 2: Expansion (Week 3-4)
- Team-wide training session
- Establish coding standards
- Set up CI/CD integration
- Create internal documentation
### Phase 3: Full Adoption (Week 5+)
- All new scripts use UV format
- Migration plan for legacy scripts
- Regular reviews and improvements
## Team Standards Checklist
- [ ] Required shebang format: `#!/usr/bin/env -S uv run`
- [ ] Minimum Python version: `>=3.11`
- [ ] Required metadata fields
- [ ] Naming conventions
- [ ] Documentation requirements
- [ ] Testing requirements
- [ ] Security review process
## TODO
This file will be expanded to include:
- Detailed training materials
- Complete adoption roadmap
- Team communication templates
- Migration guides
- Success stories and case studies

View File

@@ -0,0 +1,72 @@
# Testing Strategies for UV Scripts
> **Status**: 🚧 Placeholder - Content in development
## Overview
Strategies for testing UV single-file scripts, from inline tests to pytest integration.
## Topics to Cover
- [ ] Inline test functions
- [ ] pytest integration
- [ ] Mock and fixtures for testing
- [ ] Testing CLI applications
- [ ] API client testing with mocks
- [ ] Coverage reporting
- [ ] Test automation in CI/CD
## Quick Example
### Inline Testing
```python
#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.11"
# ///
def add(a: int, b: int) -> int:
return a + b
def test_add():
assert add(2, 3) == 5
assert add(-1, 1) == 0
print("✓ All tests passed")
if __name__ == "__main__":
# Run tests
test_add()
# Or run main application
result = add(10, 20)
print(f"Result: {result}")
```
### Pytest Integration
```python
#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.11"
# dependencies = ["pytest>=7.0.0"]
# ///
"""
Run with: pytest this_script.py
"""
def multiply(a: int, b: int) -> int:
return a * b
def test_multiply():
assert multiply(2, 3) == 6
assert multiply(-1, 5) == -5
```
## TODO
This file will be expanded to include:
- Complete testing patterns
- Mocking external dependencies
- Test organization strategies
- CI/CD integration examples
- Coverage tools and reporting