-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (132 loc) · 3.85 KB
/
Copy pathpython-app.yml
File metadata and controls
153 lines (132 loc) · 3.85 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: QReward CI
on:
push:
paths-ignore:
- '**/*.md'
- 'examples/**'
- 'docs/**'
pull_request:
paths-ignore:
- '**/*.md'
- 'examples/**'
- 'docs/**'
jobs:
lint:
name: "Lint QReward"
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest
python-version:
- "3.14"
- "3.13"
- "3.12"
- "3.11"
- "3.10"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install -r tests/requirements.txt
- name: Run lints
run: |
make lint
test:
name: "Test QReward"
strategy:
# Allows for matrix sub-jobs to fail without canceling the rest
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
python-version:
- "3.14"
- "3.13"
- "3.12"
- "3.11"
- "3.10"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install -r tests/requirements.txt
# 这里是替换成 retry action
- name: Run unit test (retry up to 3 times)
uses: nick-fields/retry@v3
with:
timeout_minutes: 30
max_attempts: 3
retry_wait_seconds: 5
command: |
pip install .
make test
- name: Upload .coverage data file
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
path: .coverage
if-no-files-found: error # 或者 ignore
include-hidden-files: true # . 开头的文件都是隐藏的
codecov:
name: "Upload coverage"
needs: [lint, test]
runs-on: ubuntu-latest
permissions:
statuses: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: coverage-files
- run: ls coverage-files
- name: Setup coverage env
run: pip install -r requirements-github-actions.txt
- name: Merge coverage files
run: |
coverage combine coverage-files/**/.coverage || echo "Combine skipped"
coverage report
coverage html
- name: Upload HTML coverage report
uses: actions/upload-artifact@v4
with:
name: html-coverage-report
path: htmlcov
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
# Try 5 times to upload coverage to smokeshow
- name: Upload coverage to smokeshow
run: |
for i in 1 2 3 4 5; do
if smokeshow upload htmlcov; then
echo "Smokeshow upload success!"
break
fi
echo "Smokeshow upload error, sleep 1 sec and try again."
sleep 1
done
env:
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 90
SMOKESHOW_GITHUB_CONTEXT: coverage
SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
SMOKESHOW_AUTH_KEY: ${{ secrets.SMOKESHOW_AUTH_KEY }}