Skip to content

Extract repeated directory-check assertions into check-dir.sh helper - #1127

Merged
brunoborges merged 2 commits into
mainfrom
brunoborges-extract-check-dir-helper
Jul 15, 2026
Merged

Extract repeated directory-check assertions into check-dir.sh helper#1127
brunoborges merged 2 commits into
mainfrom
brunoborges-extract-check-dir-helper

Conversation

@brunoborges

@brunoborges brunoborges commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

What

e2e-cache.yml repeated the same inline shell block many times to assert that a cache directory exists (and then ls it), plus several inverse checks (the gradle2/maven2/sbt2 cache-miss jobs) asserting a directory does not exist.

This PR deduplicates that logic into a single helper script.

Rebased onto main after #1124 merged, which consolidated e2e-cache-dependency-path.yml into e2e-cache.yml and added maven/sbt cache-dependency-path coverage. The extraction is now applied across all 25 checks in the consolidated workflow; the standalone dependency-path file no longer exists.

Changes

  • New __tests__/check-dir.sh (POSIX sh, marked executable):
    • check-dir.sh <dir> [present|absent], default mode present.
    • present: fail with ::error::The <dir> directory does not exist unexpectedly + exit 1 when the directory is missing; otherwise ls it.
    • absent: fail with ::error::The <dir> directory exists unexpectedly + exit 1 when the directory exists.
  • e2e-cache.yml now calls the helper instead of inline if [ ! -d ... ] blocks, keeping the exact same directories and present/absent semantics. Steps that only did check-and-ls collapse to a single line.
  • Paths are passed already-expanded via $HOME (e.g. bash __tests__/check-dir.sh "$HOME/.gradle/caches") to avoid tilde-expansion pitfalls. The sbt jobs use a