Skip to content

Commit

Permalink
Pretty-simple "find dependency updates" helper
Browse files Browse the repository at this point in the history
While building github.com/cadence-workflow/cadence-go-client/pull/1060, I realized I kinda missed the out-of-date warnings.
So here's something kinda similar.

It may be worth adding e.g. a "nothing > 100 days" check to `make lint` and/or CI?
Otherwise I tend to see dependencies go un-upgraded for huge lengths of time.
  • Loading branch information
Groxx authored Feb 19, 2021
1 parent 8aba053 commit 5dbeced
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,37 @@ start-mysql: bins
start-postgres: bins
./cadence-server --zone postgres start

# broken up into multiple += so I can interleave comments.
# this all becomes a single line of output.
# you must not use single-quotes within the string in this var.
JQ_DEPS_AGE = jq '
# only deal with things with updates
JQ_DEPS_AGE += select(.Update)
# allow additional filtering, e.g. DEPS_FILTER='$(JQ_DEPS_ONLY_DIRECT)'
JQ_DEPS_AGE += $(DEPS_FILTER)
# add "days between current version and latest version"
JQ_DEPS_AGE += | . + {Age:(((.Update.Time | fromdate) - (.Time | fromdate))/60/60/24 | floor)}
# add "days between latest version and now"
JQ_DEPS_AGE += | . + {Available:((now - (.Update.Time | fromdate))/60/60/24 | floor)}
# 123 days: library old_version -> new_version
JQ_DEPS_AGE += | ([.Age, .Available] | max | tostring) + " days: " + .Path + " \t" + .Version + " -> " + .Update.Version
JQ_DEPS_AGE += '
# remove surrounding quotes from output
JQ_DEPS_AGE += --raw-output

# exclude `"Indirect": true` dependencies. direct ones have no "Indirect" key at all.
JQ_DEPS_ONLY_DIRECT = | select(has("Indirect") | not)

deps: ## Check for dependency updates, for things that are directly imported
@# filter things that do not contain 'indirect:true'
@make --no-print-directory DEPS_FILTER='$(JQ_DEPS_ONLY_DIRECT)' deps-all

deps-all: ## Check for all dependency updates
@# list all updates, compute seconds -> days between current version and latest version dates, format for display and sort
go list -u -m -json all \
| $(JQ_DEPS_AGE) \
| sort -n

help:
@# print help first, so it's visible
@printf "\033[36m%-20s\033[0m %s\n" 'help' 'Prints a help message showing any specially-commented targets'
Expand Down

0 comments on commit 5dbeced

Please sign in to comment.