Skip to content

Jules - fix pyodide/valgrind test failures. #4549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions .github/workflows/test-valgrind.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
name: Test valgrind

on:
workflow_dispatch:
schedule:
- cron: '13 6 * * *'
workflow_dispatch:
inputs:
scripts_test_options:
description: 'Extra options for scripts/test.py.'

jobs:

valgrind:
name: Test valgrind
runs-on: ${{ matrix.os }}
name: valgrind
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]

args: [
'',
'-m "git:--branch master https://github.com/ArtifexSoftware/mupdf"',
'-m "git:--branch 1.26.x https://github.com/ArtifexSoftware/mupdf"',
]
fail-fast: false

steps:

- uses: actions/checkout@v4
- uses: actions/setup-python@v5

- name: test_mupdf-master-branch
env:
PYMUDF_SCRIPTS_TEST_options: ${{inputs.scripts_test_options}}
- name: valgrind
run:
python scripts/test.py -m 'git:--recursive --depth 1 --shallow-submodules --branch master https://github.com/ArtifexSoftware/mupdf.git' -P 1 --valgrind 1 buildtest
python scripts/test.py ${{matrix.args}} -P 1 --valgrind 1 build test
56 changes: 19 additions & 37 deletions .github/workflows/test_pyodide.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,39 @@
name: Build Pyodide wheel

# Builds pyodide wheels.

on:
workflow_dispatch:

inputs:
PYMUPDF_SETUP_MUPDF_BUILD:
description: 'Value for PYMUPDF_SETUP_MUPDF_BUILD, e.g.: git:--branch master https://github.com/ArtifexSoftware/mupdf.git'
type: string
#default: 'git:--branch master https://github.com/ArtifexSoftware/mupdf.git'
default: '-'
PYMUPDF_SETUP_PY_LIMITED_API:
type: string
default: '1'

schedule:
- cron: '13 5 * * *'

jobs:

build_pyodide:

name: Build pyodide wheel
pyodide:
name: pyodide
runs-on: ubuntu-latest

strategy:
matrix:
# Python version needs to match emsdk.
python-version: ["3.12"]

# Avoid cancelling of all runs after a single failure.
args: [
'',
'-m "git:--branch master https://github.com/ArtifexSoftware/mupdf"',
'-m "git:--branch 1.26.x https://github.com/ArtifexSoftware/mupdf"',
]
fail-fast: false

steps:

- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: build_pyodide_wheel
env:
inputs_sdist: 0
inputs_PYMUPDF_SETUP_MUPDF_BUILD: ${{inputs.PYMUPDF_SETUP_MUPDF_BUILD}}
PYMUPDF_SETUP_PY_LIMITED_API: ${{inputs.PYMUPDF_SETUP_PY_LIMITED_API}}
inputs_wheels_default: 0
inputs_wheels_linux_pyodide: 1
python-version: 3.12

- name: pyodide
run:
python scripts/gh_release.py build


# Upload generated wheels, to be accessible from github Actions page.
#
- uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
python scripts/test.py ${{matrix.args}} pyodide

# We do not use upload-artifact@v4 because it fails due to us creating
# identically-named wheels.
#- uses: actions/upload-artifact@v4
# with:
# path: ./wheelhouse/*.whl
18 changes: 15 additions & 3 deletions scripts/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@
[This simply sSets $PYMUPDF_SETUP_PY_LIMITED_API, which is used by
PyMuPDF/setup.py.]

--show-args:
Show sys.argv and exit. For debugging.

--sync-paths
Do not run anything, instead write required files/directories/checkouts
to stdout, one per line. This is to help with automated running on
Expand Down Expand Up @@ -278,6 +281,7 @@ def main(argv):
pyodide_build_version = None
pytest_options = ''
pytest_prefix = None
show_args = False
show_help = False
sync_paths = False
system_site_packages = False
Expand Down Expand Up @@ -388,6 +392,8 @@ def main(argv):
assert _value in ('0', '1'), f'`-s` must be followed by `0` or `1`, not {_value=}.'
env_extra['PYMUPDF_SETUP_PY_LIMITED_API'] = _value

elif arg == '--show-args':
show_args = 1
elif arg == '--sync-paths':
sync_paths = True

Expand Down Expand Up @@ -439,6 +445,12 @@ def main(argv):
print(__doc__)
return

if show_args:
print(f'sys.argv ({len(sys.argv)}):')
for arg in sys.argv:
print(f' {arg!r}')
return

if os_names:
if platform.system().lower() not in os_names:
log(f'Not running because {platform.system().lower()=} not in {os_names=}')
Expand Down Expand Up @@ -905,7 +917,7 @@ def getmtime(path):
for test_name in test_names:
pytest_arg += f' {pymupdf_dir_rel}/{test_name}'
else:
pytest_arg += f' {pymupdf_dir_rel}'
pytest_arg += f' {pymupdf_dir_rel}/tests'
python = gh_release.relpath(sys.executable)
log('Running tests with tests/run_compound.py and pytest.')

Expand Down Expand Up @@ -940,7 +952,7 @@ def getmtime(path):
command += (
f' valgrind'
f' --suppressions={pymupdf_dir_abs}/valgrind.supp'
f' --trace-children=yes'
f' --trace-children=no'
f' --num-callers=20'
f' --error-exitcode=100'
f' --errors-for-leak-kinds=none'
Expand All @@ -952,7 +964,7 @@ def getmtime(path):
command = (
f' valgrind'
f' --tool=helgrind'
f' --trace-children=yes'
f' --trace-children=no'
f' --num-callers=20'
f' --error-exitcode=100'
f' --fullpath-after='
Expand Down