Skip to content

Update __init__.py

Update __init__.py #23

name: Basic smoke test
on:
push:
branches:
- main
permissions:
contents: write
jobs:
build-and-test:
if: github.actor != 'github-actions[bot]'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
defaults:
run:
shell: bash
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
xvfb \
libegl1 \
libgl1 \
libx11-xcb1 \
libxkbcommon-x11-0 \
libxcb-cursor0 \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-randr0 \
libxcb-render-util0 \
libxcb-shape0 \
libxcb-sync1 \
libxcb-xfixes0 \
libxcb-xinerama0 \
libxcb-xkb1
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements.txt
python -m pip install cmake
- name: Build MMG (v5.8.0, Release, -O3)
run: |
if [ "${{ runner.os }}" = "macOS" ]; then
python .github/scripts/build_mmg.py --version 5.8.0 --arch universal2 --jobs 2
elif [ "${{ runner.os }}" = "Windows" ]; then
python .github/scripts/build_mmg.py --version 5.8.0 --arch x86_64 --jobs 2
else
python .github/scripts/build_mmg.py --version 5.8.0 --arch x86_64 --jobs 2
fi
- name: Build svZeroDSolver (v3.0, Release)
run: |
if [ "${{ runner.os }}" = "macOS" ]; then
python .github/scripts/build_0d.py --version 3.0 --arch universal2 --jobs 2
elif [ "${{ runner.os }}" = "Windows" ]; then
python .github/scripts/build_0d.py --version 3.0 --arch x86_64 --jobs 2
else
python .github/scripts/build_0d.py --version 3.0 --arch x86_64 --jobs 2
fi
- name: Install svVascularize
env:
SVV_REQUIRE_MMG: "1"
SVV_REQUIRE_SOLVER_0D: "1"
SVV_MMG_ARCH: ${{ runner.os == 'macOS' && 'universal2' || '' }}
SVV_SOLVER_0D_ARCH: ${{ runner.os == 'macOS' && 'universal2' || '' }}
run: |
python -m pip install .
- name: Verify MMG executables are installed
run: |
python - << 'PY'
import os
import subprocess
import tempfile
# Ensure we validate the *installed* package, not the repo checkout
# (stdin execution puts the current working directory on sys.path).
os.chdir(tempfile.mkdtemp(prefix="svv-mmg-verify-"))
from svv.utils.remeshing.mmg import get_mmg_exe
from svv.utils.solvers.solver_0d import get_solver_0d_exe
for tool in ("mmg2d", "mmg3d", "mmgs"):
exe = get_mmg_exe(tool)
print(f"{tool} -> {exe}", flush=True)
if os.name != "nt" and not os.access(exe, os.X_OK):
raise SystemExit(f"{exe} is not marked executable")
# MMG tools often return a non-zero code for help/usage (commonly 1 or 2),
# so don't treat that as a failure; we only want to ensure the binary runs.
proc = subprocess.run(
[str(exe), "-h"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
timeout=10,
check=False,
)
print(f"{tool} -h exit: {proc.returncode}", flush=True)
solver_0d = get_solver_0d_exe()
print(f"svzerodsolver -> {solver_0d}", flush=True)
if os.name != "nt" and not os.access(solver_0d, os.X_OK):
raise SystemExit(f"{solver_0d} is not marked executable")
proc = subprocess.run(
[str(solver_0d), "-h"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
timeout=10,
check=False,
)
print(f"svzerodsolver -h exit: {proc.returncode}", flush=True)
PY
- name: Run basic smoke test
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
xvfb-run -a -s "-screen 0 1920x1080x24" python .github/scripts/basic_smoke_test.py
else
python .github/scripts/basic_smoke_test.py
fi
env:
SVV_TELEMETRY_DISABLED: "1"
SVV_GUI_DISABLE_VTK: "1"
SVV_GUI_GL_MODE: "software"
QT_X11_NO_MITSHM: "1"
SVV_USEARCH_THREADS: "1"
OMP_NUM_THREADS: "1"
OPENBLAS_NUM_THREADS: "1"
MKL_NUM_THREADS: "1"
VECLIB_MAXIMUM_THREADS: "1"
NUMEXPR_NUM_THREADS: "1"
- name: Record job status
if: always()
run: |
echo "${{ matrix.os }}=${{ job.status }}" > smoke-status.txt
- name: Upload status artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: smoke-status-${{ matrix.os }}-py${{ matrix.python-version }}
path: smoke-status.txt
update-smoke-badge:
if: ${{ github.actor != 'github-actions[bot]' && always() }}
needs: build-and-test
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Check out code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Download status artifacts
uses: actions/download-artifact@v4
with:
pattern: smoke-status-*
path: smoke-status
- name: Update README smoke test badge
run: |
set -euo pipefail
linux="unknown"
macos="unknown"
windows="unknown"
# If no smoke-status artifacts were downloaded, skip badge update.
if ! compgen -G "smoke-status/*/smoke-status.txt" > /dev/null; then
echo "No smoke-status artifacts found; skipping badge update."
exit 0
fi
# Each artifact directory contains a single smoke-status.txt file.
for f in smoke-status/*/smoke-status.txt; do
line=$(cat "$f")
os="${line%%=*}"
status="${line#*=}"
case "$os" in
ubuntu-latest)
if [ "$status" = "success" ]; then
if [ "$linux" = "unknown" ]; then
linux="ok"
fi
else
linux="fail"
fi
;;
macos-latest)
if [ "$status" = "success" ]; then
if [ "$macos" = "unknown" ]; then
macos="ok"
fi
else
macos="fail"
fi
;;
windows-latest)
if [ "$status" = "success" ]; then
if [ "$windows" = "unknown" ]; then
windows="ok"
fi
else
windows="fail"
fi
;;
esac
done
message="linux ${linux} | macos ${macos} | windows ${windows}"
if [ "$linux" = "ok" ] && [ "$macos" = "ok" ] && [ "$windows" = "ok" ]; then
color="brightgreen"
elif [ "$linux" = "fail" ] || [ "$macos" = "fail" ] || [ "$windows" = "fail" ]; then
color="red"
else
color="lightgrey"
fi
msg_enc=$(SMOKE_MSG="${message}" python - << 'PY'
import os
import urllib.parse
print(urllib.parse.quote(os.environ["SMOKE_MSG"], safe=""))
PY
)
badge_url="https://img.shields.io/static/v1?label=svv%20passing&message=${msg_enc}&color=${color}"
link="https://github.com/${GITHUB_REPOSITORY}/actions/workflows/basic-smoke-test.yml?query=branch%3A${GITHUB_REF_NAME}"
new_badge="[![SVV passing](${badge_url})](${link})"
BADGE_URL="${badge_url}" BADGE_LINK="${link}" BADGE_MD="${new_badge}" python - << 'PY'
import os
import re
from pathlib import Path
readme_path = Path("README.md")
text = readme_path.read_text(encoding="utf-8")
badge_url = os.environ["BADGE_URL"]
link = os.environ["BADGE_LINK"]
badge_md = os.environ["BADGE_MD"]
pattern = re.compile(r"<!-- smoke-test-badge -->.*?<!-- /smoke-test-badge -->", re.S)
replacement = f"<!-- smoke-test-badge -->\n{badge_md}\n<!-- /smoke-test-badge -->"
new_text, n = pattern.subn(replacement, text)
if n == 0:
raise SystemExit("smoke-test-badge markers not found in README.md")
readme_path.write_text(new_text, encoding="utf-8")
PY
- name: Commit README badge update
run: |
if git diff --quiet README.md; then
echo "No README changes to commit."
else
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md
git commit -m "Update smoke test status badge"
git push
fi