From 3837e79336b4ef5f965dd32ea3646b42cde00998 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Thu, 7 Dec 2023 14:19:15 +0000 Subject: [PATCH] .github/workflows/test*: Use scripts/*.py instead of complex yml code. When running tests, we need to not install `pillow` if on windows-x32; this is much easier to do in python, so we now use scripts/*.py instead of increasingly obscure yml configuration. .github/workflows/test-valgrind.yml Use scripts/test.py. .github/workflows/test_mupdf-master-branch.yml .github/workflows/test_mupdf-release-branch.yml .github/workflows/test_quick.yml Use scripts/gh_release.py. .github/workflows/test.yml Removed because unused. --- .github/workflows/test-valgrind.yml | 89 ++----------------- .github/workflows/test.yml | 51 ----------- .../workflows/test_mupdf-master-branch.yml | 37 +++----- .../workflows/test_mupdf-release-branch.yml | 37 +++----- .github/workflows/test_quick.yml | 33 +++---- 5 files changed, 39 insertions(+), 208 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test-valgrind.yml b/.github/workflows/test-valgrind.yml index 3b555e86e..cfd596d09 100644 --- a/.github/workflows/test-valgrind.yml +++ b/.github/workflows/test-valgrind.yml @@ -2,102 +2,23 @@ name: Test valgrind on: schedule: - - cron: '13 5 * * *' + - cron: '13 6 * * *' workflow_dispatch: jobs: - test_valgrind: + valgrind: name: Test valgrind runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest] - # Avoid cancelling of all runs after a single failure. - fail-fast: false - steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - # python-3.11 seems to generate valgrind errors e.g. 'Use of - # uninitialised value of size 8' in Py_INCREF. - # - # python-3.9 works. - # python-3.10 works. - python-version: '3.10' - - - name: Test valgrind - - run: | - import os - import subprocess - import sys - - def log(text): - print(f'test-valgrind.yml: {text}') - sys.stdout.flush() - - def run(command, env_extra=None): - env = None - if env_extra: - env = os.environ.copy() - env.update(env_extra) - log(f'Adding environment:') - for n, v in env_extra.items(): - log(f' {n}: {v!r}') - log(f'Running: {command}') - sys.stdout.flush() - subprocess.run(command, check=1, shell=1, env=env) - - # Change into parent directory (we will originally be inside the - # PyMuPDF checkout), otherwise there's potential confusion caused - # by the `fitz/` directory not being the installed `fitz` module. - # - log('Changing into parent directory of checkout.') - leaf = os.path.basename(os.getcwd()) - log(f'{os.getcwd()=}') - os.chdir('..') - log(f'{os.getcwd()=}') - - log('Installing valgrind.') - run(f'sudo apt update') - run(f'sudo apt install valgrind') - run(f'valgrind --version') - - log('Creating venv.') - run(f'{sys.executable} -m venv pylocal') - - log('Install required python packages.') - run(f'./pylocal/bin/python -m pip install -U pip') - run(f'./pylocal/bin/python -m pip install pytest fontTools') - - log('Installing PyMuPDF.') - if 0: - # Useful for quick testing - use pypi.org package instead of - # building locally. - run(f'./pylocal/bin/python -m pip install pymupdf') - else: - run( - f'./pylocal/bin/python -m pip install -vv ./{leaf}', - env_extra=dict( - PYMUPDF_SETUP_MUPDF_TGZ='', - PYMUPDF_SETUP_MUPDF_BUILD='git:--recursive --depth 1 --shallow-submodules --branch master https://github.com/ArtifexSoftware/mupdf.git', - PYMUPDF_SETUP_MUPDF_BUILD_TYPE='debug', - ), - ) - log('Running PyMuPDF tests under valgrind.') - # We ignore memory leaks. - run( - f'./pylocal/bin/python {leaf}/tests/run_compound.py valgrind --suppressions={leaf}/valgrind.supp --error-exitcode=100 --errors-for-leak-kinds=none --fullpath-after= ./pylocal/bin/python -m pytest -s -vv {leaf}', - env_extra=dict( - PYTHONMALLOC='malloc', - PYMUPDF_RUNNING_ON_VALGRIND='1', - ), - ) - - shell: python + - name: test_mupdf-master-branch + run: + python scripts/test.py --valgrind 1 buildtest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index e8267aa0d..000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Test - -on: - #schedule: - #- cron: '13 5 * * *' - workflow_dispatch: - -jobs: - - test: - # Build+test current PyMuPDF git. - # - name: Test - runs-on: ${{ matrix.os }} - strategy: - matrix: - # 2023-05-09: Builds on Windows-latest do not work because our wdev.py - # (used to build MuPDF) picks up a later VS than setuptools (when - # building SWIG-generated PyMuPDF code). - # - os: [ubuntu-latest, windows-2019, macos-latest] - - # Avoid cancelling of all cibuildwheel runs after a single failure. - fail-fast: false - - steps: - - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - # Set up cibuildwheel. - # - - name: cibuildwheel - uses: pypa/cibuildwheel@v2.11.2 - - env: - # Build will use the default hard-coded mupdf URL. - - # Build on single cpu. - CIBW_ARCHS_LINUX: x86_64 - - # Build for single python version. - CIBW_BUILD: "cp311*" - - # Don't build for unsupported platforms or win32. - CIBW_SKIP: "pp* *i686 *-musllinux_* cp36*" - - # Get cibuildwheel to run pytest with each wheel. - CIBW_TEST_REQUIRES: "fontTools pytest psutil" - CIBW_TEST_COMMAND: "python {project}/tests/run_compound.py pytest -s {project}/tests" - CIBW_BUILD_VERBOSITY: 3 diff --git a/.github/workflows/test_mupdf-master-branch.yml b/.github/workflows/test_mupdf-master-branch.yml index 4059efe91..e40d5ee48 100644 --- a/.github/workflows/test_mupdf-master-branch.yml +++ b/.github/workflows/test_mupdf-master-branch.yml @@ -24,30 +24,15 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - # Set up cibuildwheel. - # - - name: cibuildwheel - uses: pypa/cibuildwheel@v2.11.2 - + - name: test_mupdf-master-branch env: - # PYMUPDF_SETUP_MUPDF_TGZ="": don't embed mupdf in sdist - no need - # because the build stage gets MuPDF using `git clone ...`. - # - # PYMUPDF_SETUP_MUPDF_BUILD="git:...": build with mupdf from a `git - # clone` command, selecting the current master branch. - # - CIBW_ENVIRONMENT: PYMUPDF_SETUP_MUPDF_TGZ="" PYMUPDF_SETUP_MUPDF_BUILD="git:--recursive --depth 1 --shallow-submodules --branch master https://github.com/ArtifexSoftware/mupdf.git" - - # Build on single cpu. - CIBW_ARCHS_LINUX: x86_64 - - # Build for single python version. - CIBW_BUILD: "cp311*" - - # Don't build for unsupported platforms. - CIBW_SKIP: "pp* *i686 *-musllinux_* cp36*" - - # Get cibuildwheel to run pytest with each wheel. - CIBW_TEST_REQUIRES: "fontTools pytest psutil" - CIBW_TEST_COMMAND: "python {project}/tests/run_compound.py pytest -s {project}/tests" - CIBW_BUILD_VERBOSITY: 3 + inputs_PYMUPDF_SETUP_MUPDF_BUILD: "git:--recursive --depth 1 --shallow-submodules --branch master https://github.com/ArtifexSoftware/mupdf.git" + inputs_flavours: "0" + inputs_sdist: "0" + inputs_wheels_cps: "cp312*" + inputs_wheels_default: "0" + inputs_wheels_linux_auto: "1" + inputs_wheels_macos_auto: "1" + inputs_wheels_windows_auto: "1" + run: + python scripts/gh_release.py diff --git a/.github/workflows/test_mupdf-release-branch.yml b/.github/workflows/test_mupdf-release-branch.yml index 2b1ac1fd0..0b8f0d1da 100644 --- a/.github/workflows/test_mupdf-release-branch.yml +++ b/.github/workflows/test_mupdf-release-branch.yml @@ -25,30 +25,15 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - # Set up cibuildwheel. - # - - name: cibuildwheel - uses: pypa/cibuildwheel@v2.11.2 - + - name: test_mupdf-master-branch env: - # PYMUPDF_SETUP_MUPDF_TGZ="": don't embed mupdf in sdist - no need - # because the build stage gets MuPDF using `git clone ...`. - # - # PYMUPDF_SETUP_MUPDF_BUILD="git:...": build with mupdf from a `git - # clone` command, selecting the current release branch. - # - CIBW_ENVIRONMENT: PYMUPDF_SETUP_MUPDF_TGZ="" PYMUPDF_SETUP_MUPDF_BUILD="git:--recursive --depth 1 --shallow-submodules --branch 1.23.x https://github.com/ArtifexSoftware/mupdf.git" - - # Build on single cpu. - CIBW_ARCHS_LINUX: x86_64 - - # Build for single python version. - CIBW_BUILD: "cp311*" - - # Don't build for unsupported platforms. - CIBW_SKIP: "pp* *i686 *-musllinux_* cp36*" - - # Get cibuildwheel to run pytest with each wheel. - CIBW_TEST_REQUIRES: "fontTools pytest psutil" - CIBW_TEST_COMMAND: "python {project}/tests/run_compound.py pytest -s {project}/tests" - CIBW_BUILD_VERBOSITY: 3 + inputs_PYMUPDF_SETUP_MUPDF_BUILD: "git:--recursive --depth 1 --shallow-submodules --branch 1.23.x https://github.com/ArtifexSoftware/mupdf.git" + inputs_flavours: "0" + inputs_sdist: "0" + inputs_wheels_cps: "cp312*" + inputs_wheels_default: "0" + inputs_wheels_linux_auto: "1" + inputs_wheels_macos_auto: "1" + inputs_wheels_windows_auto: "1" + run: + python scripts/gh_release.py diff --git a/.github/workflows/test_quick.yml b/.github/workflows/test_quick.yml index 68dd6fc89..31d9d42da 100644 --- a/.github/workflows/test_quick.yml +++ b/.github/workflows/test_quick.yml @@ -13,12 +13,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - # We test on just Ubuntu, with hard-coded MuPDF, MuPDF master, and current MuPDF branch. + # We test on just Ubuntu with MuPDF master. # os: [ubuntu-latest] - environment: [ - 'PYMUPDF_SETUP_MUPDF_TGZ="" PYMUPDF_SETUP_MUPDF_BUILD="git:--recursive --depth 1 --shallow-submodules --branch master https://github.com/ArtifexSoftware/mupdf.git"', - ] # Avoid cancelling of all cibuildwheel runs after a single failure. fail-fast: false @@ -28,22 +25,16 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - - name: cibuildwheel - uses: pypa/cibuildwheel@v2.11.2 + - name: test_quick env: - CIBW_ENVIRONMENT: ${{matrix.environment}} - - # Build on single cpu. - CIBW_ARCHS_LINUX: x86_64 - - # Build for single python version. - CIBW_BUILD: "cp311*" - - # Don't build for unsupported platforms or win32. - CIBW_SKIP: "pp* *i686 *-musllinux_* cp36* *win32*" - - # Get cibuildwheel to run pytest with each wheel. - CIBW_TEST_REQUIRES: "fontTools pytest psutil" - CIBW_TEST_COMMAND: "python {project}/tests/run_compound.py pytest -s {project}/tests" - CIBW_BUILD_VERBOSITY: 3 + inputs_PYMUPDF_SETUP_MUPDF_BUILD: "git:--recursive --depth 1 --shallow-submodules --branch master https://github.com/ArtifexSoftware/mupdf.git" + inputs_flavours: "0" + inputs_sdist: "0" + inputs_wheels_cps: "cp312*" + inputs_wheels_default: "0" + inputs_wheels_linux_auto: "1" + inputs_wheels_macos_auto: "1" + inputs_wheels_windows_auto: "1" + run: + python scripts/gh_release.py