CI: Warn longstanding development revision of bundled gems

This commit is contained in:
Nobuyoshi Nakada committed 2025-08-30 10:45:42 +09:00
1 parent d94e0a7bca
commit 01a57bd6cd
1 file changed
+42
+42
View File
@@ -100,6 +100,48 @@ jobs:
gems: ${{ steps.diff.outputs.gems }}
if: ${{ steps.diff.outputs.update }}
- name: Fetch more logs
id: logs
run: |
file=gems/bundled_gems days=30
{ echo days=$days; echo file=$file; } >> $GITHUB_OUTPUT
since=$(date --date=-$[days * 2 + 10]day +'%F')
set -x
git sparse-checkout set --no-cone /$file
git fetch --shallow-since="$since" --no-tags origin ${GITHUB_REF}
- name: Development revision of bundled gems
run: |
#!ruby
file = ENV["file"]
days = ENV["days"].to_i
today = Time.new("#{ENV['TODAY']}T00:00:00Z").to_i
limit = today - days * 86400
ok = true
IO.popen(%W"git blame --line-porcelain -- #{file}") do |blame|
while head = blame.gets("\n\t") and s = blame.gets
next unless (gem = s.split(/\s+|#.*/)).size > 3
time = head[/^committer-time \K\d+/].to_i
next if (d = limit - time) <= 0
d /= 86400
line = head[/\A\h+ \d+ \K\d+/].to_i
level = if d < days; 'warning'; else ok = false; 'error'; end
d += days
puts "::#{level} file=#{file},line=#{line},title=Older than #{d} days::#{gem[0]} #{gem[3]}"
end
end
# exit ok
shell: ruby {0}
env:
file: ${{ steps.logs.outputs.file }}
days: ${{ steps.logs.outputs.days }}
- name: Restore sparse checkout
run: |
git sparse-checkout disable
if: always()
- name: Install libraries
uses: ./.github/actions/setup/ubuntu
if: ${{ steps.diff.outputs.gems }}