Skip to content
Draft
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
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 工作流名称 (Workflow name)
name: Python Project CI

# 触发工作流的事件:当有代码推送到任意分支或有人发起 Pull Request 时触发
# (Trigger events: when code is pushed to any branch or someone creates a Pull Request)
on:
push:
branches: [ "*" ]
pull_request:
branches: [ "*" ]

# 工作流包含的任务 (jobs)
jobs:
build-and-test:
# 运行此任务的操作系统环境 (Operating system environment)
runs-on: ubuntu-latest

# 任务包含的步骤 (steps)
steps:
# 第一步:检出你的代码库 (Step 1: Checkout repository)
- name: Checkout repository
uses: actions/checkout@v4

# 第二步:设置Python环境 (Step 2: Set up Python environment)
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10' # 指定Python版本 (Specify Python version)

# 第三步:安装项目依赖 (Step 3: Install dependencies)
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

# 第四步:运行单元测试 (Step 4: Run unit tests)
- name: Run unit tests
run: |
pytest test_calculator.py test_string_utils.py -v --cov=calculator --cov=string_utils --cov-report=term-missing

# 第五步:运行集成测试 (Step 5: Run integration tests)
- name: Run integration tests
run: |
pytest test_integration.py -v

# 第六步:生成完整的覆盖率报告 (Step 6: Generate complete coverage report)
- name: Generate coverage report
run: |
pytest --cov=. --cov-report=xml --cov-report=html --cov-report=term

# 第七步:上传覆盖率报告 (Step 7: Upload coverage report)
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: htmlcov/
53 changes: 53 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Testing
.pytest_cache/
.coverage
.coverage.*
htmlcov/
.tox/
.nox/
coverage.xml
*.cover

# Virtual Environment
venv/
env/
ENV/
.venv

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# Fuzzing
fuzz_input/
fuzz_output/
fuzz_target

# OS
.DS_Store
Thumbs.db
Loading