-
Notifications
You must be signed in to change notification settings - Fork 0
204 lines (168 loc) · 6.55 KB
/
python-app.yaml
File metadata and controls
204 lines (168 loc) · 6.55 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
name: imgshape CI
on:
push:
branches: ["master", "main"]
pull_request:
branches: ["master", "main"]
concurrency:
group: imgshape-ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
fail-fast: false
env:
PIP_EXTRA_INDEX_URL: ""
PYTHONUNBUFFERED: 1
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
cache: "pip"
- name: Cache pip cache (explicit)
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml','**/setup.py','**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: Install system deps (robust apt-get)
shell: bash
run: |
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive
APT_OPTS="-o Acquire::Retries=3 -o Acquire::http::Timeout=60 -o Acquire::https::Timeout=60"
echo "Updating apt indexes (retries=3)..."
attempt=0; max=3
until [ $attempt -ge $max ]
do
attempt=$((attempt+1))
if sudo apt-get $APT_OPTS update -qq; then
echo "apt-get update succeeded on attempt $attempt"
break
else
echo "apt-get update failed on attempt $attempt; sleeping before retry..."
sleep $((attempt * 4))
fi
done
echo "Installing minimal runtime libs (no recommends) ..."
sudo apt-get install -y --no-install-recommends libgl1 libglib2.0-0 ca-certificates || {
echo "apt-get install failed — printing apt logs for debugging" >&2
apt-cache policy libgl1 || true
exit 1
}
echo "apt-get step completed"
- name: Upgrade pip / build tools
shell: bash
run: |
python -m pip install --upgrade pip wheel setuptools build
- name: Install package in editable mode with extras (dev + full)
shell: bash
run: |
pip install -e ".[dev,full]" || pip install -e ".[dev]"
- name: Prepare test image
shell: bash
run: |
set -euo pipefail
mkdir -p sample tmp
if [ -f assets/sample_images/Image_created_with_a_mobile_phone.png ]; then
cp assets/sample_images/Image_created_with_a_mobile_phone.png sample/test.png
else
RAW="https://raw.githubusercontent.com/STiFLeR7/imgshape/master/assets/sample_images/Image_created_with_a_mobile_phone.png"
curl -fsSLo sample/test.png "$RAW" || true
if [ ! -f sample/test.png ]; then
echo "Primary sample image not available; using Wikimedia fallback"
curl -fsSLo sample/test.png https://upload.wikimedia.org/wikipedia/commons/7/77/Delete_key1.jpg || true
fi
fi
ls -l sample || true
- name: Lint (flake8) — non-blocking
shell: bash
run: |
pip install flake8
flake8 src tests || true
- name: Type-check (mypy) — non-blocking
shell: bash
run: |
pip install mypy
mypy src || true
# ---- CLI Smoke Tests ----
- name: CLI Test - Help
run: imgshape --help
- name: CLI Test - Version (non-blocking)
run: imgshape --version || true
- name: CLI Test - Shape detection
run: python -m imgshape.cli --path sample/test.png --shape
- name: CLI Test - Analysis
run: python -m imgshape.cli --path sample/test.png --analyze
- name: CLI Test - Recommendation
run: python -m imgshape.cli --path sample/test.png --recommend --augment
- name: CLI Test - Report (Markdown) (non-blocking)
run: python -m imgshape.cli --path sample --report --augment --out tmp/ci_report.md || true
- name: CLI Test - Report (HTML) (non-blocking)
run: python -m imgshape.cli --path sample --report --augment --out tmp/ci_report.html || true
- name: CLI Test - Visualization (non-blocking) — run script
shell: bash
run: |
# run deterministic script that attempts to generate an interactive plot (if viz available)
mkdir -p .github/scripts
python .github/scripts/plot_test.py || true
- name: CLI Test - Model Compatibility (non-blocking)
run: python -m imgshape.cli --dir sample --check mobilenet_v2 || true
- name: CLI Test - TorchLoader (transform snippet) (non-blocking)
run: python -m imgshape.cli --path sample --torchloader --out tmp/transform_snippet.py || true
# ---- v4 Atlas Tests ----
- name: CLI Test - v4 Fingerprint
run: imgshape --fingerprint --path sample --out tmp/v4_fingerprint.json
- name: CLI Test - v4 Atlas Analyze
run: imgshape --atlas --path sample --intent training --out tmp/v4_analysis.json
- name: CLI Test - v4 Decisions
run: imgshape --decisions --path sample --intent training --out tmp/v4_decisions.json
- name: Run pytest (all tests)
run: pytest -q --disable-warnings --maxfail=1
- name: Run pytest (v4 tests only)
run: pytest tests/v4_test.py -v --disable-warnings
- name: Build distributions
run: python -m build
- name: Twine check
run: |
pip install twine
twine check dist/*
- name: Collect logs & reports (always)
if: always()
shell: bash
run: |
mkdir -p tmp
if [ ! -f pytest-report.xml ]; then
echo "<testsuites/>" > pytest-report.xml
fi
ls -la dist/ || true
ls -la tmp/ || true
echo "Files ready for upload:"
find dist/ tmp/ -type f 2>/dev/null | head -20 || true
- name: Upload artifacts (test logs + distributions)
if: always()
uses: actions/upload-artifact@v4
with:
name: ci-artifacts-py${{ matrix.python-version }}
path: |
dist/
tmp/
pytest-report.xml
retention-days: 30
if-no-files-found: warn
- name: Cleanup (best-effort)
if: always()
run: |
rm -rf .pytest_cache || true
du -sh tmp || true