-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (113 loc) · 4.3 KB
/
Copy pathci.yml
File metadata and controls
129 lines (113 loc) · 4.3 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
name: CI
on:
push:
pull_request:
workflow_dispatch:
jobs:
test:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout OptiProfiler
uses: actions/checkout@v4
with:
repository: optiprofiler/optiprofiler
path: optiprofiler
ref: main
- name: Bootstrap the API-v1 protocol under development
shell: bash
run: |
protocol_file="optiprofiler/python/optiprofiler/problem_libraries.py"
if ! test -f "$protocol_file" || ! grep -q "class ProblemLibraryPlugin" "$protocol_file"; then
git -C optiprofiler fetch --depth=1 origin python
git -C optiprofiler checkout --detach FETCH_HEAD
fi
grep -q "PROBLEM_LIBRARY_API_VERSION = 1" "$protocol_file"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set up MSYS2 toolchain
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
install: make mingw-w64-ucrt-x86_64-gcc
- name: Add MSYS2 tools to PATH
if: runner.os == 'Windows'
shell: pwsh
run: |
"C:\msys64\ucrt64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
"C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install OptiProfiler
run: |
python -m pip install --upgrade pip
python -m pip install build "setuptools>=61" wheel
python -m pip install -e optiprofiler
python -m pip install -e . --no-deps --no-build-isolation
- name: Build SOLAR runtime
shell: bash
run: |
mkdir -p runtime/solar/bin
exe_ext=""
libs_arg=""
if [ "${{ runner.os }}" = "Windows" ]; then
exe_ext=".exe"
libs_arg="LIBS=-lm"
fi
make -C runtime/solar/src EXEEXT="$exe_ext" $libs_arg
test -f "runtime/solar/bin/solar$exe_ext"
- name: Regenerate probinfo
run: |
python scripts/annotate_runtime_manifest.py
git diff --exit-code runtime/solar/manifest.json
python scripts/collect_info.py
git diff --exit-code runtime/solar/metadata/probinfo.csv
- name: Build wheel and source distribution
run: python -m build
- name: Check distribution licenses and contents
run: python scripts/check_distribution_licenses.py
- name: Run Python tests
run: |
python -m unittest discover -s tests -p 'test_*.py'
- name: Fresh installed plugin smoke
shell: bash
run: |
wheel="$(python -c 'from pathlib import Path; print(next(Path("dist").glob("*.whl")).resolve())')"
python -m pip uninstall -y optiprofiler-solar
python -m pip install --no-deps "$wheel"
tmpdir="$(mktemp -d)"
cd "$tmpdir"
python - <<'PY'
from optiprofiler.problem_libraries import ProblemLibraryRef, load_problem_library
ref = ProblemLibraryRef(
"solar",
"entry_point",
"optiprofiler_solar:get_problem_library",
distribution="optiprofiler-solar",
)
plugin = load_problem_library(ref)
assert plugin.name == "solar"
assert "SOLAR10_MINCOST_UNCONSTRAINED" in plugin.select({"ptype": "b", "maxdim": 5}, {})
plugin.check_available()
problem = plugin.load("SOLAR10_MINCOST_UNCONSTRAINED", {})
assert float(problem.fun(problem.x0)) == 1880.297
PY
- name: Ensure generated runtime artifacts are not tracked changes
if: always()
shell: bash
run: |
rm -f runtime/solar/bin/solar runtime/solar/bin/solar.exe runtime/solar/src/*.o
rm -rf runtime/solar/.build.lock.d
rm -rf optiprofiler
git status --short
test -z "$(git status --short)"