diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 63f6c2e..5c63702 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -48,9 +48,12 @@ jobs: brewfile-check: name: Brewfile name validation - runs-on: macos-latest + # Only resolves names, so Linux Homebrew (preinstalled, not on PATH) is enough + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Put Homebrew on PATH + run: echo "/home/linuxbrew/.linuxbrew/bin" >> "$GITHUB_PATH" - name: Tap all taps referenced in Brewfile run: | { @@ -60,20 +63,29 @@ jobs: sed -n 's/^brew "\([^/"]*\/[^/"]*\)\/[^"]*".*/\1/p' Brewfile sed -n 's/^cask "\([^/"]*\/[^/"]*\)\/[^"]*".*/\1/p' Brewfile } | sort -u > /tmp/taps.txt + brew --version + # Homebrew refuses to load formulae and casks from untrusted + # third-party taps, so trust each tap after adding it. while read -r t; do - brew tap "$t" || echo "::error::tap \"$t\" failed to add" + if brew tap "$t"; then + brew trust --tap "$t" || echo "::error::tap \"$t\" could not be trusted" + else + echo "::error::tap \"$t\" failed to add" + fi done < /tmp/taps.txt - name: Verify every brew/cask entry resolves to a real formula/cask run: | # Short-name lookup can miss formulas from a tap added moments ago # (name-resolution cache isn't warm yet), so fall back to checking - # every tapped repo explicitly by fully-qualified name. + # every tapped repo explicitly by fully-qualified name. On failure, + # print brew's error for the name as written. resolves() { - local kind=$1 name=$2 - brew info "--$kind" "$name" >/dev/null 2>&1 && return 0 + local kind=$1 name=$2 err t + err=$(brew info "--$kind" "$name" 2>&1 >/dev/null) && return 0 while read -r t; do brew info "--$kind" "$t/$name" >/dev/null 2>&1 && return 0 done < /tmp/taps.txt + printf ' %s\n' "${err//$'\n'/$'\n' }" return 1 } fail=0