Skip to content

Commit 3fa6899

Browse files
committed
Add github actions
1 parent 18eb4f9 commit 3fa6899

File tree

2 files changed

+224
-0
lines changed

2 files changed

+224
-0
lines changed

.github/workflows/release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
id-token: write
12+
13+
jobs:
14+
build:
15+
name: Build distributions
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
fetch-tags: true
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.12"
28+
cache: pip
29+
cache-dependency-path: |
30+
pyproject.toml
31+
setup.py
32+
33+
- name: Install build tooling
34+
run: |
35+
python -m pip install --upgrade pip
36+
python -m pip install build
37+
38+
- name: Build package
39+
run: python -m build
40+
41+
- name: Upload build artifacts
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: dist
45+
path: dist/*
46+
47+
publish_pypi:
48+
name: Publish to PyPI
49+
runs-on: ubuntu-latest
50+
needs: build
51+
environment:
52+
name: pypi
53+
url: https://pypi.org/p/ripperdoc-agent-sdk
54+
permissions:
55+
id-token: write
56+
steps:
57+
- name: Download artifacts
58+
uses: actions/download-artifact@v4
59+
with:
60+
name: dist
61+
path: dist
62+
63+
- name: Publish distribution
64+
uses: pypa/gh-action-pypi-publish@release/v1
65+
with:
66+
packages_dir: dist
67+
68+
github_release:
69+
name: GitHub Release
70+
runs-on: ubuntu-latest
71+
needs:
72+
- build
73+
- publish_pypi
74+
permissions:
75+
contents: write
76+
steps:
77+
- name: Download artifacts
78+
uses: actions/download-artifact@v4
79+
with:
80+
name: dist
81+
path: dist
82+
83+
- name: Create release
84+
uses: softprops/action-gh-release@v2
85+
with:
86+
files: dist/*
87+
generate_release_notes: true

.github/workflows/test.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["main", "master"]
6+
pull_request:
7+
branches: ["main", "master"]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint:
14+
name: Lint (Non-blocking)
15+
runs-on: ubuntu-latest
16+
continue-on-error: true # 不阻塞工作流
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.12"
25+
cache: pip
26+
cache-dependency-path: |
27+
pyproject.toml
28+
setup.py
29+
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
python -m pip install -e ".[dev]"
34+
35+
- name: Ruff
36+
id: ruff
37+
run: |
38+
echo "Running ruff check..."
39+
if ruff check . --output-format=github; then
40+
echo "ruff_status=passed" >> $GITHUB_OUTPUT
41+
echo "Ruff check passed"
42+
else
43+
echo "ruff_status=failed" >> $GITHUB_OUTPUT
44+
echo "::warning::Ruff found code style issues (non-blocking)"
45+
fi
46+
47+
- name: Mypy
48+
id: mypy
49+
run: |
50+
echo "Running mypy..."
51+
if python -m mypy ripperdoc_agent_sdk --show-error-codes; then
52+
echo "mypy_status=passed" >> $GITHUB_OUTPUT
53+
echo "Mypy check passed"
54+
else
55+
echo "mypy_status=failed" >> $GITHUB_OUTPUT
56+
echo "::warning::Mypy found type issues (non-blocking)"
57+
fi
58+
59+
- name: Lint Summary
60+
if: always()
61+
run: |
62+
echo "=== Lint Check Summary ==="
63+
echo "Ruff: ${{ steps.ruff.outputs.ruff_status || 'unknown' }}"
64+
echo "Mypy: ${{ steps.mypy.outputs.mypy_status || 'unknown' }}"
65+
echo "========================="
66+
echo "Note: Lint checks are non-blocking. Focus on test results."
67+
68+
tests:
69+
name: Tests - Primary Check (Python ${{ matrix.python-version }})
70+
runs-on: ubuntu-latest
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
python-version: ["3.10", "3.11", "3.12"]
75+
steps:
76+
- name: Checkout
77+
uses: actions/checkout@v4
78+
79+
- name: Set up Python
80+
uses: actions/setup-python@v5
81+
with:
82+
python-version: ${{ matrix.python-version }}
83+
cache: pip
84+
cache-dependency-path: |
85+
pyproject.toml
86+
setup.py
87+
88+
- name: Install dependencies
89+
run: |
90+
python -m pip install --upgrade pip
91+
python -m pip install -e ".[dev]"
92+
93+
- name: Pytest
94+
id: pytest
95+
run: |
96+
echo "Running tests..."
97+
if pytest; then
98+
echo "pytest_status=passed" >> $GITHUB_OUTPUT
99+
echo "Tests passed"
100+
else
101+
echo "pytest_status=failed" >> $GITHUB_OUTPUT
102+
echo "::error::Tests failed"
103+
exit 1
104+
fi
105+
106+
- name: Test Summary
107+
if: always()
108+
run: |
109+
echo "=== Test Results Summary ==="
110+
echo "Python ${{ matrix.python-version }}: ${{ steps.pytest.outputs.pytest_status || 'unknown' }}"
111+
echo "============================"
112+
113+
summary:
114+
name: Workflow Summary
115+
runs-on: ubuntu-latest
116+
needs: [lint, tests]
117+
if: always()
118+
steps:
119+
- name: Display Summary
120+
run: |
121+
echo "=== CI Workflow Summary ==="
122+
echo ""
123+
echo "Lint Checks (Non-blocking):"
124+
echo " - Ruff: ${{ needs.lint.result || 'skipped' }}"
125+
echo " - Mypy: ${{ needs.lint.result || 'skipped' }}"
126+
echo ""
127+
echo "Test Results (Primary Check):"
128+
echo " - Python 3.10: ${{ needs.tests.result == 'success' && 'passed' || 'failed' }}"
129+
echo " - Python 3.11: ${{ needs.tests.result == 'success' && 'passed' || 'failed' }}"
130+
echo " - Python 3.12: ${{ needs.tests.result == 'success' && 'passed' || 'failed' }}"
131+
echo ""
132+
echo "=== Final Status ==="
133+
echo "Workflow ${{ github.event_name == 'pull_request' && 'PR check' || 'Push check' }}: ${{ needs.tests.result == 'success' && 'PASSED' || 'FAILED' }}"
134+
echo "===================="
135+
echo ""
136+
echo "Note: Lint checks (ruff/mypy) are informational only."
137+
echo "Test results determine workflow success."

0 commit comments

Comments
 (0)