Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Build and Publish

on:
push:
tags:
- 'v*'
release:
types: [published]

jobs:
build:
name: Build Package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"

- name: Install build dependencies
run: |
uv sync --dev

- name: Build package
run: |
uv run build

- name: Check package
run: |
uv run twine check dist/*

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

test-install:
name: Test Package Installation
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.14"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Install package
run: |
python -m pip install --upgrade pip
pip install dist/*.whl

- name: Test import
run: |
python -c "import dify_client; print('Package imported successfully')"

publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build, test-install]
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
125 changes: 125 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: CI

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]

jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.14"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"

- name: Install dependencies
run: |
uv sync --dev

- name: Run ruff (linting)
run: |
uv run ruff check dify_client tests

- name: Run black (check formatting)
run: |
uv run black --check dify_client tests

- name: Run isort (check import sorting)
run: |
uv run isort --check-only dify_client tests

- name: Run mypy (type checking)
run: |
uv run mypy dify_client

- name: Compile Python files (syntax check)
run: |
uv run python -m py_compile $(find dify_client -name "*.py") $(find tests -name "*.py")

test:
name: Test Code
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.14"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"

- name: Install dependencies
run: |
uv sync --dev

- name: Run tests with pytest
run: |
uv run pytest -v --cov=dify_client --cov-report=xml --cov-report=html

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

security:
name: Security Scan
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"

- name: Install dependencies
run: |
uv sync --dev

- name: Run bandit security linter
run: |
uv run bandit -r dify_client -f json -o bandit-report.json


- name: Upload security reports
uses: actions/upload-artifact@v4
if: always()
with:
name: security-reports
path: |
bandit-report.json
56 changes: 56 additions & 0 deletions .github/workflows/dependency-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Dependency Update

on:
schedule:
# Run every Monday at 9:00 AM UTC
- cron: '0 9 * * 1'
workflow_dispatch:

jobs:
update-dependencies:
name: Update Dependencies
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"

- name: Update dependencies
run: |
uv sync --dev
uv pip list --outdated

- name: Run tests after update
run: |
uv run pytest -v

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: update dependencies"
title: "Automated Dependency Update"
body: |
## Automated Dependency Update

This PR updates the project dependencies to their latest versions.

### Changes Made
- Updated Python dependencies using `uv sync`
- All tests are passing after the update

Please review the changes and ensure everything looks correct before merging.
branch: dependency-update
delete-branch: true
50 changes: 50 additions & 0 deletions .github/workflows/quick-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Quick Check

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
quick-check:
name: Quick Check
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"

- name: Install dependencies
run: |
uv sync --dev

- name: Quick syntax check
run: |
find dify_client tests -name "*.py" -exec uv run python -m py_compile {} \;

- name: Check import sorting
run: |
uv run isort --check-only dify_client tests

- name: Run quick tests
run: |
uv run pytest tests/ -x --tb=short

- name: Basic import test
run: |
uv run python -c "
import dify_client
from dify_client import CompletionClient, ChatClient, AsyncCompletionClient, AsyncChatClient
print('All imports successful')
"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,4 @@ cython_debug/
marimo/_static/
marimo/_lsp/
__marimo__/
.idea
Loading