Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,142 @@ jobs:
exit 1
fi

max-skip-cached-node-precedence:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Capture Pre-Action Toolcache State
shell: bash
run: |
set -euo pipefail

tools_dir="${RUNNER_TOOL_CACHE:-${AGENT_TOOLSDIRECTORY:-/opt/hostedtoolcache}}"
echo "TOOLS_DIR=${tools_dir}" >> "$GITHUB_ENV"

if [ -d "${tools_dir}/node" ] || [ -d "${tools_dir}/Node" ]; then
echo "NODE_CACHE_PRE=1" >> "$GITHUB_ENV"
else
echo "NODE_CACHE_PRE=0" >> "$GITHUB_ENV"
fi

if [ -d "${tools_dir}/Python" ] || [ -d "${tools_dir}/python" ]; then
echo "PYTHON_CACHE_PRE=1" >> "$GITHUB_ENV"
else
echo "PYTHON_CACHE_PRE=0" >> "$GITHUB_ENV"
fi

- name: Max Profile Skip Cached Node
uses: ./
with:
cleanup-profile: max
skip-components: " CACHED-Node "

- name: Verify Cached Node Is Kept But Cached Python Can Be Removed
shell: bash
run: |
set -euo pipefail

if [ "${NODE_CACHE_PRE}" = "1" ] && [ ! -d "${TOOLS_DIR}/node" ] && [ ! -d "${TOOLS_DIR}/Node" ]; then
echo 'Node toolcache should have been skipped but is missing'
exit 1
fi

if [ "${PYTHON_CACHE_PRE}" = "1" ] && { [ -d "${TOOLS_DIR}/Python" ] || [ -d "${TOOLS_DIR}/python" ]; }; then
echo 'Python toolcache should have been removed when only cached-node is skipped'
exit 1
fi

max-skip-firefox-precedence:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Capture Pre-Action Browser State
shell: bash
run: |
set -euo pipefail

if command -v firefox >/dev/null 2>&1; then
echo "FIREFOX_PRE=1" >> "$GITHUB_ENV"
else
echo "FIREFOX_PRE=0" >> "$GITHUB_ENV"
fi

if command -v google-chrome >/dev/null 2>&1 || command -v google-chrome-stable >/dev/null 2>&1; then
echo "CHROME_PRE=1" >> "$GITHUB_ENV"
else
echo "CHROME_PRE=0" >> "$GITHUB_ENV"
fi

- name: Max Profile Skip Firefox
uses: ./
with:
cleanup-profile: max
skip-components: " FireFox , LARGE-Packages "

- name: Verify Firefox Is Kept But Chrome Can Be Removed
shell: bash
run: |
set -euo pipefail

if [ "${FIREFOX_PRE}" = "1" ] && ! command -v firefox >/dev/null 2>&1; then
echo 'Firefox should have been skipped but is missing'
exit 1
fi

if [ "${CHROME_PRE}" = "1" ] && { command -v google-chrome >/dev/null 2>&1 || command -v google-chrome-stable >/dev/null 2>&1; }; then
echo 'Chrome should have been removed when only firefox is skipped'
exit 1
fi

custom-grouped-subgroup-precedence:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Capture Pre-Action Browser State
shell: bash
run: |
set -euo pipefail

if command -v firefox >/dev/null 2>&1; then
echo "FIREFOX_PRE=1" >> "$GITHUB_ENV"
else
echo "FIREFOX_PRE=0" >> "$GITHUB_ENV"
fi

if command -v google-chrome >/dev/null 2>&1 || command -v google-chrome-stable >/dev/null 2>&1; then
echo "CHROME_PRE=1" >> "$GITHUB_ENV"
else
echo "CHROME_PRE=0" >> "$GITHUB_ENV"
fi

- name: Custom Profile Grouped + Subgroup Browsers
uses: ./
with:
cleanup-profile: custom
remove-browsers: "true"
remove-firefox: "true"

- name: Verify Grouped Browser Removal Takes Precedence
shell: bash
run: |
set -euo pipefail

if [ "${FIREFOX_PRE}" = "1" ] && command -v firefox >/dev/null 2>&1; then
echo 'Firefox should be removed when grouped browser cleanup is enabled'
exit 1
fi

