Skip to content

Add workflow_settings.free_disk_space#2568

Open
mgorny wants to merge 22 commits into
conda-forge:mainfrom
mgorny:workflow-settings-free-disk-space
Open

Add workflow_settings.free_disk_space#2568
mgorny wants to merge 22 commits into
conda-forge:mainfrom
mgorny:workflow-settings-free-disk-space

Conversation

@mgorny
Copy link
Copy Markdown
Contributor

@mgorny mgorny commented Jun 2, 2026

Checklist

  • Added a news entry with any new deprecations added to the Deprecated section.
  • Regenerated schema JSON if schema altered (python -m conda_smithy.schema)
  • Regenerated linter documentation if any rules were added, removed or modified (python -m conda_smithy.linter.messages)

Part of issue #2349
Fixes #1949
Closes #1966

Add a new workflow_settings.free_disk_space setting as a replacement for the legacy azure.free_disk_space and
github_actions.free_disk_space. The old values are converted automatically. All values are also normalized to arrays to simplify templates. The values can be conditional to individual jobs.

Progress:

  • GHA template support
  • Azure template support
  • Tests
  • osx/win support

Add a new `workflow_settings.free_disk_space` setting as a replacement
for the legacy `azure.free_disk_space` and
`github_actions.free_disk_space`.  The old values are converted
automatically.  All values are also normalized to arrays to simplify
templates.  The values can be conditional to individual jobs.

