Loading...
Loading...
Set up GitHub Actions workflows for CI/CD with automated testing, linting, and deployment for Python/UV projects. Use when creating CI pipelines, automating tests, or setting up deployment workflows.
npx skill4agent add autumnsgrove/groveengine cicd-automation.github/workflows/ci.ymlname: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install UV
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Add UV to PATH
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install dependencies
run: uv sync
- name: Run tests
run: uv run pytest tests/ -v --cov=src
- name: Lint with Ruff
run: uv run ruff check src/ tests/
- name: Check formatting
run: uv run black --check src/ tests/.github/
└── workflows/
├── ci.yml # Tests and linting
├── release.yml # Package publishing
└── deploy.yml # Deployment# Every push and PR
on: [push, pull_request]
# Specific branches
on:
push:
branches: [main]
pull_request:
branches: [main]
# Manual trigger
on: workflow_dispatch
# Scheduled (cron)
on:
schedule:
- cron: '0 0 * * *' # Daily at midnight- name: Run tests with coverage
run: |
uv run pytest tests/ \
--cov=src \
--cov-report=xml \
--cov-report=term-missing \
--junitxml=junit.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
fail_ci_if_error: truejobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install UV
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Run tests
run: uv run pytest tests/- name: Cache UV dependencies
uses: actions/cache@v3
with:
path: |
~/.cache/uv
.venv
key: ${{ runner.os }}-uv-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-uv-
- name: Install dependencies
run: uv sync- name: Deploy
env:
API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: uv run python deploy.pyname: Publish
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install UV
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Build package
run: uv build
- name: Publish to PyPI
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: uv publish --token $UV_PUBLISH_TOKEN- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: user/app:latest,user/app:${{ github.sha }}
[](https://codecov.io/gh/username/repo)AgentUsage/ci_cd_patterns.md