Initial release: - Complete async API client (45+ endpoints) - Pydantic models for all responses - Two-step authentication - Comprehensive error handling - 92% test coverage - Gitea Actions CI/CD - Semantic release configured
157 lines
3.6 KiB
YAML
157 lines
3.6 KiB
YAML
name: CI/CD Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches: [main, master]
|
|
tags: ['v*']
|
|
pull_request:
|
|
branches: [main, master]
|
|
|
|
env:
|
|
PYTHON_VERSION: '3.12'
|
|
|
|
jobs:
|
|
test:
|
|
name: Tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install UV
|
|
uses: astral-sh/setup-uv@v3
|
|
with:
|
|
version: "latest"
|
|
enable-cache: true
|
|
|
|
- name: Set up Python
|
|
run: uv python install ${{ env.PYTHON_VERSION }}
|
|
|
|
- name: Install dependencies
|
|
run: uv sync --frozen --dev
|
|
|
|
- name: Run linters
|
|
run: uv run ruff check src/ tests/
|
|
|
|
- name: Run tests
|
|
run: uv run pytest --cov=kwork_api --cov-report=xml
|
|
|
|
- name: Upload coverage
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
files: ./coverage.xml
|
|
fail_ci_if_error: false
|
|
|
|
build:
|
|
name: Build
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install UV
|
|
uses: astral-sh/setup-uv@v3
|
|
with:
|
|
version: "latest"
|
|
|
|
- name: Set up Python
|
|
run: uv python install ${{ env.PYTHON_VERSION }}
|
|
|
|
- name: Build package
|
|
run: uv build
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: dist
|
|
path: dist/
|
|
|
|
release:
|
|
name: Semantic Release
|
|
runs-on: ubuntu-latest
|
|
needs: [test, build, docs]
|
|
if: github.ref == 'refs/heads/main'
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install UV
|
|
uses: astral-sh/setup-uv@v3
|
|
with:
|
|
version: "latest"
|
|
|
|
- name: Set up Python
|
|
run: uv python install ${{ env.PYTHON_VERSION }}
|
|
|
|
- name: Install dependencies
|
|
run: uv sync --frozen --dev
|
|
|
|
- name: Run semantic-release
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
uv run semantic-release version --push --no-mock
|
|
|
|
publish:
|
|
name: Publish to Gitea Registry
|
|
runs-on: ubuntu-latest
|
|
needs: release
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
permissions:
|
|
packages: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: dist
|
|
path: dist/
|
|
|
|
- name: Install UV
|
|
uses: astral-sh/setup-uv@v3
|
|
with:
|
|
version: "latest"
|
|
|
|
- name: Publish to Gitea
|
|
env:
|
|
UV_PUBLISH_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
uv publish \
|
|
--publish-url https://git.much-data.ru/api/packages/claw/pypi \
|
|
--token $UV_PUBLISH_TOKEN
|
|
|
|
docs:
|
|
name: Build & Deploy Documentation
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install UV
|
|
uses: astral-sh/setup-uv@v3
|
|
with:
|
|
version: "latest"
|
|
|
|
- name: Set up Python
|
|
run: uv python install ${{ env.PYTHON_VERSION }}
|
|
|
|
- name: Install dependencies
|
|
run: uv sync --frozen --dev
|
|
|
|
- name: Build docs
|
|
run: uv run mkdocs build
|
|
|
|
- name: Deploy to Gitea Pages
|
|
if: github.ref == 'refs/heads/main'
|
|
uses: peaceiris/actions-gh-pages@v4
|
|
with:
|
|
gitea_token: ${{ secrets.GITEA_TOKEN }}
|
|
gitea_server_url: https://git.much-data.ru
|
|
publish_dir: ./site
|
|
publish_branch: gh-pages
|
|
force_orphan: true
|