Signed-off-by: Michał Górny <mgorny@quansight.com>
Comment thread conda_smithy/schema.py Outdated
] = Field(
default=[],
description=cleandoc("""
Free up disk space before running the Docker container for building on Linux.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it Linux only? 🤔 I thought we were going to do it OS-agnostic too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I suppose extending to other systems could be handled as a separate PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See #1949; John had a draft to extend this to windows in #1966

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I can live with deferring other platforms to a separate PR, but then we need some thought how os-specific workflow_settings will work. IMO there should be an error in smithy if someone does

workflow_settings:
  free_disk_space: true

because it gives the false impression of being cross-platform.

build_workspace_dir already has a platform-specific warning (e.g. for setting windows paths on unix), so hopefully this should be a ~solved problem already.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'll start looking into other platforms.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, added macOS and Windows; with Windows supporting only cache and macOS not doing anything right now. Does anyone have a suggestion what we should be cleaning there?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The description here needs an update, in one way or another

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread conda_smithy/templates/github-actions.yml.tmpl
mgorny added 5 commits June 2, 2026 19:06
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
We've used `rsync` to workaround historical `rm` inefficiency but that's
no longer the case.  From a quick testing, both commands involve roughly
the same syscalls, and there is no noticeable difference on GHA.

Signed-off-by: Michał Górny <mgorny@quansight.com>
Comment thread conda_smithy/templates/free_disk_space.sh.tmpl Outdated
mgorny added 2 commits June 3, 2026 13:05
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
@mgorny
Copy link
Copy Markdown
Contributor Author

mgorny commented Jun 3, 2026

Demo feedstock: conda-forge/polars-feedstock#380

@mgorny
Copy link
Copy Markdown
Contributor Author

mgorny commented Jun 3, 2026

I can't reproduce the test failure locally. I suspect the schema generation is not reproducible.

mgorny added 3 commits June 3, 2026 16:11
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
@mgorny mgorny marked this pull request as ready for review June 3, 2026 18:57
@mgorny mgorny requested a review from a team as a code owner June 3, 2026 18:57
@h-vetinari
Copy link
Copy Markdown
Member

h-vetinari commented Jun 4, 2026

If you squint a bit, the following could also be considered freeing making more disk space usable.

{%- if github_actions.resize_win_partitions %}
# https://github.com/aktech/cirun-azure-resize-disk
- name: Resize all partitions to maximum
if: matrix.os == 'windows'

Not sure if/how we want to unify these things, but the named-arg-style approach already used linux might also be applicable to windows?

@mgorny
Copy link
Copy Markdown
Contributor Author

mgorny commented Jun 4, 2026

Yeah, I suppose that'd work, and it would definitely make sense to avoid inlining that script.

Signed-off-by: Michał Górny <mgorny@quansight.com>
@mgorny
Copy link
Copy Markdown
Contributor Author

mgorny commented Jun 4, 2026

Not sure if/how we want to unify these things, but the named-arg-style approach already used linux might also be applicable to windows?

To be honest, I'd keep it as a separate key. It's not like keys are expensive, and the backwards compatibility logic would end up being a bit messy here. And in the end, resize_partitions: true is more obvious than free_disk_space: resize-partitions or likewise. Or perhaps even:

workflow_settings:
  free_disk_space:
    - os: win
      value: resize-partitions
    - os: linux
      value: true

@mgorny
Copy link
Copy Markdown
Contributor Author

mgorny commented Jun 4, 2026

Either way, I'd like to avoid adding more into this PR. We can add new functions as a followup, but I'd like to get what we have now reviewed.

Copy link
Copy Markdown
Member

@h-vetinari h-vetinari left a comment

Choose a reason for hiding this comment

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

Thinking about the interface here, and how to deal with platform-specific stuff in an ostensibly cross-platform value:

Comment thread conda_smithy/templates/azure-pipelines-linux.yml.tmpl Outdated
Comment thread conda_smithy/templates/free_disk_space.sh.tmpl
Comment thread conda_smithy/schema.py
Comment on lines +555 to +561
bool,
list[Literal["apt", "cache", "docker"]],
list[
conditional_value(
Union[bool, list[Literal["apt", "cache", "docker"]]], False
)
],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm unsure about the multi-type approach here, and mixing in platform-specific options. I think it may be cleaner/simpler to either do

free_disk_space: Optional[Union[Literal[None, "quick", "extensive"]]]

(or however the bikeshed is coloured), which would trade granularity for an easier interface1; or alternatively, we could make free_disk_space: Optional[bool] to just mean the cache portion, and introduce separate (but linux-specific-by-definition) switches for cleaning up docker & apt.

Footnotes

  1. because, let's face it, for recipe authors it's a simple trade-off of "make my recipe pass" vs. "how much extra time does my CI take"

Copy link
Copy Markdown
Member

@jaimergp jaimergp Jun 5, 2026

Choose a reason for hiding this comment

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

I mean, it could be both:

Union[
	bool,  # true -> quick
	Literal["all"], # opt-in to everything
	list[Literal["apt", "cache", "docker"]],  # as granular as it gets
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What I'm not super keen on is implying that apt or docker are legitimate values anywhere but on linux. But perhaps I'm over-designing this? Could be that it's not that important.

My comment is based on the fact that I've only ever seen true or the full set of apt, cache, docker for this, so I'm wondering if this granularity really buys us anything? I kinda like quick vs. extensive (or all), that should IMO provide enough for what recipe authors use this for.

BTW, I've used this PR today in conda-forge/pyg-lib-feedstock@6274e01, and I think that

workflow_settings:
  free_disk_space:
    - value: ["apt", "cache", "docker"]
      os: linux

looks weird? I mean having value: (itself already a list item) be again a list itself.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If we're changing the format, then perhaps let's avoid lists indeed (it would also make the code cleaner). I'm fine with strings or string/bool, or even CSV for granularity.

One thing to consider is backwards compatibility, but I don't think there would be any harm even if we said that, say, apt alone is not supported anymore and either fall to not cleaning at all or cleaning more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, how about either:

  • if we want real booleans, false / true / "all"
  • if we just strings for fewer types: "no" / "quick" / "all"

?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"no" / "quick" / "all"

I like this 👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd maybe change "all" to "max". We're not deleting all things in the image after all, just the most we can. And "max" describes that more accurately, both in the sense of what can be deleted, as well as what we have actually implemented (or deemed worth implementing).

Comment thread conda_smithy/schema.py Outdated
] = Field(
default=[],
description=cleandoc("""
Free up disk space before running the Docker container for building on Linux.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The description here needs an update, in one way or another

@h-vetinari h-vetinari force-pushed the workflow-settings-free-disk-space branch from 2a52cd4 to d5c333f Compare June 4, 2026 21:21
Comment thread conda_smithy/templates/free_disk_space.sh.tmpl
Comment thread conda_smithy/templates/free_disk_space.sh.tmpl
Comment thread conda_smithy/templates/free_disk_space.sh.tmpl Outdated
Comment thread conda_smithy/templates/free_disk_space.sh.tmpl Outdated
Comment thread conda_smithy/templates/free_disk_space.sh.tmpl
Comment thread conda_smithy/templates/free_disk_space.sh.tmpl Outdated
Comment thread conda_smithy/templates/free_disk_space.sh.tmpl Outdated
Comment thread conda_smithy/templates/free_disk_space.sh.tmpl
Comment thread conda_smithy/schema.py Outdated
Comment on lines +567 to +570
Free up disk space before running the Docker container for building on Linux.
The following components can be cleaned up: `apt`, `cache`, `docker`.
When set to `true`, only `apt` and `cache` are cleaned up.
Set it to the full list to clean up all components.
Copy link
Copy Markdown
Member

@jaimergp jaimergp Jun 5, 2026

Choose a reason for hiding this comment

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

My suggested description:

Suggested change
Free up disk space before running the Docker container for building on Linux.
The following components can be cleaned up: `apt`, `cache`, `docker`.
When set to `true`, only `apt` and `cache` are cleaned up.
Set it to the full list to clean up all components.
Free up disk space before running the builds.
- On Linux, the following components can be cleaned up:
`apt`, `cache`, `docker`. When set to `true`, only `apt`
and `cache` are used. Set it to the full list to
clean up all components.
- On macOS, only `cache` is supported (same as `true`).
- On Windows, only `cache` is supported (same as `true`).
Note that only `C:/` is cleaned up, so this is only useful
if you are targeting this drive via `build_workspace_dir`,
`tools_install_dir`, or `pagefile_size`.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Uh, sorry, changed it prior to getting down to your comment. However, let's discuss the actual values first perhaps :-).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Jaime 👍'd your comment about changing away from list-as-value. So it appears that the next step would be to make a proposal how that would look like.

mgorny and others added 9 commits June 5, 2026 13:11
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Co-authored-by: jaimergp <jaimergp@users.noreply.github.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Signed-off-by: Michał Górny <mgorny@quansight.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: extend free_disk_space to windows?

3 participants