1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/.github/workflows/bundled_gems.yml

140 lines
4.5 KiB
YAML
Raw Normal View History

2021-09-05 00:10:04 -04:00
name: bundled_gems
on:
2021-12-17 11:04:17 -05:00
push:
paths:
- '.github/workflows/bundled_gems.yml'
- 'gems/bundled_gems'
pull_request:
2021-12-17 23:05:48 -05:00
paths:
2021-12-17 11:04:17 -05:00
- '.github/workflows/bundled_gems.yml'
- 'gems/bundled_gems'
2021-09-05 00:10:04 -04:00
schedule:
- cron: '45 6 * * *'
jobs:
update:
2021-12-17 11:04:17 -05:00
if: ${{ github.event_name != 'schedule' || github.repository == 'ruby/ruby' }}
2021-09-05 00:10:04 -04:00
name: update ${{ github.workflow }}
runs-on: ubuntu-latest
steps:
- name: git config
run: |
git config --global advice.detachedHead 0
git config --global init.defaultBranch garbage
- name: Set ENV
run: |
echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
2021-12-17 11:04:17 -05:00
echo "TODAY=$(date +%F)" >> $GITHUB_ENV
2021-09-05 00:10:04 -04:00
- uses: actions/checkout@v3
2021-09-05 00:10:04 -04:00
- uses: actions/cache@v3
2021-12-17 11:04:17 -05:00
with:
path: .downloaded-cache
key: downloaded-cache-${{ github.sha }}
restore-keys: |
downloaded-cache
2021-12-17 11:04:17 -05:00
- name: Download previous gems list
run: |
data=bundled_gems.json
mkdir -p .downloaded-cache
ln -s .downloaded-cache/$data .
curl -O -R -z ./$data https://stdgems.org/$data
2021-12-17 11:04:17 -05:00
- name: Update bundled gems list
run: |
ruby -i~ tool/update-bundled_gems.rb gems/bundled_gems
- name: Maintain updated gems list in NEWS
2021-09-05 00:10:04 -04:00
run: |
#!ruby
2021-12-17 11:04:17 -05:00
require 'json'
news = File.read("NEWS.md")
prev = news[/since the \*+(\d+\.\d+\.\d+)\*+/, 1]
prevs = [prev, prev.sub(/\.\d+\z/, '')]
%W[bundled].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
changed, added = changed.partition {|g, _| last[g]}
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
news.sub!(/^\*( +)The following default gems are now bundled gems\.\n\K(?: \1\* .*\n)*/) do
mark = "#{$1} * "
added.map {|g, v|"#{mark}#{g} #{v}\n"}.join("")
end or next if added
2021-12-17 11:04:17 -05:00
File.write("NEWS.md", news)
end
shell: ruby {0}
2021-09-05 00:10:04 -04:00
- name: Check diffs
id: diff
run: |
2021-12-17 11:04:17 -05:00
git add -- NEWS.md
git diff --no-ext-diff --ignore-submodules --quiet -- gems/bundled_gems
2021-09-05 00:10:04 -04:00
continue-on-error: true
- name: Install libraries
run: |
set -x
sudo apt-get update -q || :
sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev bison autoconf ruby
if: ${{ steps.diff.outcome == 'failure' }}
- name: Build
run: |
./autogen.sh
./configure -C --disable-install-doc
make
2021-09-05 00:10:04 -04:00
if: ${{ steps.diff.outcome == 'failure' }}
- name: Prepare bundled gems
run: |
make -s prepare-gems
if: ${{ steps.diff.outcome == 'failure' }}
2021-09-05 00:10:04 -04:00
- name: Test bundled gems
run: |
make -s test-bundled-gems
2021-12-17 11:04:17 -05:00
git add -- gems/bundled_gems
2021-09-05 00:10:04 -04:00
timeout-minutes: 30
env:
RUBY_TESTOPTS: "-q --tty=no"
TEST_BUNDLED_GEMS_ALLOW_FAILURES: ""
if: ${{ steps.diff.outcome == 'failure' }}
2021-12-17 11:04:17 -05:00
- name: Show diffs
id: show
run: |
git diff --cached --color --no-ext-diff --ignore-submodules --exit-code --
continue-on-error: true
2021-09-05 00:10:04 -04:00
- name: Commit
run: |
git pull --ff-only origin ${GITHUB_REF#refs/heads/}
message="Update bundled gems list at "
if [ ${{ steps.diff.outcome }} = success ]; then
git commit --message="${message}${GITHUB_SHA:0:30} [ci skip]"
else
git commit --message="${message}${TODAY}"
fi
2021-09-05 00:10:04 -04:00
git push origin ${GITHUB_REF#refs/heads/}
env:
EMAIL: svn-admin@ruby-lang.org
GIT_AUTHOR_NAME: git
GIT_COMMITTER_NAME: git
if: ${{ github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull') && steps.show.outcome == 'failure' }}