diff --git a/scripts/run_daily.sh b/scripts/run_daily.sh index a661bbe..17409c3 100755 --- a/scripts/run_daily.sh +++ b/scripts/run_daily.sh @@ -61,7 +61,20 @@ TRACKER_ARGS=() if [[ -n "${STORES:-}" ]]; then TRACKER_ARGS+=(--stores "${STORES}") fi +set +e "$NODE_BIN" bin/tracker.js "${TRACKER_ARGS[@]}" +rc=$? +set -e + +if [[ $rc -eq 3 ]]; then + echo "No meaningful changes; resetting worktree and skipping commit." >&2 + git reset --hard -q + git clean -fdq -- reports data/db viz/data + exit 0 +fi +if [[ $rc -ne 0 ]]; then + exit $rc +fi # Build viz artifacts on the data branch "$NODE_BIN" tools/build_viz_index.js diff --git a/src/main.js b/src/main.js index 02ce290..feb5703 100644 --- a/src/main.js +++ b/src/main.js @@ -156,12 +156,25 @@ async function main() { const report = await runAllStores(storesToRun, { config, logger, http }); + const meaningful = + (report?.totals?.newCount || 0) + + (report?.totals?.updatedCount || 0) + + (report?.totals?.removedCount || 0) + + (report?.totals?.restoredCount || 0) > + 0; + const reportTextColor = renderFinalReport(report, { dbDir: config.dbDir, colorize: logger.colorize, }); process.stdout.write(reportTextColor); + if (!meaningful) { + logger.ok("No meaningful changes; skipping report write."); + process.exitCode = 3; // special "no-op" code + return; + } + const reportTextPlain = renderFinalReport(report, { dbDir: config.dbDir, colorize: false,