-
Notifications
You must be signed in to change notification settings - Fork 0
250 lines (210 loc) Β· 7.53 KB
/
code-quality.yml
File metadata and controls
250 lines (210 loc) Β· 7.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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
name: Code Quality
# Run on all PRs and pushes to main for comprehensive quality checks
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
# Concurrency group to cancel previous runs
concurrency:
group: code-quality-${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
# Environment variables
env:
FORCE_COLOR: "1"
PIP_DISABLE_PIP_VERSION_CHECK: "1"
# Test environment indicators
CI: "true"
TESTING: "true"
PYTEST_RUNNING: "true"
# Mock AWS credentials (required for boto3 initialization)
AWS_ACCESS_KEY_ID: "test-access-key-id"
AWS_SECRET_ACCESS_KEY: "test-secret-access-key"
AWS_DEFAULT_REGION: "us-east-1"
AWS_REGION: "us-east-1"
# YMemo-specific test configuration
TRANSCRIPTION_PROVIDER: "aws"
CAPTURE_PROVIDER: "pyaudio"
LOG_LEVEL: "WARNING" # Reduce CI log noise
# Disable real service connections
SKIP_AWS_VALIDATION: "true"
MOCK_SERVICES: "true"
permissions:
contents: read
pull-requests: write
jobs:
# Linting and code style checks
lint:
name: "Lint & Style"
runs-on: ubuntu-latest
steps:
- name: "π₯ Checkout repository"
uses: actions/checkout@v4
- name: "π Set up Python 3.11"
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: "π¦ Cache pip dependencies"
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: lint-pip-3.11-${{ hashFiles('**/requirements.txt') }}
restore-keys: lint-pip-3.11-
- name: "π§ Install system dependencies (Ubuntu)"
run: |
sudo apt-get update -yq
sudo apt-get install -yq portaudio19-dev python3-dev libasound2-dev
sudo apt-get install -yq libportaudio2 libportaudiocpp0
- name: "π§ͺ Set up test environment"
run: |
# Create fake AWS credentials directory for boto3 (Linux/macOS only)
mkdir -p ~/.aws
cat > ~/.aws/credentials << EOF
[default]
aws_access_key_id = test-access-key-id
aws_secret_access_key = test-secret-access-key
region = us-east-1
EOF
cat > ~/.aws/config << EOF
[default]
region = us-east-1
output = json
EOF
echo "β
Test environment configured with mock AWS credentials"
- name: "π¦ Install linting tools"
run: |
python -m pip install --upgrade pip
python -m pip install black isort
- name: "π¨ Check Black formatting"
run: black --check --diff src/ tests/
- name: "π¦ Check import sorting (isort)"
run: isort --check-only --diff src/ tests/
# Documentation checks
docs:
name: "Documentation"
runs-on: ubuntu-latest
steps:
- name: "π₯ Checkout repository"
uses: actions/checkout@v4
- name: "π Set up Python 3.11"
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: "π¦ Install documentation tools"
run: |
python -m pip install --upgrade pip
python -m pip install pydocstyle doc8 sphinx
- name: "π Check docstring style"
run: |
# Check docstring conventions (relaxed for initial implementation)
pydocstyle src/ --convention=numpy --add-ignore=D100,D101,D102,D103,D104,D105 || true
- name: "π Check README and documentation"
run: |
# Basic checks for markdown files
if command -v markdownlint-cli2 &> /dev/null; then
markdownlint-cli2 "**/*.md"
else
echo "markdownlint not installed, skipping markdown linting"
fi
# Dependency analysis
dependencies:
name: "Dependency Analysis"
runs-on: ubuntu-latest
steps:
- name: "π₯ Checkout repository"
uses: actions/checkout@v4
- name: "π Set up Python 3.11"
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: "π§ Install system dependencies (Ubuntu)"
run: |
sudo apt-get update -yq
sudo apt-get install -yq portaudio19-dev python3-dev libasound2-dev
sudo apt-get install -yq libportaudio2 libportaudiocpp0
- name: "π§ͺ Set up test environment"
run: |
# Create fake AWS credentials directory for boto3 (Linux/macOS only)
mkdir -p ~/.aws
cat > ~/.aws/credentials << EOF
[default]
aws_access_key_id = test-access-key-id
aws_secret_access_key = test-secret-access-key
region = us-east-1
EOF
cat > ~/.aws/config << EOF
[default]
region = us-east-1
output = json
EOF
echo "β
Test environment configured with mock AWS credentials"
- name: "π¦ Install dependency analysis tools"
run: |
python -m pip install --upgrade pip
# Force secure setuptools version first
python -m pip install "setuptools>=78.1.1"
python -m pip install pip-audit pipdeptree
- name: "π³ Generate dependency tree"
run: |
# Install project dependencies first
python -m pip install -r requirements.txt
# Generate dependency tree for analysis
pipdeptree --json > dependency-tree.json
pipdeptree
- name: "π Audit dependencies for vulnerabilities"
run: |
# pip-audit for dependency vulnerability scanning
pip-audit --desc --output=audit-report.json --format=json || true
pip-audit --desc
- name: "π€ Upload dependency reports"
if: always()
uses: actions/upload-artifact@v4
with:
name: dependency-reports
path: |
audit-report.json
dependency-tree.json
retention-days: 30
# Quality gate for all code quality checks
quality-summary:
name: "Quality Summary β
"
needs: [lint, docs, dependencies]
runs-on: ubuntu-latest
if: always()
steps:
- name: "β
Quality checks passed"
if: |
needs.lint.result == 'success' &&
needs.docs.result == 'success' &&
needs.dependencies.result == 'success'
run: |
echo "π All code quality checks passed!"
echo "π Quality Summary:"
echo "- β
Linting and style checks"
echo "- β
Documentation checks"
echo "- β
Dependency analysis"
echo ""
echo "YMemo maintains high code quality standards! π"
- name: "β Quality checks failed"
if: |
needs.lint.result == 'failure' ||
needs.docs.result == 'failure' ||
needs.dependencies.result == 'failure'
run: |
echo "β Some quality checks failed:"
echo "- Lint: ${{ needs.lint.result }}"
echo "- Docs: ${{ needs.docs.result }}"
echo "- Dependencies: ${{ needs.dependencies.result }}"
echo ""
echo "Please review the detailed reports above."
exit 1
- name: "β οΈ Quality checks incomplete"
if: |
contains(fromJSON('["cancelled", "skipped"]'), needs.lint.result) ||
contains(fromJSON('["cancelled", "skipped"]'), needs.docs.result) ||
contains(fromJSON('["cancelled", "skipped"]'), needs.dependencies.result)
run: |
echo "β οΈ Some quality checks were cancelled or skipped."
echo "This may indicate workflow issues or concurrency limits."
exit 1