Skip to content

ENH: Drop *.o/*.a between ctest_build and ctest_test#6322

Merged
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:dashboardfrom
hjmjohnson:dashboard-cleanup-objects-before-test
May 21, 2026
Merged

ENH: Drop *.o/*.a between ctest_build and ctest_test#6322
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:dashboardfrom
hjmjohnson:dashboard-cleanup-objects-before-test

Conversation

@hjmjohnson
Copy link
Copy Markdown
Member

Adds an automatic post-build, pre-test cleanup step to itk_common.cmake that deletes intermediate *.o and *.a files from CTEST_BINARY_DIRECTORY between ctest_build and ctest_test. Free disk for the test phase on size-constrained CI runners (the GitHub Actions Ubuntu 22.04 runner has ~73 GiB root with ~2 GiB free immediately post-build; tests can hit "No space left on device" before they get a chance to run).

What this does

Just after ctest_build returns and before ctest_test is called, the script removes every *.o and *.a under CTEST_BINARY_DIRECTORY. The linked executables and shared libraries are already complete at this point; the intermediates aren't needed by ctest_test, ctest_memcheck, or ctest_submit.

Two opt-outs:

  • dashboard_do_coverage — automatic skip. gcov needs the .gcno note files colocated with the corresponding .o files in the build tree.
  • dashboard_keep_objects — new per-client opt-out, e.g. for clients that re-link incrementally between dashboard iterations.

The step is wrapped in a CI fold (ci_section_start / ci_section_end "Free build-tree object files") so it appears next to the build and test sections in the GitHub Actions log.

Motivating CI failure

From PR #6318's Pixi-Cxx (ubuntu-22.04) job:

****** df -h /  -- post build
/dev/root        73G   71G  2.0G  98% /
****** df -h /  -- post cleanup
/dev/root        73G   63G   11G  87% /
...
System.IO.IOException: No space left on device :
  '/home/runner/actions-runner/cached/2.334.0/_diag/Worker_20260521-171155-utc.log'

The GitHub Actions workflow has been working around this by running find build -type f -name "*.o" -delete + find build -type f -name "*.a" -delete in a dedicated "Free disk space after build" step (see .github/workflows/itk.pixi.yml). This PR moves that same logic into the canonical dashboard script so it applies to every consumer of itk_common.cmake (Azure, CircleCI, Jenkins, custom nightly clients) — not just GitHub Actions.

@github-actions github-actions Bot added the type:Enhancement Improvement of existing methods or implementation label May 21, 2026
@hjmjohnson hjmjohnson marked this pull request as ready for review May 21, 2026 18:30
Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I have not tried running this. It would be good if someone else took a look.

@dzenanz dzenanz requested review from blowekamp and thewtex May 21, 2026 18:32
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 21, 2026

Greptile Summary

This PR adds an automatic post-build, pre-test step to itk_common.cmake that removes all *.o and *.a files under CTEST_BINARY_DIRECTORY to free disk space on constrained CI runners. Two opt-outs are provided: an automatic skip when dashboard_do_coverage is set (gcov requires .gcno files colocated with .o), and a new dashboard_keep_objects flag for incremental-relinking clients.

  • The file(GLOB_RECURSE) + file(REMOVE) pattern is correct CMake idiom; LIST_DIRECTORIES FALSE ensures no directory paths contaminate the list passed to file(REMOVE).
  • The cleanup only covers Unix-style intermediates (*.o, *.a); MSVC builds produce .obj and .lib instead, so Windows CI runners facing the same disk-pressure issue would see no benefit.
  • ci_section_start / ci_section_end bracket the entire block including the zero-file case, producing an empty log fold on Windows or when the build produced no intermediates.

Confidence Score: 4/5

Safe to merge for Linux/macOS CI; Windows runners won't benefit from the disk cleanup.

The change is well-scoped and the CMake idioms used are correct. The main gap is that MSVC intermediates (.obj/.lib) are not covered, so any Windows CI runner facing the same disk-pressure scenario is left unchanged. The empty CI log fold on zero-file runs is cosmetic. Both are improvement opportunities, not blocking defects.

Only itk_common.cmake changed; the cleanup block at lines 554-568 is the area to focus on.

Important Files Changed

Filename Overview
itk_common.cmake Adds a post-build, pre-test cleanup step that removes all *.o and *.a files under CTEST_BINARY_DIRECTORY using file(GLOB_RECURSE) + file(REMOVE). Two opt-outs are provided: automatic skip under dashboard_do_coverage, and a new dashboard_keep_objects flag. Logic and flow are correct for Unix/Linux targets; Windows/MSVC intermediates are not addressed.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[ctest_build] --> B[ci_report_build_diagnostics]
    B --> C{dashboard_do_coverage\nOR dashboard_keep_objects?}
    C -- Yes --> F[ci_section_start: test]
    C -- No --> D[GLOB_RECURSE *.o *.a]
    D --> E2{count > 0?}
    E2 -- Yes --> E3[file REMOVE all matched files]
    E2 -- No --> E4[no-op]
    E3 --> E5[unset variables]
    E4 --> E5
    E5 --> F
    F --> G[ctest_test]
    G --> H{dashboard_do_coverage?}
    H -- Yes --> I[ctest_coverage]
    H -- No --> J{dashboard_do_memcheck?}
    I --> J
    J -- Yes --> K[ctest_memcheck]
    J -- No --> L[ctest_submit]
    K --> L
Loading

Reviews (1): Last reviewed commit: "ENH: Drop *.o/*.a between ctest_build an..." | Re-trigger Greptile

Comment thread itk_common.cmake Outdated
Comment thread itk_common.cmake Outdated
Comment thread itk_common.cmake Outdated
Copy link
Copy Markdown
Member

@blowekamp blowekamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me. Consider windows files extensions too.

Add an automatic post-build, pre-test cleanup step to itk_common.cmake
that deletes intermediate object files (*.o) and static archives (*.a)
from CTEST_BINARY_DIRECTORY before ctest_test runs.

Linked executables and shared libraries are already complete by the
time ctest_build returns; the *.o files and *.a archives remaining in
the tree are not needed for ctest_test, ctest_memcheck, or
ctest_submit and can total many gigabytes for a default-configured
ITK build.  Removing them frees disk for the test phase, which on
size-constrained CI runners (GitHub Actions Ubuntu 22.04 has ~73 GiB
root with ~2 GiB free post-build) can otherwise reach
"No space left on device" while writing logs or large BigIO test
outputs.

The cleanup is skipped when dashboard_do_coverage is set (gcov needs
the .gcno notes co-located with the corresponding .o files in the
build tree) and can also be skipped per-client via the new
dashboard_keep_objects opt-out variable.

The step is wrapped in a CI fold (ci_section_start /
ci_section_end "cleanup_objects_*") so it appears next to the build
and test sections in the GitHub Actions log.
@hjmjohnson hjmjohnson force-pushed the dashboard-cleanup-objects-before-test branch from e6de4ac to 6ba12c3 Compare May 21, 2026 18:37
@hjmjohnson
Copy link
Copy Markdown
Member Author

Pushed 6ba12c3 addressing two greptile P2 findings:

  • Added *.obj and *.lib to the cleanup glob so Windows MSVC dashboard runners also free disk.
  • Auto-skip when dashboard_continuous is set (incremental relink in the next loop iteration would otherwise be defeated).
  • The ci_section_start/ci_section_end pair is now inside the "files found" branch — no empty fold appears when nothing matches (Windows-no-MSVC build or a partially-failed build).

@dzenanz thanks for the LGTM — these two refinements don't change the spirit of the change, just broaden it to the MSVC pipelines and tidy the log output.

@hjmjohnson hjmjohnson merged commit 62fc83a into InsightSoftwareConsortium:dashboard May 21, 2026
3 of 4 checks passed
@hjmjohnson hjmjohnson deleted the dashboard-cleanup-objects-before-test branch May 21, 2026 22:19
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 21, 2026
Widen the post-build `find build -delete` to cover `*.obj` and `*.lib`
so the windows-2022 job benefits from the same disk recovery as Linux
and macOS, and run `ccache --evict-older-than 1d` before `--cleanup`
to match the eviction policy introduced for dashboard clients in InsightSoftwareConsortium#6322.

Follow-up to InsightSoftwareConsortium#6322; that PR moved equivalent logic into
itk_common.cmake for clients that drive CTest via dashboard scripts.
The Pixi workflow runs cmake + ctest directly and so needs its own
inline cleanup.
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 21, 2026
Widen the post-build `find build -delete` to cover `*.obj` and `*.lib`
so the windows-2022 job benefits from the same disk recovery as Linux
and macOS, and run `ccache --evict-older-than 1d` before `--cleanup`
to match the eviction policy introduced for dashboard clients in InsightSoftwareConsortium#6322.

Follow-up to InsightSoftwareConsortium#6322; that PR moved equivalent logic into
itk_common.cmake for clients that drive CTest via dashboard scripts.
The Pixi workflow runs cmake + ctest directly and so needs its own
inline cleanup.
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 21, 2026
Delete Windows compiler intermediates (*.obj, *.lib) in the post-build
"Free disk space" step so windows-2022 gets the same disk recovery as
Linux and macOS, and run `ccache --evict-older-than 1d` before
`--cleanup` to match the eviction policy introduced for dashboard
clients in InsightSoftwareConsortium#6322.

Scope the deletion by path: *.obj also names Wavefront mesh fixtures
(ITKIOMeshOBJ, Cuberille) and *.lib names a DCMTK Makefile template,
so match compiled objects only under CMakeFiles/ and archives only
under lib/ to avoid removing test data before the test phase.

Follow-up to InsightSoftwareConsortium#6322; that PR moved equivalent logic into
itk_common.cmake for clients that drive CTest via dashboard scripts.
The Pixi workflow runs cmake + ctest directly and so needs its own
inline cleanup.
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 22, 2026
The post-build intermediate cleanup added in InsightSoftwareConsortium#6322 globs *.obj and *.lib
recursively under CTEST_BINARY_DIRECTORY and deletes the matches before
ctest_test. Both extensions are overloaded: *.obj also names Wavefront
mesh fixtures (ITKIOMeshOBJ Baseline/bunny.obj, box.obj; Cuberille
mesh.obj) and *.lib names a DCMTK Makefile template. GLOB_RECURSE
descends into ExternalData/, so those fixtures were removed between
build and test, failing itkOBJMeshIOTest1/2 and itkMeshFileReadWriteOBJ*
on every dashboard client (ARMBUILD, Azure ITK.* pipelines).

Scope the deletion by path: match compiled objects only under
CMakeFiles/ and archives only under lib/, where every compiler-emitted
object and archive lives on all platforms. Verified against a real
build tree: 5579 compiled objects and 148 archives still removed; all
seven *.obj mesh fixtures and the DCMTK Makefile.lib spared.
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 22, 2026
Delete Windows compiler intermediates (*.obj, *.lib) in the post-build
"Free disk space" step so windows-2022 gets the same disk recovery as
Linux and macOS, and run `ccache --evict-older-than 1d` before
`--cleanup` to match the eviction policy introduced for dashboard
clients in InsightSoftwareConsortium#6322.

Scope the deletion by path: *.obj also names Wavefront mesh fixtures
(ITKIOMeshOBJ, Cuberille) and *.lib names a DCMTK Makefile template,
so match compiled objects only under CMakeFiles/ and archives only
under lib/ to avoid removing test data before the test phase.

Follow-up to InsightSoftwareConsortium#6322; that PR moved equivalent logic into
itk_common.cmake for clients that drive CTest via dashboard scripts.
The Pixi workflow runs cmake + ctest directly and so needs its own
inline cleanup.
hjmjohnson added a commit that referenced this pull request May 22, 2026
…test-fixtures

BUG: Spare test fixtures from dashboard post-build cleanup (#6322 regression)
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 22, 2026
Delete Windows compiler intermediates (*.obj, *.lib) in the post-build
"Free disk space" step so windows-2022 gets the same disk recovery as
Linux and macOS, and run `ccache --evict-older-than 1d` before
`--cleanup` to match the eviction policy introduced for dashboard
clients in InsightSoftwareConsortium#6322.

Scope the deletion by path: *.obj also names Wavefront mesh fixtures
(ITKIOMeshOBJ, Cuberille) and *.lib names a DCMTK Makefile template,
so match compiled objects only under CMakeFiles/ and archives only
under lib/ to avoid removing test data before the test phase.

Follow-up to InsightSoftwareConsortium#6322; that PR moved equivalent logic into
itk_common.cmake for clients that drive CTest via dashboard scripts.
The Pixi workflow runs cmake + ctest directly and so needs its own
inline cleanup.
hjmjohnson added a commit that referenced this pull request May 22, 2026
…cts-and-ccache-evict

COMP: Extend Pixi-Cxx post-build cleanup to MSVC artifacts (followup #6322)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:Enhancement Improvement of existing methods or implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants