Repository navigation
Soften yay go-mod caches and warn on AUR update failure #13474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AnPod
wants to merge
3
commits into
omacom:quattro
Choose a base branch
from
AnPod:fix/aur-gomod-cache-warning
base: quattro
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
| source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" | ||
|
|
||
| test_tmp=$(mktemp -d) | ||
| trap 'chmod -R u+w "$test_tmp" 2>/dev/null || true; rm -rf "$test_tmp"' EXIT | ||
| mkdir -p "$test_tmp/bin" "$test_tmp/home" | ||
| export FAKE_CALLS="$test_tmp/calls" FAKE_NOTIFICATIONS="$test_tmp/notifications" | ||
| for layout in hyprmoncfg/src/go-mod standard/src/pkg/mod nested/src/gopath/pkg/mod; do | ||
| mkdir -p "$test_tmp/cache/yay/$layout/module" | ||
| touch "$test_tmp/cache/yay/$layout/module/LICENSE" | ||
| chmod -R a-w "$test_tmp/cache/yay/$layout" | ||
| done | ||
| cat >"$test_tmp/bin/pacman" <<'SH' | ||
| #!/bin/bash | ||
| [[ $1 == "-Qem" ]] || exit 90 | ||
| exit "${TEST_NO_AUR:-0}" | ||
| SH | ||
| cat >"$test_tmp/bin/omarchy-pkg-aur-accessible" <<'SH' | ||
| #!/bin/bash | ||
| exit "${TEST_AUR_UNAVAILABLE:-0}" | ||
| SH | ||
| cat >"$test_tmp/bin/yay" <<'SH' | ||
| #!/bin/bash | ||
| printf '%s\n%s\n' "$GOFLAGS" "$*" >>"$FAKE_CALLS" | ||
| exit "${TEST_YAY_STATUS:-1}" | ||
| SH | ||
| cat >"$test_tmp/bin/omarchy-notification-send" <<'SH' | ||
| #!/bin/bash | ||
| printf '%s\n' "$*" >>"$FAKE_NOTIFICATIONS" | ||
| exit "${TEST_NOTIFICATION_STATUS:-0}" | ||
| SH | ||
| chmod +x "$test_tmp/bin/"* | ||
| run() { | ||
| : >"$FAKE_CALLS" | ||
| : >"$FAKE_NOTIFICATIONS" | ||
| HOME="$test_tmp/home" XDG_CACHE_HOME="$test_tmp/cache" PATH="$test_tmp/bin:$PATH" OMARCHY_PATH="$ROOT" \ | ||
| bash "$ROOT/bin/omarchy-update-aur-pkgs" >"$test_tmp/out" 2>"$test_tmp/err" | ||
| } | ||
| GOFLAGS='-trimpath -tags=custom' run || fail "failed AUR build stays nonfatal" | ||
| [[ $(head -1 "$FAKE_CALLS") == '-trimpath -tags=custom -modcacherw' ]] || fail "yay receives existing Go flags plus writable-cache flag" | ||
| for layout in hyprmoncfg/src/go-mod standard/src/pkg/mod nested/src/gopath/pkg/mod; do | ||
| for path in "$test_tmp/cache/yay/$layout" "$test_tmp/cache/yay/$layout/module/LICENSE"; do | ||
| mode=$(stat -c %a "$path") | ||
| (( (8#$mode & 0200) != 0 )) || fail "Go cache remains read-only: $layout" | ||
| done | ||
| done | ||
| pass "all supported Go cache layouts become writable and GOFLAGS are preserved" | ||
| grep -q 'AUR package update failed' "$test_tmp/err" || fail "AUR failure prints a terminal warning" | ||
| grep -q 'AUR update needs attention' "$FAKE_NOTIFICATIONS" || fail "AUR failure sends a desktop notification" | ||
| pass "failed AUR update remains visible without aborting" | ||
| TEST_NOTIFICATION_STATUS=1 run || fail "notification failure must not abort the update" | ||
| pass "failed desktop notification leaves the terminal warning and remains nonfatal" | ||
| GOFLAGS='' TEST_YAY_STATUS=0 run || fail "successful AUR update succeeds" | ||
| [[ $(head -1 "$FAKE_CALLS") == '-modcacherw' && ! -s $FAKE_NOTIFICATIONS && ! -s $test_tmp/err ]] || fail "successful update adds flag without warning" | ||
| pass "successful AUR update emits no failure notification" | ||
| TEST_NO_AUR=1 run | ||
| [[ ! -s $FAKE_CALLS && ! -s $FAKE_NOTIFICATIONS ]] || fail "no foreign packages skips yay" | ||
| TEST_AUR_UNAVAILABLE=1 run | ||
| [[ ! -s $FAKE_CALLS && ! -s $FAKE_NOTIFICATIONS ]] || fail "unavailable AUR skips yay" | ||
| pass "missing packages and unavailable AUR do not report a build failure" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fake
yaynever checks whether the caches are writable when it starts. The permission checks run afterward, so this test would still pass if cleanup moved afteryay, even though the next rebuild would fail. Check the cache permissions inside the fakeyaybefore it returns.