Skip to content

Commit

Permalink
.github/workflows/test*: Use scripts/*.py instead of complex yml code.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
julian-smith-artifex-com committed Dec 7, 2023
1 parent 5e03d48 commit 3837e79
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 208 deletions.
89 changes: 5 additions & 84 deletions .github/workflows/test-valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
51 changes: 0 additions & 51 deletions .github/workflows/test.yml

This file was deleted.

37 changes: 11 additions & 26 deletions .github/workflows/test_mupdf-master-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
37 changes: 11 additions & 26 deletions .github/workflows/test_mupdf-release-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
33 changes: 12 additions & 21 deletions .github/workflows/test_quick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 3837e79

Please sign in to comment.