fix: Extract memory_guard() to lib/env.sh to deduplicate poll scripts
The memory guard block in action-poll.sh and dev-poll.sh became identical after removing matrix_send calls, triggering the duplicate-detection CI check. Extract to a shared function in lib/env.sh (already sourced by both scripts). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
472d70e4bb
commit
d8dab4a18a
3 changed files with 14 additions and 10 deletions
|
|
@ -25,11 +25,7 @@ log() {
|
|||
}
|
||||
|
||||
# --- Memory guard ---
|
||||
AVAIL_MB=$(awk '/MemAvailable/{printf "%d", $2/1024}' /proc/meminfo)
|
||||
if [ "$AVAIL_MB" -lt 2000 ]; then
|
||||
log "SKIP: only ${AVAIL_MB}MB available (need 2000MB)"
|
||||
exit 0
|
||||
fi
|
||||
memory_guard 2000
|
||||
|
||||
# --- Find open 'action' issues ---
|
||||
log "scanning for open action issues"
|
||||
|
|
|
|||
|
|
@ -309,11 +309,7 @@ if [ -f "$LOCKFILE" ]; then
|
|||
fi
|
||||
|
||||
# --- Memory guard ---
|
||||
AVAIL_MB=$(awk '/MemAvailable/{printf "%d", $2/1024}' /proc/meminfo)
|
||||
if [ "$AVAIL_MB" -lt 2000 ]; then
|
||||
log "SKIP: only ${AVAIL_MB}MB available (need 2000MB)"
|
||||
exit 0
|
||||
fi
|
||||
memory_guard 2000
|
||||
|
||||
# =============================================================================
|
||||
# HELPER: check if a dependency issue is fully resolved (closed + PR merged)
|
||||
|
|
|
|||
12
lib/env.sh
12
lib/env.sh
|
|
@ -146,6 +146,18 @@ wpdb() {
|
|||
-t "$@" 2>/dev/null
|
||||
}
|
||||
|
||||
# Memory guard — exit 0 (skip) if available RAM is below MIN_MB.
|
||||
# Usage: memory_guard [MIN_MB] (default 2000)
|
||||
memory_guard() {
|
||||
local min_mb="${1:-2000}"
|
||||
local avail_mb
|
||||
avail_mb=$(awk '/MemAvailable/{printf "%d", $2/1024}' /proc/meminfo)
|
||||
if [ "${avail_mb:-0}" -lt "$min_mb" ]; then
|
||||
log "SKIP: only ${avail_mb}MB available (need ${min_mb}MB)"
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
# Source tea helpers (available when tea binary is installed)
|
||||
if command -v tea &>/dev/null; then
|
||||
# shellcheck source=tea-helpers.sh
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue