burme-coder-max / scripts /create_github_workflows.py
amkyawdev's picture
Upload folder using huggingface_hub
40fd3fa verified
"""GitHub Actions CI/CD Workflow
.place workflows in .github/workflows/
"""
import yaml
from pathlib import Path
workflow_content = """name: CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
release:
types: [published]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Check syntax
run: python -m py_compile $(find src -name "*.py")
- name: Run linters
run: |
pip install black mypy ruff
black --check src/ tests/
ruff check src/
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run tests
run: pytest tests/ -v --tb=short
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: pip install -e ".[dev]"
- name: Run QA tests
run: python scripts/automation.py quality
- name: Check documentation
run: |
python scripts/automation.py validate-data
deploy:
needs: [lint, test, quality]
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install build tools
run: pip install build twine
- name: Build package
run: python -m build
- name: Upload to PyRI
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload dist/* --token $PYPI_TOKEN
huggingface:
needs: [lint, test]
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install huggingface_hub
run: pip install huggingface_hub
- name: Upload to HuggingFace
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: python scripts/automation.py deploy --token $HF_TOKEN
"""
def create_github_workflows():
"""Create GitHub Actions workflow files."""
workflows_dir = Path(".github/workflows")
workflows_dir.mkdir(parents=True, exist_ok=True)
# CI workflow
ci_workflow = workflows_dir / "ci.yml"
ci_workflow.write_text(workflow_content, encoding="utf-8")
print(f"✅ Created {ci_workflow}")
if __name__ == "__main__":
create_github_workflows()
print("📁 GitHub workflows created in .github/workflows/")