-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (44 loc) · 1.53 KB
/
python-package.yml
File metadata and controls
52 lines (44 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# 工作流名称
name: Python Application CI
# 触发工作流的事件
on:
push:
branches: [ "main", "master" ] # 当主分支有推送时触发
pull_request:
branches: [ "main", "master" ] # 当向主分支发起 Pull Request 时触发
# 定义工作流中的任务
jobs:
build-and-test:
# 任务名称
name: Test on ${{ matrix.os }} with Python ${{ matrix.python-version }}
# 定义运行环境和 Python 版本的矩阵
strategy:
fail-fast: false # 确保即使一个任务失败,其他任务也会继续运行
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12"]
# 指定任务运行的虚拟机环境
runs-on: ${{ matrix.os }}
# 定义任务的步骤
steps:
# 第一步:检出代码
- name: Check out repository code
uses: actions/checkout@v4
# 第二步:设置 Python 环境
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # 启用 pip 缓存以加快后续构建速度
# 第三步:安装依赖
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# 第四步:运行启动测试
- name: Run Startup Test
run: python main.py | head -n 30
# 在所有平台上都使用 bash shell 来确保命令一致性
shell: bash
env:
PYTHONIOENCODING: "utf-8"