Address review: argc guard in check-dir.sh, fix sbt ubuntu matrix conditionals

- check-dir.sh: with set -u, invoking without a <dir> argument failed with an
  opaque "parameter not set" error. Add an explicit argc check that prints a
  usage message and exits 2 (distinct from the assertion failure code 1).
- e2e-cache.yml: the sbt-save and sbt-restore jobs run on an ubuntu-22.04
  matrix entry, but their coursier-cache steps were guarded by
  'if: matrix.os == "ubuntu-latest"', so those checks never executed on
  Ubuntu. Align the conditionals with the matrix (ubuntu-22.04), matching the
  newer sbt1/sbt2 jobs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Bruno Borges 2026-07-15 10:59:21 -04:00
parent 0040423ea0
commit 85f658438e
2 changed files with 7 additions and 2 deletions

View File

@ -144,7 +144,7 @@ jobs:
if: matrix.os == 'windows-latest' if: matrix.os == 'windows-latest'
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache" run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache"
- name: Check files to cache on ubuntu-latest - name: Check files to cache on ubuntu-latest
if: matrix.os == 'ubuntu-latest' if: matrix.os == 'ubuntu-22.04'
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier" run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
sbt-restore: sbt-restore:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
@ -177,7 +177,7 @@ jobs:
if: matrix.os == 'windows-latest' if: matrix.os == 'windows-latest'
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache" run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache"
- name: Confirm that ~/.cache/coursier directory has been made - name: Confirm that ~/.cache/coursier directory has been made
if: matrix.os == 'ubuntu-latest' if: matrix.os == 'ubuntu-22.04'
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier" run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
gradle1-save: gradle1-save:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}

View File

@ -10,6 +10,11 @@
# tilde-expansion pitfalls. # tilde-expansion pitfalls.
set -eu set -eu
if [ "$#" -lt 1 ]; then
echo "Usage: check-dir.sh <dir> [present|absent]" >&2
exit 2
fi
dir=$1 dir=$1
mode=${2:-present} mode=${2:-present}