if [ "${CHROME_PRE}" = "1" ] && { command -v google-chrome >/dev/null 2>&1 || command -v google-chrome-stable >/dev/null 2>&1; }; then
echo 'Chrome should be removed when grouped browser cleanup is enabled'
exit 1
fi

invalid-input-validation:
runs-on: ubuntu-latest
strategy:
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
## Repository Map

- `action.yml`: Action metadata, inputs, and all cleanup logic.
- `.github/workflows/test.yml`: CI matrix tests; each run enables exactly one removal input and verifies expected state.
- `.github/workflows/test.yml`: CI matrix tests plus focused interaction jobs for grouped/subgroup precedence and `skip-components` normalization.
- `README.md`: User-facing usage and caveats.

## Scripts / Execution Surfaces
Expand All @@ -24,7 +24,7 @@
- Environment assumptions: GitHub-hosted Ubuntu runner, `bash`, `sudo`, `apt-get`, `docker` available.
- Operations are destructive (`rm -rf`, package purges, swap resize/removal/recreation when explicitly requested). Keep changes tightly scoped and idempotent.
- The action uses parallel cleanup jobs and temporary progress files in `/tmp` (`/tmp/total_ops`, `/tmp/completed_ops`, `/tmp/component_flags.env`).
- Boolean removal inputs default to `'false'`; CI validates behavior one input at a time via matrix and includes dedicated swapfile resize/remove/oversize-failure coverage plus no-input coverage for leaving swap untouched, and those checks must tolerate runners that start with or without `/mnt/swapfile`.
- Boolean removal inputs default to `'false'`; CI validates behavior one input at a time via matrix, includes dedicated grouped/subgroup precedence and `max` + `skip-components` interaction coverage, and includes swapfile resize/remove/oversize-failure coverage plus no-input coverage for leaving swap untouched. Swap checks must tolerate runners that start with or without `/mnt/swapfile`.
- When changing removal targets or swapfile behavior, update both:
- `action.yml` removal logic
- `.github/workflows/test.yml` verification checks
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ All `remove-*` inputs are optional toggles. In `cleanup-profile: max`, every com
Each row lists the `remove-*` input, its `skip-components` name, and the primary removal targets.
For grouped areas like browsers and toolcache, listing a subcomponent in `skip-components` automatically disables the group removal so only non-skipped subcomponents are removed.

### CI-verified interaction guarantees

The CI workflow includes targeted interaction tests beyond single-input toggles. These lock in:

- `cleanup-profile: max` + `skip-components: cached-node` keeps Node toolcache while still allowing other toolcache families (for example Python) to be removed.
- `cleanup-profile: max` + `skip-components: firefox,large-packages` keeps Firefox while still allowing other browser artifacts (for example Chrome) to be removed.
- `cleanup-profile: custom` + `remove-browsers: "true"` + `remove-firefox: "true"` uses grouped precedence (`remove-browsers`) so subgroup removals are not scheduled separately.
- `skip-components` normalization behavior for whitespace and mixed case values.

**Toolchains and SDKs**

| Input | Component | Removes |
Expand Down
3 changes: 2 additions & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This document is for action maintainers and contributors. If you only need to us
## Repository structure

- `action.yml`: Composite action inputs and cleanup implementation.
- `.github/workflows/test.yml`: Matrix tests for input behavior and max-profile skip behavior.
- `.github/workflows/test.yml`: Matrix tests for input behavior, max-profile skip behavior, and grouped/subgroup precedence interactions.
- `.github/workflows/lint.yml`: Pre-commit checks in CI.
- `.github/workflows/release.yml`: Automated release PR and tagging flow.
- `release-please-config.json`: Release Please configuration.
Expand All @@ -37,6 +37,7 @@ When you change cleanup behavior:

1. Update cleanup logic in `action.yml`.
2. Update or extend verification logic in `.github/workflows/test.yml`.
- Include targeted interaction coverage whenever you change grouped logic (`browsers` vs subcomponents, `cached-tools` vs per-language caches, or `max` + `skip-components` precedence).
3. Update the root `README.md` input docs/examples if behavior changed.
4. Update `docs/MIGRATIONS.md` if the change is breaking or materially alters defaults.

Expand Down
Loading