Run Jenkins Python helpers through uv and clarify Xvfb setup
This commit is contained in:
parent
54cb479f4b
commit
3000833ac9
|
|
@ -2212,7 +2212,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "pdf-presenter"
|
||||
version = "0.1.17"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"chrono",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ default-members = ["crates/pdf-presenter"]
|
|||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.17"
|
||||
version = "0.1.18"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
repository = "https://proxy.dandaedre.com/gitea/idle-org/pdf-presenter"
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ pipeline {
|
|||
steps {
|
||||
deleteDir()
|
||||
checkout scm
|
||||
sh 'python3 scripts/ci.py init'
|
||||
sh 'uv run --no-project --python ">=3.11" python scripts/ci.py init'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -29,9 +29,13 @@ pipeline {
|
|||
steps {
|
||||
sh '''
|
||||
set -eu
|
||||
python3 -c 'import sys; assert sys.version_info >= (3, 11), "Python 3.11+ required for CI"'
|
||||
uv run --no-project --python ">=3.11" python -c 'import sys; assert sys.version_info >= (3, 11), "Python 3.11+ required for CI"'
|
||||
test -n "${BRANCH_NAME:?Configure this job as a Multibranch Pipeline}"
|
||||
command -v Xvfb
|
||||
if ! command -v Xvfb >/dev/null 2>&1; then
|
||||
echo 'Xvfb is missing from the Jenkins worker PATH. uv manages Python, not the X server.' >&2
|
||||
echo 'Provision the worker with xvfb (Debian/Ubuntu) or xorg-vfbserver (FreeBSD), then rerun.' >&2
|
||||
exit 1
|
||||
fi
|
||||
uname -sr
|
||||
rustc --version
|
||||
if ! cargo llvm-cov --version | grep -Fx 'cargo-llvm-cov 0.9.1'; then
|
||||
|
|
@ -59,23 +63,23 @@ pipeline {
|
|||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE', catchInterruptions: false) {
|
||||
sh '''
|
||||
set -eu
|
||||
python3 -m unittest discover -s tests -v
|
||||
python3 scripts/gui_ci.py cargo test --locked --workspace --all-features
|
||||
uv run --no-project --python ">=3.11" python -m unittest discover -s tests -v
|
||||
uv run --no-project --python ">=3.11" python scripts/gui_ci.py cargo test --locked --workspace --all-features
|
||||
cargo build --locked --workspace --all-features
|
||||
python3 scripts/ci.py tests-passed
|
||||
uv run --no-project --python ">=3.11" python scripts/ci.py tests-passed
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Coverage') {
|
||||
steps { sh 'python3 scripts/gui_ci.py python3 scripts/ci.py coverage' }
|
||||
steps { sh 'uv run --no-project --python ">=3.11" python scripts/gui_ci.py python scripts/ci.py coverage' }
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
cleanup {
|
||||
script {
|
||||
sh 'python3 scripts/ci.py finalize'
|
||||
sh 'uv run --no-project --python ">=3.11" python scripts/ci.py finalize'
|
||||
archiveArtifacts artifacts: 'coverage/version.svg,coverage/test.svg,coverage/coverage.svg',
|
||||
fingerprint: true, allowEmptyArchive: false
|
||||
if (env.BRANCH_NAME == 'main' && !env.CHANGE_ID) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,13 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
### 0.1.18
|
||||
|
||||
- Use uv-selected Python 3.11+ throughout Jenkins, including badge initialization,
|
||||
cleanup, helper tests and nested coverage execution. Launcher tests reuse that interpreter.
|
||||
- Explain missing Xvfb with worker provisioning instructions; uv manages Python
|
||||
and cannot replace the native X server required by GUI tests. Keep GUI coverage mandatory.
|
||||
|
||||
### 0.1.17
|
||||
|
||||
- Embed application icons in all native windows and the Windows executable.
|
||||
|
|
|
|||
|
|
@ -5,23 +5,34 @@ Create a Jenkins Multibranch Pipeline for `idle-org/pdf-presenter`, using the ro
|
|||
upload does not create a Jenkins job. Configure branch discovery and a Gitea webhook
|
||||
in Jenkins/Gitea when connecting the job.
|
||||
|
||||
The worker needs Rust, rustup, Python 3.11+, POSIX shell/awk/sed and a writable
|
||||
`/mnt/assets/coverage`. Native GUI CI additionally requires Xvfb and ordinary X11
|
||||
The worker needs Rust, rustup, uv, POSIX shell/awk/sed and a writable
|
||||
`/mnt/assets/coverage`. Every Jenkins Python invocation uses
|
||||
`uv run --no-project --python ">=3.11" python`, including initial/final badges and
|
||||
coverage. uv selects a compatible installed Python or downloads one where supported;
|
||||
no system `python3` alias or project virtual environment is required. On workers
|
||||
without a supported uv-managed Python build (including FreeBSD), provision Python
|
||||
3.11+ for uv to discover.
|
||||
|
||||
Native GUI CI additionally requires Xvfb and ordinary X11
|
||||
client libraries (on FreeBSD install `xorg-vfbserver` and the required X11 packages). The pipeline installs cargo-llvm-cov 0.9.1 and the rustfmt,
|
||||
Clippy and llvm-tools-preview components. It builds and tests without a sibling
|
||||
checkout or PDF renderer. `scripts/gui_ci.py` starts an isolated Xvfb server for
|
||||
tests/coverage, waits at most 10 seconds for readiness and always cleans it up.
|
||||
It enables the native smoke integration test. Missing Xvfb fails explicitly; GUI
|
||||
It enables the native smoke integration test. `uv` does not supply Xvfb: an
|
||||
administrator must provision the Jenkins worker (`apt-get install xvfb` on
|
||||
Debian/Ubuntu, or `pkg install xorg-vfbserver` on FreeBSD) and expose it on PATH.
|
||||
A failure at `command -v Xvfb` means that prerequisite is missing, not a Python
|
||||
version error. Missing Xvfb fails with provisioning guidance; GUI
|
||||
production code is never excluded from coverage.
|
||||
|
||||
```sh
|
||||
python3 -m unittest discover -s tests -v
|
||||
uv run --no-project --python ">=3.11" python -m unittest discover -s tests -v
|
||||
cargo fmt --all --check
|
||||
cargo clippy --locked --workspace --all-targets --all-features -- -D warnings
|
||||
cargo test --locked --workspace --all-features
|
||||
cargo build --locked --workspace --all-features
|
||||
RUSTDOCFLAGS="-D warnings" cargo doc --locked --workspace --all-features --no-deps
|
||||
PDF_PRESENTER_GUI_TESTS=1 python3 scripts/ci.py coverage
|
||||
PDF_PRESENTER_GUI_TESTS=1 uv run --no-project --python ">=3.11" python scripts/ci.py coverage
|
||||
```
|
||||
|
||||
Coverage measures the entire Rust workspace with a 75% floor. Add all future
|
||||
|
|
@ -39,7 +50,7 @@ worker configuration or prove the remote pipeline has run.
|
|||
|
||||
|
||||
The coverage command above needs a usable desktop session. On a headless POSIX host,
|
||||
run `python3 scripts/gui_ci.py python3 scripts/ci.py coverage` instead. To include
|
||||
run `uv run --no-project --python ">=3.11" python scripts/gui_ci.py python scripts/ci.py coverage` instead. To include
|
||||
native smoke in local workspace tests, set `PDF_PRESENTER_GUI_TESTS=1`. Without it,
|
||||
the ordinary tests remain headless and explicitly skip native-window smoke. CI sets
|
||||
it through the virtual-display wrapper for both tests and coverage. Xvfb tests cannot
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ def run(command):
|
|||
raise ValueError("usage: gui_ci.py COMMAND [ARGS...]")
|
||||
xvfb = shutil.which("Xvfb")
|
||||
if xvfb is None:
|
||||
raise RuntimeError("Xvfb is required for native GUI CI/coverage (install xorg-vfbserver on FreeBSD)")
|
||||
raise RuntimeError("Xvfb is required for native GUI CI/coverage; uv cannot install the X server. Provision the worker with xvfb (Debian/Ubuntu) or xorg-vfbserver (FreeBSD), and put Xvfb on PATH.")
|
||||
reader, writer = os.pipe()
|
||||
server = None
|
||||
with tempfile.TemporaryFile() as log:
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class GuiCiTests(unittest.TestCase):
|
|||
def test_missing_server_or_command_fails_explicitly(self):
|
||||
with self.assertRaises(ValueError):
|
||||
gui.run([])
|
||||
with patch.object(gui.shutil, "which", return_value=None), self.assertRaises(RuntimeError):
|
||||
with patch.object(gui.shutil, "which", return_value=None), self.assertRaisesRegex(RuntimeError, "uv cannot install the X server"):
|
||||
gui.run([sys.executable, "-c", "pass"])
|
||||
|
||||
def test_child_receives_isolated_display_and_exit_status_survives(self):
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import importlib.util
|
|||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
|
@ -30,11 +31,11 @@ class LauncherTests(unittest.TestCase):
|
|||
(bundle / 'pdf-presenter').touch()
|
||||
(bundle / 'pdf-presenter.png').touch()
|
||||
env = dict(os.environ, XDG_DATA_HOME=str(root / 'data'))
|
||||
subprocess.run(['python3', str(script)], env=env, check=True, capture_output=True)
|
||||
subprocess.run([sys.executable, str(script)], env=env, check=True, capture_output=True)
|
||||
installed = root / 'data/applications/pdf-presenter.desktop'
|
||||
self.assertEqual(installed.read_text(), launcher.desktop_entry(
|
||||
bundle / 'pdf-presenter', bundle / 'pdf-presenter.png'))
|
||||
(bundle / 'pdf-presenter').unlink()
|
||||
result = subprocess.run(['python3', str(script)], env=env, capture_output=True)
|
||||
result = subprocess.run([sys.executable, str(script)], env=env, capture_output=True)
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertTrue(installed.is_file())
|
||||
|
|
|
|||
Loading…
Reference in New Issue