-
Notifications
You must be signed in to change notification settings - Fork 0
317 lines (267 loc) · 10.1 KB
/
ci.yml
File metadata and controls
317 lines (267 loc) · 10.1 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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2025 py7zz contributors
name: CI
on:
push:
branches: ["**"] # All branches
pull_request:
branches: [main]
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "latest"
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: |
uv sync --dev
uv pip install -e .
- name: Run ruff check
run: uv run ruff check . --output-format=github
- name: Run ruff format check
run: uv run ruff format --check --diff .
- name: REUSE compliance check
run: pipx run reuse lint
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Ubuntu: comprehensive testing across all supported Python versions
- os: ubuntu-latest
python-version: "3.8"
- os: ubuntu-latest
python-version: "3.9"
- os: ubuntu-latest
python-version: "3.10"
- os: ubuntu-latest
python-version: "3.11"
- os: ubuntu-latest
python-version: "3.12"
- os: ubuntu-latest
python-version: "3.13"
# Windows: test key versions (minimum and maximum supported)
- os: windows-latest
python-version: "3.8"
- os: windows-latest
python-version: "3.13"
# macOS: test intermediate version for additional platform validation
- os: macos-latest
python-version: "3.11"
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "latest"
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: |
uv sync --dev
uv pip install -e .
- name: Download 7zz binary for testing
shell: bash
run: |
# Use locked version from file
echo "Reading configured 7-Zip version..."
chmod +x scripts/get_7zz.sh
VERSION=$(./scripts/get_7zz.sh --get-current)
echo "Configured version: $VERSION"
VERSION_FOR_ASSET=$(echo "$VERSION" | sed 's/\.//g') # e.g., 25.01 -> 2501
# Map platform to 7zz release naming (same logic as release.yml)
if [[ "${{ runner.os }}" == "Windows" ]]; then
ASSET_NAME="7z${VERSION_FOR_ASSET}-x64.exe"
BINARY_NAME="7zz.exe"
elif [[ "${{ runner.os }}" == "macOS" ]]; then
ASSET_NAME="7z${VERSION_FOR_ASSET}-mac.tar.xz"
BINARY_NAME="7zz"
else
ASSET_NAME="7z${VERSION_FOR_ASSET}-linux-x64.tar.xz"
BINARY_NAME="7zz"
fi
DOWNLOAD_URL="https://github.com/ip7z/7zip/releases/download/${VERSION}/${ASSET_NAME}"
echo "Downloading from: $DOWNLOAD_URL"
TEMP_DIR=$(mktemp -d)
curl -L -o "${TEMP_DIR}/${ASSET_NAME}" "$DOWNLOAD_URL"
if [[ "${{ runner.os }}" == "Windows" ]]; then
# Windows installer - extract CLI components (same logic as release.yml)
echo "Downloading installer and extracting CLI components..."
echo "URL: $DOWNLOAD_URL"
# Create binary directory for testing
mkdir -p "py7zz/bin"
# GitHub Runner has built-in 7z.exe for extraction
7z x "${TEMP_DIR}/${ASSET_NAME}" -o"${TEMP_DIR}/out" > /dev/null
# Extract complete CLI with DLL for full format support (7z.exe + 7z.dll)
if [[ -f "${TEMP_DIR}/out/7z.exe" ]] && [[ -f "${TEMP_DIR}/out/7z.dll" ]]; then
# Rename 7z.exe to 7zz.exe for cross-platform consistency
cp "${TEMP_DIR}/out/7z.exe" "py7zz/bin/${BINARY_NAME}"
cp "${TEMP_DIR}/out/7z.dll" "py7zz/bin/"
echo "Windows CLI components (7z.exe + 7z.dll) extracted and copied successfully"
else
echo "Error: 7z.exe or 7z.dll not found in extracted files"
echo "Contents of extracted directory:"
ls -la "${TEMP_DIR}/out/"
exit 1
fi
else
# Unix tar.xz file (same logic as release.yml)
echo "Downloading and extracting Unix binary..."
echo "URL: $DOWNLOAD_URL"
# Create binary directory for testing
mkdir -p "py7zz/bin"
cd "${TEMP_DIR}"
tar -xf "${ASSET_NAME}"
# Find and copy the 7zz binary (search only in current extraction directory)
BINARY_PATH=$(find . -name "7zz" -type f | head -1)
if [ -n "$BINARY_PATH" ]; then
cp "$BINARY_PATH" "$GITHUB_WORKSPACE/py7zz/bin/${BINARY_NAME}"
echo "Binary found and copied: $BINARY_PATH -> py7zz/bin/${BINARY_NAME}"
# Return to workspace directory to set permissions
cd "$GITHUB_WORKSPACE"
# Make binary executable for Unix systems
if [[ "${{ runner.os }}" != "Windows" ]]; then
chmod +x "py7zz/bin/${BINARY_NAME}"
echo "Set executable permissions for Unix binary"
fi
else
echo "Error: 7zz binary not found in extracted files"
echo "Contents of extracted directory:"
ls -la .
exit 1
fi
fi
# Ensure we're in the workspace directory for verification
cd "$GITHUB_WORKSPACE"
# Verify the binary was placed correctly (same logic as release.yml)
echo "Verifying binary placement..."
if [[ -f "py7zz/bin/${BINARY_NAME}" ]]; then
echo "✓ Binary correctly placed at: py7zz/bin/${BINARY_NAME}"
ls -la "py7zz/bin/"
else
echo "✗ Binary not found at expected location: py7zz/bin/${BINARY_NAME}"
echo "Contents of py7zz/bin/:"
find py7zz/bin/ -type f -ls || echo "No files found"
exit 1
fi
# Verify binary works (same logic as release.yml)
echo "Verifying binary functionality..."
BINARY_PATH="py7zz/bin/${BINARY_NAME}"
if [[ "${{ runner.os }}" == "Windows" ]]; then
# Windows binary verification - verify 7zz.exe (from 7z.exe) with 7z.dll works
if "$BINARY_PATH" -h > /dev/null 2>&1; then
echo "✓ Windows binary verification passed - 7zz.exe (from 7z.exe) with full format support"
else
echo "✗ Windows binary cannot run properly"
echo "Binary path: $BINARY_PATH"
echo "Binary exists: $(test -f "$BINARY_PATH" && echo "yes" || echo "no")"
echo "DLL exists: $(test -f "py7zz/bin/7z.dll" && echo "yes" || echo "no")"
echo "Binary size: $(stat -c%s "$BINARY_PATH" 2>/dev/null || stat -f%z "$BINARY_PATH" 2>/dev/null || echo "unknown")"
exit 1
fi
else
# Unix binary verification
if "$BINARY_PATH" --help > /dev/null 2>&1; then
echo "✓ Unix binary verification passed"
else
echo "✗ Unix binary verification failed for: $BINARY_PATH"
exit 1
fi
fi
# Clean up
cd "$GITHUB_WORKSPACE"
rm -rf "${TEMP_DIR}"
- name: Run pytest
shell: bash
run: uv run pytest -v --tb=short
- name: Run mypy
shell: bash
run: uv run mypy .
build-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "latest"
enable-cache: true
- name: Set up Python
run: uv python install 3.11
- name: Install build dependencies
run: |
uv sync --dev
uv pip install build
- name: Build wheel and sdist
run: uv run python -m build
- name: Check wheel contents
run: |
WHL=$(ls dist/*.whl | head -n1)
echo "Checking wheel contents: $WHL"
unzip -l "$WHL" | grep -E "(LICENSE|THIRD_PARTY_NOTICES\.md|licenses/7zip-LICENSE\.txt)" || {
echo "❌ Missing required license files in wheel"
echo "Wheel contents:"
unzip -l "$WHL"
exit 1
}
echo "✅ All required license files found in wheel"
- name: Check sdist contents
run: |
SDIST=$(ls dist/*.tar.gz | head -n1)
echo "Checking sdist contents: $SDIST"
tar tzf "$SDIST" | grep -E "(LICENSE|THIRD_PARTY_NOTICES\.md|licenses/7zip-LICENSE\.txt)" || {
echo "❌ Missing required license files in sdist"
echo "Sdist contents:"
tar tzf "$SDIST"
exit 1
}
echo "✅ All required license files found in sdist"
- name: Install and test wheel
run: |
WHL=$(ls dist/*.whl | head -n1)
uv pip install "$WHL"
uv run python -c "import py7zz; print('✅ Wheel installation successful')"
sbom-generation:
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "latest"
enable-cache: true
- name: Set up Python
run: uv python install 3.11
- name: Install SBOM and license tools
run: |
uv sync --dev
uv add --dev cyclonedx-bom pip-licenses
- name: Generate SBOM
run: |
uv run cyclonedx-py environment .venv -o sbom.json --output-format=json
echo "✅ SBOM generated: sbom.json"
- name: Generate dependency licenses report
run: |
uv run pip-licenses --format=markdown > licenses-dependencies.md
echo "✅ Dependency licenses generated: licenses-dependencies.md"
- name: Upload SBOM and licenses as artifacts
uses: actions/upload-artifact@v4
with:
name: compliance-reports
path: |
sbom.json
licenses-dependencies.md
retention-days: 90