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 ---
|
# --- Memory guard ---
|
||||||
AVAIL_MB=$(awk '/MemAvailable/{printf "%d", $2/1024}' /proc/meminfo)
|
memory_guard 2000
|
||||||
if [ "$AVAIL_MB" -lt 2000 ]; then
|
|
||||||
log "SKIP: only ${AVAIL_MB}MB available (need 2000MB)"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# --- Find open 'action' issues ---
|
# --- Find open 'action' issues ---
|
||||||
log "scanning for open action issues"
|
log "scanning for open action issues"
|
||||||
|
|
|
||||||
|
|
@ -309,11 +309,7 @@ if [ -f "$LOCKFILE" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- Memory guard ---
|
# --- Memory guard ---
|
||||||
AVAIL_MB=$(awk '/MemAvailable/{printf "%d", $2/1024}' /proc/meminfo)
|
memory_guard 2000
|
||||||
if [ "$AVAIL_MB" -lt 2000 ]; then
|
|
||||||
log "SKIP: only ${AVAIL_MB}MB available (need 2000MB)"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# HELPER: check if a dependency issue is fully resolved (closed + PR merged)
|
# 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
|
-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)
|
# Source tea helpers (available when tea binary is installed)
|
||||||
if command -v tea &>/dev/null; then
|
if command -v tea &>/dev/null; then
|
||||||
# shellcheck source=tea-helpers.sh
|
# shellcheck source=tea-helpers.sh
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue