Repository navigation
98 lines (92 loc) · 3.15 KB
/
Copy pathpython-package.yml
File metadata and controls
98 lines (92 loc) · 3.15 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
name: Python package
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
workflow_call:
inputs:
release-tag:
description: Release tag to compare with the built package version
required: false
default: ""
type: string
permissions:
contents: read
jobs:
build:
name: Build distributions
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install build tools
run: python -m pip install build twine packaging
- name: Build and validate distributions
run: |
python -m build
python -m twine check --strict dist/*
- name: Check package and release version
env:
RELEASE_TAG: ${{ inputs.release-tag }}
run: |
python - <<'PY'
import os
from email.parser import BytesParser
from pathlib import Path
from zipfile import ZipFile
from packaging.version import Version
wheels = list(Path("dist").glob("*.whl"))
if len(wheels) != 1:
raise SystemExit("Expected exactly one wheel")
with ZipFile(wheels[0]) as wheel:
paths = [name for name in wheel.namelist() if name.endswith(".dist-info/METADATA")]
if len(paths) != 1:
raise SystemExit("Expected exactly one wheel metadata file")
metadata = BytesParser().parsebytes(wheel.read(paths[0]))
if metadata["Name"] != "evomo":
raise SystemExit("Expected an evomo distribution")
tag = os.environ.get("RELEASE_TAG", "")
version = metadata["Version"]
if tag and Version(tag.removeprefix("v")) != Version(version):
raise SystemExit(f"Release tag {tag!r} does not match package version {version!r}")
print(f"Validated evomo {version}")
PY
- uses: actions/upload-artifact@v4
with:
name: python-distributions
path: dist/*
if-no-files-found: error
test:
name: Core tests (Python ${{ matrix.python-version }})
needs: build
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v4
with:
name: python-distributions
path: dist
- name: Install CPU PyTorch and built wheel
run: |
python -m pip install "torch>=2.6.0" --index-url https://download.pytorch.org/whl/cpu
python -m pip install dist/*.whl
python -m pip check
- name: Smoke test installed package outside checkout
working-directory: ${{ runner.temp }}
run: |
python -c "import evomo.algorithms, evomo.metrics, evomo.operators, evomo.problems, evomo.workflows"
- name: Run unit tests
run: python -m unittest discover -s unit_test -v