Skip to content

Commit a3ce501

Browse files
authored
Merge pull request #1 from fatelei/main
first commit
2 parents 734c467 + de44901 commit a3ce501

26 files changed

Lines changed: 10033 additions & 203 deletions

.github/workflows/build.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Build and Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
release:
8+
types: [published]
9+
10+
jobs:
11+
build:
12+
name: Build Package
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: "3.11"
22+
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v3
25+
with:
26+
enable-cache: true
27+
cache-dependency-glob: "pyproject.toml"
28+
29+
- name: Install build dependencies
30+
run: |
31+
uv sync --dev
32+
33+
- name: Build package
34+
run: |
35+
uv run build
36+
37+
- name: Check package
38+
run: |
39+
uv run twine check dist/*
40+
41+
- name: Upload build artifacts
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: dist
45+
path: dist/
46+
47+
test-install:
48+
name: Test Package Installation
49+
runs-on: ubuntu-latest
50+
needs: build
51+
strategy:
52+
matrix:
53+
python-version: ["3.10", "3.11", "3.12", "3.14"]
54+
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Set up Python ${{ matrix.python-version }}
59+
uses: actions/setup-python@v4
60+
with:
61+
python-version: ${{ matrix.python-version }}
62+
63+
- name: Download build artifacts
64+
uses: actions/download-artifact@v4
65+
with:
66+
name: dist
67+
path: dist/
68+
69+
- name: Install package
70+
run: |
71+
python -m pip install --upgrade pip
72+
pip install dist/*.whl
73+
74+
- name: Test import
75+
run: |
76+
python -c "import dify_client; print('Package imported successfully')"
77+
78+
publish:
79+
name: Publish to PyPI
80+
runs-on: ubuntu-latest
81+
needs: [build, test-install]
82+
if: github.event_name == 'release' && github.event.action == 'published'
83+
84+
steps:
85+
- name: Download build artifacts
86+
uses: actions/download-artifact@v4
87+
with:
88+
name: dist
89+
path: dist/
90+
91+
- name: Publish to PyPI
92+
uses: pypa/gh-action-pypi-publish@release/v1
93+
with:
94+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/ci.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint:
11+
name: Lint Code
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ["3.10", "3.11", "3.12", "3.14"]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v3
27+
with:
28+
enable-cache: true
29+
cache-dependency-glob: "pyproject.toml"
30+
31+
- name: Install dependencies
32+
run: |
33+
uv sync --dev
34+
35+
- name: Run ruff (linting)
36+
run: |
37+
uv run ruff check dify_client tests
38+
39+
- name: Run black (check formatting)
40+
run: |
41+
uv run black --check dify_client tests
42+
43+
- name: Run isort (check import sorting)
44+
run: |
45+
uv run isort --check-only dify_client tests
46+
47+
- name: Run mypy (type checking)
48+
run: |
49+
uv run mypy dify_client
50+
51+
- name: Compile Python files (syntax check)
52+
run: |
53+
uv run python -m py_compile $(find dify_client -name "*.py") $(find tests -name "*.py")
54+
55+
test:
56+
name: Test Code
57+
runs-on: ubuntu-latest
58+
strategy:
59+
matrix:
60+
python-version: ["3.10", "3.11", "3.12", "3.14"]
61+
62+
steps:
63+
- uses: actions/checkout@v4
64+
65+
- name: Set up Python ${{ matrix.python-version }}
66+
uses: actions/setup-python@v4
67+
with:
68+
python-version: ${{ matrix.python-version }}
69+
70+
- name: Install uv
71+
uses: astral-sh/setup-uv@v3
72+
with:
73+
enable-cache: true
74+
cache-dependency-glob: "pyproject.toml"
75+
76+
- name: Install dependencies
77+
run: |
78+
uv sync --dev
79+
80+
- name: Run tests with pytest
81+
run: |
82+
uv run pytest -v --cov=dify_client --cov-report=xml --cov-report=html
83+
84+
- name: Upload coverage to Codecov
85+
uses: codecov/codecov-action@v3
86+
with:
87+
file: ./coverage.xml
88+
flags: unittests
89+
name: codecov-umbrella
90+
fail_ci_if_error: false
91+
92+
security:
93+
name: Security Scan
94+
runs-on: ubuntu-latest
95+
96+
steps:
97+
- uses: actions/checkout@v4
98+
99+
- name: Set up Python
100+
uses: actions/setup-python@v4
101+
with:
102+
python-version: "3.11"
103+
104+
- name: Install uv
105+
uses: astral-sh/setup-uv@v3
106+
with:
107+
enable-cache: true
108+
cache-dependency-glob: "pyproject.toml"
109+
110+
- name: Install dependencies
111+
run: |
112+
uv sync --dev
113+
114+
- name: Run bandit security linter
115+
run: |
116+
uv run bandit -r dify_client -f json -o bandit-report.json
117+
118+
119+
- name: Upload security reports
120+
uses: actions/upload-artifact@v4
121+
if: always()
122+
with:
123+
name: security-reports
124+
path: |
125+
bandit-report.json
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Dependency Update
2+
3+
on:
4+
schedule:
5+
# Run every Monday at 9:00 AM UTC
6+
- cron: '0 9 * * 1'
7+
workflow_dispatch:
8+
9+
jobs:
10+
update-dependencies:
11+
name: Update Dependencies
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
token: ${{ secrets.GITHUB_TOKEN }}
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: "3.11"
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v3
26+
with:
27+
enable-cache: true
28+
cache-dependency-glob: "pyproject.toml"
29+
30+
- name: Update dependencies
31+
run: |
32+
uv sync --dev
33+
uv pip list --outdated
34+
35+
- name: Run tests after update
36+
run: |
37+
uv run pytest -v
38+
39+
- name: Create Pull Request
40+
uses: peter-evans/create-pull-request@v5
41+
with:
42+
token: ${{ secrets.GITHUB_TOKEN }}
43+
commit-message: "chore: update dependencies"
44+
title: "Automated Dependency Update"
45+
body: |
46+
## Automated Dependency Update
47+
48+
This PR updates the project dependencies to their latest versions.
49+
50+
### Changes Made
51+
- Updated Python dependencies using `uv sync`
52+
- All tests are passing after the update
53+
54+
Please review the changes and ensure everything looks correct before merging.
55+
branch: dependency-update
56+
delete-branch: true

.github/workflows/quick-check.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Quick Check
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
quick-check:
11+
name: Quick Check
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: "3.11"
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v3
24+
with:
25+
enable-cache: true
26+
cache-dependency-glob: "pyproject.toml"
27+
28+
- name: Install dependencies
29+
run: |
30+
uv sync --dev
31+
32+
- name: Quick syntax check
33+
run: |
34+
find dify_client tests -name "*.py" -exec uv run python -m py_compile {} \;
35+
36+
- name: Check import sorting
37+
run: |
38+
uv run isort --check-only dify_client tests
39+
40+
- name: Run quick tests
41+
run: |
42+
uv run pytest tests/ -x --tb=short
43+
44+
- name: Basic import test
45+
run: |
46+
uv run python -c "
47+
import dify_client
48+
from dify_client import CompletionClient, ChatClient, AsyncCompletionClient, AsyncChatClient
49+
print('All imports successful')
50+
"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,4 @@ cython_debug/
205205
marimo/_static/
206206
marimo/_lsp/
207207
__marimo__/
208+
.idea

0 commit comments

Comments
 (0)