2020-12-19 02:09:54 -05:00
|
|
|
name: Miscellaneous checks
|
2020-08-10 06:39:58 -04:00
|
|
|
on: [push, pull_request]
|
|
|
|
|
2021-11-18 08:21:05 -05:00
|
|
|
concurrency:
|
2021-11-21 05:17:27 -05:00
|
|
|
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
|
|
|
|
cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
|
2021-11-18 08:21:05 -05:00
|
|
|
|
2020-08-10 06:39:58 -04:00
|
|
|
jobs:
|
2020-12-19 02:09:54 -05:00
|
|
|
checks:
|
2020-08-10 06:39:58 -04:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-03-24 07:38:59 -04:00
|
|
|
- uses: actions/checkout@v3
|
2020-08-10 06:39:58 -04:00
|
|
|
- name: Check if C-sources are US-ASCII
|
|
|
|
run: |
|
|
|
|
! grep -r -n '[^ -~]' *.[chy] include internal win32/*.[ch]
|
2021-03-03 21:39:45 -05:00
|
|
|
- name: Check for trailing spaces
|
|
|
|
run: |
|
|
|
|
! git grep -n '[ ]$' '*.rb' '*.[chy]'
|
2020-12-19 02:10:57 -05:00
|
|
|
- name: Check for header macros
|
|
|
|
run: |
|
|
|
|
! for header in ruby/*.h; do \
|
|
|
|
git grep -l -F -e $header -e HAVE_`echo $header | tr a-z./ A-Z__` -- . > /dev/null || echo $header
|
|
|
|
done | grep -F .
|
|
|
|
working-directory: include
|
2021-12-16 12:36:09 -05:00
|
|
|
|
2022-03-24 07:32:46 -04:00
|
|
|
- uses: actions/cache@v3
|
2021-12-17 11:27:08 -05:00
|
|
|
with:
|
|
|
|
path: .downloaded-cache
|
2021-12-23 00:49:10 -05:00
|
|
|
key: downloaded-cache-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
downloaded-cache
|
2021-12-17 11:27:08 -05:00
|
|
|
|
|
|
|
- name: Download previous gems list
|
2021-12-15 03:42:48 -05:00
|
|
|
run: |
|
2021-12-23 00:29:56 -05:00
|
|
|
data=default_gems.json
|
2021-12-21 00:26:18 -05:00
|
|
|
mkdir -p .downloaded-cache
|
2021-12-23 00:29:56 -05:00
|
|
|
ln -s .downloaded-cache/$data .
|
|
|
|
curl -O -R -z ./$data https://stdgems.org/$data
|
2021-12-16 12:36:09 -05:00
|
|
|
|
|
|
|
- name: Make default gems list
|
|
|
|
run: |
|
|
|
|
require 'rubygems'
|
2021-12-15 07:41:49 -05:00
|
|
|
$:.unshift "lib"
|
2021-12-16 12:36:09 -05:00
|
|
|
rgver = File.foreach("lib/rubygems.rb") do |line|
|
|
|
|
break $1 if /^\s*VERSION\s*=\s*"([^"]+)"/ =~ line
|
|
|
|
end
|
|
|
|
gems = Dir.glob("{ext,lib}/**/*.gemspec").map do |f|
|
2021-12-15 03:42:48 -05:00
|
|
|
spec = Gem::Specification.load(f)
|
2021-12-16 12:36:09 -05:00
|
|
|
"#{spec.name} #{spec.version}"
|
|
|
|
end.sort
|
2021-12-17 11:27:08 -05:00
|
|
|
File.open("gems/default_gems", "w") do |f|
|
2021-12-16 12:36:09 -05:00
|
|
|
f.puts "RubyGems #{rgver}"
|
|
|
|
f.puts gems
|
|
|
|
end
|
|
|
|
shell: ruby --disable=gems {0}
|
|
|
|
|
2021-12-17 11:27:08 -05:00
|
|
|
- name: Maintain updated gems list in NEWS
|
2021-12-16 12:36:09 -05:00
|
|
|
run: |
|
|
|
|
require 'json'
|
|
|
|
news = File.read("NEWS.md")
|
|
|
|
prev = news[/since the \*+(\d+\.\d+\.\d+)\*+/, 1]
|
|
|
|
prevs = [prev, prev.sub(/\.\d+\z/, '')]
|
2021-12-17 11:27:08 -05:00
|
|
|
%W[default].each do |type|
|
|
|
|
last = JSON.parse(File.read("#{type}_gems.json"))['gems'].filter_map do |g|
|
|
|
|
v = g['versions'].values_at(*prevs).compact.first
|
|
|
|
g = g['gem']
|
|
|
|
g = 'RubyGems' if g == 'rubygems'
|
|
|
|
[g, v] if v
|
|
|
|
end.to_h
|
|
|
|
changed = File.foreach("gems/#{type}_gems").filter_map do |l|
|
|
|
|
next if l.start_with?("#")
|
|
|
|
g, v = l.split(" ", 3)
|
|
|
|
[g, v] unless last[g] == v
|
|
|
|
end
|
2021-12-26 01:35:22 -05:00
|
|
|
news.sub!(/^\*( +)The following #{type} gems? are updated\.\n\K(?: \1\* .*\n)*/) do
|
|
|
|
mark = "#{$1} * "
|
|
|
|
changed.map {|g, v|"#{mark}#{g} #{v}\n"}.join("")
|
|
|
|
end or next
|
2021-12-17 11:27:08 -05:00
|
|
|
File.write("NEWS.md", news)
|
2021-12-16 12:36:09 -05:00
|
|
|
end
|
2021-12-15 03:42:48 -05:00
|
|
|
shell: ruby {0}
|
2021-12-16 12:36:09 -05:00
|
|
|
|
2021-12-15 03:42:48 -05:00
|
|
|
- name: Check diffs
|
|
|
|
id: diff
|
|
|
|
run: |
|
2021-12-17 11:27:08 -05:00
|
|
|
git diff --color --no-ext-diff --ignore-submodules --exit-code NEWS.md
|
2021-12-15 03:42:48 -05:00
|
|
|
continue-on-error: true
|
|
|
|
- name: Commit
|
|
|
|
run: |
|
|
|
|
git pull --ff-only origin ${GITHUB_REF#refs/heads/}
|
2021-12-17 11:27:08 -05:00
|
|
|
git commit --message="Update default gems list at ${GITHUB_SHA:0:30} [ci skip]" NEWS.md
|
2021-12-15 03:42:48 -05:00
|
|
|
git push origin ${GITHUB_REF#refs/heads/}
|
|
|
|
env:
|
|
|
|
EMAIL: svn-admin@ruby-lang.org
|
|
|
|
GIT_AUTHOR_NAME: git
|
|
|
|
GIT_COMMITTER_NAME: git
|
2021-12-23 04:31:17 -05:00
|
|
|
if: ${{ github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull') && steps.diff.outcome == 'failure' }}
|