image-codecs: CI runs the tests with TIFF left out

Every CI test build enabled the `tiff` feature: the all-features run and
the default-features run both include it. The tests that check a build
without TIFF (`tiff_feature::omitted_tiff_pixels_are_refused_but_metadata_remains_readable`)
were never compiled in CI.

scripts/ci-workspace-tests.sh adds a run of craft-image-codecs with every
default codec except `tiff`: one more nextest run in the unsharded legs,
and a fourth archive and shard in the sharded Linux leg. Both are left
out when the test selection skips craft-image-codecs; the new `codecs`
step reports that, and the workflow passes it to every leg as
CRAFT_IMAGE_CODECS and picks three or four shards from it.
scripts/test-workspace-tests.py checks the new commands, the selection,
and that the feature list matches the crate's `default` features
without `tiff`.
This commit is contained in:
dotCooCoo committed 2026-11-29 21:59:00 -08:00
1 parent 6c680ec358
commit 443036a85f
3 files changed
+86 -13

No files matched your search

+8 -4
View File
@@ -42,6 +42,7 @@ jobs:
tests: ${{ steps.select.outputs.tests }}
filter: ${{ steps.select.outputs.filter }}
audit: ${{ steps.audit.outputs.audit }}
codecs: ${{ steps.audit.outputs.codecs }}
profile: ${{ steps.audit.outputs.profile }}
deps-profile: ${{ steps.audit.outputs.deps-profile }}
steps:
@@ -63,7 +64,7 @@ jobs:
select-tests: true
label: full-ci
# Whether the selection reaches a replay-audit crate, which runs the Linux leg as a build job
# and three test shards (see `native`), and the hash of the profile overrides every test build
# and three or four test shards (see `native`), and the hash of the profile overrides every test build
# passes (scripts/ci-workspace-tests.sh), which names the Workspace legs' cache entries:
# rust-cache's key does not hash these files, and an entry built with other overrides would be
# rebuilt in full on every run. Other events than a pull request check out only these files.
@@ -86,6 +87,7 @@ jobs:
CRAFT_TEST_SKIP: ${{ steps.select.outputs.skip }}
run: |
echo "audit=$(bash scripts/ci-workspace-tests.sh audit)" >> "$GITHUB_OUTPUT"
echo "codecs=$(bash scripts/ci-workspace-tests.sh codecs)" >> "$GITHUB_OUTPUT"
echo "profile=$(cat .config/cargo-dev.toml .config/cargo-ci.toml | sha256sum | cut -c1-12)" >> "$GITHUB_OUTPUT"
# An assignment, so a failure stops the step (`bash -e`) instead of naming every entry `v2-`.
deps=$(python3 -I - <<'PY'
@@ -142,6 +144,7 @@ jobs:
PROPTEST_CASES=64
CRAFT_TESTS=${{ needs.platforms.outputs.tests }}
CRAFT_TEST_FILTER=${{ needs.platforms.outputs.filter }}
CRAFT_IMAGE_CODECS=${{ needs.platforms.outputs.codecs }}
setup-command: &setup bash scripts/ci-test-inputs.sh
# The PhotoCraft corpora, keyed on the script that pins them: a hit skips the PhotoCraft
# checkout and its xtask build (1:51 on Windows).
@@ -163,12 +166,13 @@ jobs:
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
# A selection that reaches a replay-audit crate builds once in a `build` job, which writes
# three nextest archives and then runs the doctests; three shard legs run them in parallel:
# three or four nextest archives and then runs the doctests; shard legs run them in parallel:
# every selected test outside the replay audit's crates and craft-draw, those crates (run plainly,
# then the audit crates with the audit), and craft-image-codecs with default features. Any other selection
# then the audit crates with the audit), the crates with default features, and craft-image-codecs
# without TIFF when selected. Any other selection
# (and every macOS and Windows leg) builds and runs in one leg. scripts/ci-workspace-tests.sh
# holds every step.
test-shards: ${{ needs.platforms.outputs.audit == 'true' && 3 || 0 }}
test-shards: ${{ needs.platforms.outputs.audit == 'true' && (needs.platforms.outputs.codecs == 'true' && 4 || 3) || 0 }}
shard-archives: ${{ needs.platforms.outputs.audit == 'true' }}
archive-command: ${{ needs.platforms.outputs.audit == 'true' && 'bash scripts/ci-workspace-tests.sh archive' || '' }}
after-archive-command: bash scripts/ci-workspace-tests.sh doctest
+30 -3
View File
@@ -5,11 +5,13 @@
# the selection reaches no replay-audit crate
# archive the Linux build job (gate.yml `archive-command`) builds once and writes one nextest
# archive per shard: 1 every selected test outside the replay audit's crates and the
# crates shard 2 also takes, 2 those crates, 3 the default-feature crate
# crates shard 2 also takes, 2 those crates, 3 the default-feature crates, 4
# craft-image-codecs without TIFF
# shard a Linux shard leg runs its archive ($GATE_SHARD); shard 2 runs it plainly, then the
# audit crates' tests again with the audit on
# doctest the doctests, in the build job after the archives (`after-archive-command`)
# audit prints whether the selection reaches a replay-audit crate (`true` or `false`)
# codecs prints whether the selection reaches craft-image-codecs (`true` or `false`)
# full the nightly run: every test, at the full sweep and proptest counts nightly.yml leaves set
#
# CRAFT_TESTS (all, some, none) and CRAFT_TEST_FILTER are the platforms job's selection;
@@ -29,6 +31,10 @@ examples=(-p craft-aep -p craft-video --example stubicc --example h264_h264enc_b
# craft-raster3d's default build is serial. craft-text is not here: its tests all need features, and
# its craft-ui dev-dependency would build the whole UI stack a second time with default features.
default_features=(-p craft-image-codecs -p craft-raster3d --locked --profile ci "${config[@]}")
# craft-image-codecs with every default codec except TIFF, for the tests of a build that leaves TIFF
# out. scripts/test-workspace-tests.py checks this list against the crate's `default` feature.
no_tiff=(-p craft-image-codecs --no-default-features --features dds,dicom,dpx,exr,fits,iff,jp2,jpegls,jxl-encode,pnm,tga,webp,xpm
--locked --profile ci "${config[@]}")
# The replay audit (craft-libs#2336): these crates' tests again, with every memoized view that would
# replay also run for real and compared with its replay.
audit_packages=(craft-ui-contract craft-ui-widgets craft-ui-panels craft-ui-patterns craft-ui-shell craft-ui-gallery craft-menu)
@@ -64,6 +70,9 @@ case "${1:-}" in
cargo nextest run "${examples[@]}" --all-features --locked --profile ci "${config[@]}" -E "$filter" --no-tests=warn
doctests
cargo nextest run "${default_features[@]}" -E "$filter" --no-tests=warn "${targets[@]}"
if [ "${CRAFT_IMAGE_CODECS:-}" != false ]; then
cargo nextest run "${no_tiff[@]}" -E "$filter" --no-tests=warn "${targets[@]}"
fi
;;
archive)
for shard in 1 2 3; do mkdir -p "$NEXTEST_ARCHIVE_DIR/$shard"; done
@@ -75,11 +84,16 @@ case "${1:-}" in
-E "$shard_2_filter" --archive-file "$NEXTEST_ARCHIVE_DIR/2/$NEXTEST_ARCHIVE_NAME"
cargo nextest archive "${default_features[@]}" "${targets[@]}" \
-E "$filter" --archive-file "$NEXTEST_ARCHIVE_DIR/3/$NEXTEST_ARCHIVE_NAME"
if [ "${CRAFT_IMAGE_CODECS:-}" != false ]; then
mkdir -p "$NEXTEST_ARCHIVE_DIR/4"
cargo nextest archive "${no_tiff[@]}" "${targets[@]}" \
-E "$filter" --archive-file "$NEXTEST_ARCHIVE_DIR/4/$NEXTEST_ARCHIVE_NAME"
fi
;;
shard)
run=(cargo nextest run --archive-file "$NEXTEST_ARCHIVE_FILE" --workspace-remap . --profile ci --no-tests=warn)
case "${GATE_SHARD:-}" in
1 | 3) "${run[@]}" ;;
1 | 3 | 4) "${run[@]}" ;;
2) "${run[@]}"; CRAFT_UI_AUDIT_REPLAY=1 "${run[@]}" -E "$audit_crates" ;;
*) echo "unknown shard: '${GATE_SHARD:-}'" >&2; exit 2 ;;
esac
@@ -100,12 +114,25 @@ case "${1:-}" in
;;
esac
;;
codecs)
case "${CRAFT_TESTS:-all}" in
none) echo false ;;
all) echo true ;;
*)
if [[ " ${CRAFT_TEST_SKIP:-} " == *" craft-image-codecs "* ]]; then
echo false
else
echo true
fi
;;
esac
;;
full)
cargo nextest run "${all_features[@]}" --no-tests=warn "${targets[@]}"
cargo nextest run "${examples[@]}" --all-features --locked --profile ci "${config[@]}" --no-tests=warn
;;
*)
echo "usage: $0 run|archive|shard|doctest|audit|full" >&2
echo "usage: $0 run|archive|shard|doctest|audit|codecs|full" >&2
exit 2
;;
esac
+48 -6
View File
@@ -93,7 +93,7 @@ def step(name, os_name="Linux", fail="", tests="all", test_filter="all()", **env
result = subprocess.run(
["bash", str(SCRIPT), name],
env={**os.environ, "PATH": f"{tmp}:{os.environ['PATH']}", "RUNNER_OS": os_name, "FAIL": fail,
"CRAFT_TESTS": tests, "CRAFT_TEST_FILTER": test_filter,
"CRAFT_TESTS": tests, "CRAFT_TEST_FILTER": test_filter, "CRAFT_IMAGE_CODECS": "true",
"NEXTEST_ARCHIVE_DIR": str(archives), "NEXTEST_ARCHIVE_NAME": "a.tar.zst", **env},
text=True, capture_output=True, check=False, cwd=ROOT,
)
@@ -109,6 +109,8 @@ COMMON = [
CONFIG = "--config .config/cargo-dev.toml --config .config/cargo-ci.toml"
ALL = f"--workspace --all-features --locked --profile ci {CONFIG}"
DEFAULT = f"-p craft-image-codecs -p craft-raster3d --locked --profile ci {CONFIG}"
NO_TIFF_FEATURES = "dds,dicom,dpx,exr,fits,iff,jp2,jpegls,jxl-encode,pnm,tga,webp,xpm"
NO_TIFF = f"-p craft-image-codecs --no-default-features --features {NO_TIFF_FEATURES} --locked --profile ci {CONFIG}"
TARGETS = "--lib --bins --tests"
EXAMPLES = "--example stubicc --example h264_h264enc_bench"
AUDIT_PACKAGES = ("craft-ui-contract", "craft-ui-widgets", "craft-ui-panels", "craft-ui-patterns",
@@ -125,6 +127,7 @@ def run_commands(test_filter="all()"):
f"-E {test_filter} --no-tests=warn",
DOCTESTS,
f"nextest run {DEFAULT} -E {test_filter} --no-tests=warn {TARGETS}",
f"nextest run {NO_TIFF} -E {test_filter} --no-tests=warn {TARGETS}",
]
@@ -135,6 +138,7 @@ def archive_commands(directory, test_filter="all()"):
f"nextest archive {ALL} {TARGETS} {EXAMPLES} -E ({test_filter}) & ({SHARD_2}) "
f"--archive-file {directory}/2/a.tar.zst",
f"nextest archive {DEFAULT} {TARGETS} -E {test_filter} --archive-file {directory}/3/a.tar.zst",
f"nextest archive {NO_TIFF} {TARGETS} -E {test_filter} --archive-file {directory}/4/a.tar.zst",
]
@@ -162,6 +166,28 @@ class WorkspaceTests(unittest.TestCase):
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(result.stdout.splitlines(), expected)
def test_the_tiff_off_run_keeps_every_other_default_codec(self):
manifest = tomllib.loads((ROOT / "crates/image-codecs/Cargo.toml").read_text(encoding="utf-8"))
default = manifest["features"]["default"]
self.assertIn("tiff", default)
self.assertEqual(set(NO_TIFF_FEATURES.split(",")), set(default) - {"tiff"})
def test_run_omits_tiff_off_when_codecs_are_not_selected(self):
selected = "package(=craft-geom)"
for os_name in ("Linux", "macOS", "Windows"):
with self.subTest(os=os_name):
result, _ = step("run", os_name, tests="some", test_filter=selected, CRAFT_IMAGE_CODECS="false")
self.assertEqual(result.returncode, 0, result.stderr)
expected = (["powershell.exe"] if os_name == "Windows" else []) + run_commands(selected)[:-1]
self.assertEqual(result.stdout.splitlines(), expected)
def test_archive_omits_tiff_off_when_codecs_are_not_selected(self):
selected = "package(=craft-ui-widgets)"
result, made = step("archive", tests="some", test_filter=selected, CRAFT_IMAGE_CODECS="false")
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(made, ["1", "2", "3"])
self.assertEqual(result.stdout.splitlines(), archive_commands(archive_dir(result), selected)[:-1])
def test_a_selection_filters_every_nextest_run_and_none_runs_nothing(self):
selected = "package(=craft-geom) | package(=craft-svg)"
result, _ = step("run", tests="some", test_filter=selected)
@@ -176,7 +202,7 @@ class WorkspaceTests(unittest.TestCase):
selected = "package(=craft-ui-widgets) | package(=craft-svg)"
result, made = step("archive", tests="some", test_filter=selected)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(made, ["1", "2", "3"])
self.assertEqual(made, ["1", "2", "3", "4"])
self.assertEqual(result.stdout.splitlines(), archive_commands(archive_dir(result), selected))
# The audit's archive is the same build as shard 1's: only the filter and the file differ.
first, audit = (re.sub(r" -E .* --archive-file .*", "", line) for line in result.stdout.splitlines()[:2])
@@ -198,12 +224,13 @@ class WorkspaceTests(unittest.TestCase):
def test_each_shard_runs_its_archive_and_shard_2_also_audits(self):
expected = "nextest run --archive-file /a/b.tar.zst --workspace-remap . --profile ci --no-tests=warn"
# Shard 2 audits only the audit crates of its archive.
for shard, lines in (("1", [expected]), ("2", [expected, f"AUDIT {expected} -E {AUDIT}"]), ("3", [expected])):
for shard, lines in (("1", [expected]), ("2", [expected, f"AUDIT {expected} -E {AUDIT}"]), ("3", [expected]),
("4", [expected])):
with self.subTest(shard=shard):
result, _ = step("shard", GATE_SHARD=shard, NEXTEST_ARCHIVE_FILE="/a/b.tar.zst")
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(result.stdout.splitlines(), lines)
result, _ = step("shard", GATE_SHARD="4", NEXTEST_ARCHIVE_FILE="/a/b.tar.zst")
result, _ = step("shard", GATE_SHARD="5", NEXTEST_ARCHIVE_FILE="/a/b.tar.zst")
self.assertEqual(result.returncode, 2)
self.assertEqual(result.stdout, "")
@@ -217,6 +244,16 @@ class WorkspaceTests(unittest.TestCase):
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(result.stdout.strip(), expected)
def test_codecs_reports_whether_image_codecs_are_selected(self):
for tests, skip, expected in (("none", "", "false"), ("all", "craft-image-codecs", "true"),
("some", "", "true"), ("some", "craft-image-codecs", "false"),
("some", "craft-svg craft-image-codecs craft-geom", "false"),
("some", "craft-image-codecs-extra other-craft-image-codecs", "true")):
with self.subTest(tests=tests, skip=skip):
result, _ = step("codecs", tests=tests, CRAFT_TEST_SKIP=skip)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(result.stdout.strip(), expected)
def test_each_stage_failure_remains_fatal(self):
for index, command in enumerate(COMMON):
with self.subTest(block="lint-command", command=command):
@@ -305,7 +342,11 @@ class WorkspaceTests(unittest.TestCase):
self.assertIn(" native:\n name: Workspace\n needs: platforms\n", source)
self.assertIn(" select-tests: true\n", source)
self.assertIn(" CRAFT_TESTS=${{ needs.platforms.outputs.tests }}\n"
" CRAFT_TEST_FILTER=${{ needs.platforms.outputs.filter }}\n", source)
" CRAFT_TEST_FILTER=${{ needs.platforms.outputs.filter }}\n"
" CRAFT_IMAGE_CODECS=${{ needs.platforms.outputs.codecs }}\n", source)
self.assertIn(' echo "codecs=$(bash scripts/ci-workspace-tests.sh codecs)" >> "$GITHUB_OUTPUT"\n', source)
self.assertIn(" codecs: ${{ steps.audit.outputs.codecs }}\n", source)
self.assertIn(" CRAFT_TEST_SKIP: ${{ steps.select.outputs.skip }}\n", source)
self.assertIn(" env: *env\n", source)
# The macOS and Windows legs run the Linux leg's blocks and steps, not copies of them.
self.assertIn(" lint-command: &lint |\n", source)
@@ -315,7 +356,8 @@ class WorkspaceTests(unittest.TestCase):
self.assertNotIn("windows-command", source)
# Only the Linux leg splits into a build job and shards, and only for the audit.
self.assertEqual(source.count("test-shards:"), 1)
self.assertIn("test-shards: ${{ needs.platforms.outputs.audit == 'true' && 3 || 0 }}", source)
self.assertIn("test-shards: ${{ needs.platforms.outputs.audit == 'true' && "
"(needs.platforms.outputs.codecs == 'true' && 4 || 3) || 0 }}", source)
# The Linux leg's entry, which keeps workspace crates, is named after every profile override;
# the macOS and Windows legs' dependency-only entries after the settings that reach a
# dependency (test_profile_overrides_name_only_workspace_members).