Skip to content

Commit

Permalink
Merge pull request conda-forge#1882 from jakirkham/update_gha_free_space
Browse files Browse the repository at this point in the history
  • Loading branch information
beckermr authored Mar 22, 2024
2 parents 77375ed + bcc16c4 commit 12be4c3
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
27 changes: 27 additions & 0 deletions conda_smithy/data/conda-forge.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,33 @@
"description": "Whether to cancel jobs in the same build if one fails.",
"title": "Cancel In Progress"
},
"free_disk_space": {
"anyOf": [
{
"type": "boolean"
},
{
"$ref": "#/$defs/Nullable"
},
{
"items": {
"enum": [
"apt",
"cache",
"docker"
],
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": false,
"description": "Free up disk space before running the Docker container for building on Linux.\nThe following components can be cleaned up: `apt`, `cache`, `docker`.\nWhen set to `true`, only `apt` and `cache` are cleaned up.\nSet it to the full list to clean up all components.",
"title": "Free Disk Space"
},
"max_parallel": {
"anyOf": [
{
Expand Down
1 change: 1 addition & 0 deletions conda_smithy/data/conda-forge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ github:
github_actions:
artifact_retention_days: 14
cancel_in_progress: true
free_disk_space: false
max_parallel: null
self_hosted: false
store_build_artifacts: false
Expand Down
14 changes: 14 additions & 0 deletions conda_smithy/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,20 @@ class GithubActionsConfig(BaseModel):
default=True,
)

free_disk_space: Optional[
Union[bool, Nullable, List[Literal["apt", "cache", "docker"]]]
] = Field(
default=False,
description=cleandoc(
"""
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.
"""
),
)

max_parallel: Optional[Union[int, Nullable]] = Field(
description="The maximum number of jobs to run in parallel",
default=None,
Expand Down
6 changes: 6 additions & 0 deletions conda_smithy/templates/github-actions.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
- name: Manage disk space
if: matrix.os == 'ubuntu'
run: |
{%- if (github_actions.free_disk_space == true) or ('cache' in github_actions.free_disk_space) %}
sudo mkdir -p /opt/empty_dir || true
for d in \
/opt/ghc \
Expand All @@ -74,12 +75,17 @@ jobs:
; do
sudo rsync --stats -a --delete /opt/empty_dir/ $d || true
done
{%- endif %}
{%- if (github_actions.free_disk_space == true) or ('apt' in github_actions.free_disk_space) %}
sudo apt-get purge -y -f firefox \
google-chrome-stable \
microsoft-edge-stable
sudo apt-get autoremove -y >& /dev/null
sudo apt-get autoclean -y >& /dev/null
{%- endif %}
{%- if (github_actions.free_disk_space is iterable) and ('docker' in github_actions.free_disk_space) %}
sudo docker image prune --all --force
{%- endif %}
df -h
{%- endif %}

Expand Down
23 changes: 23 additions & 0 deletions news/update_gha_free_space.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* Add ``github_actions.free_disk_space`` to schema ( #1882 )

**Changed:**

* Update ``github_actions.free_disk_space`` to match Azure's ( #1882 )

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>

0 comments on commit 12be4c3

Please sign in to comment.