[前][次][番号順一覧][スレッド一覧]

ruby-changes:67069

From: Nobuyoshi <ko1@a...>
Date: Sat, 7 Aug 2021 19:23:23 +0900 (JST)
Subject: [ruby-changes:67069] 6e60fc2945 (master): Group commands on GitHub Actions

https://git.ruby-lang.org/ruby.git/commit/?id=6e60fc2945

From 6e60fc29453603270ebdf79f4b37ec6544a602cc Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sat, 7 Aug 2021 18:32:24 +0900
Subject: Group commands on GitHub Actions

---
 common.mk                 | 22 ++++++++++++++++++++++
 defs/gmake.mk             |  5 +++++
 template/Makefile.in      |  3 +++
 tool/test-bundled-gems.rb |  6 +++++-
 win32/Makefile.sub        |  8 ++++++++
 5 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/common.mk b/common.mk
index 2f1a47c..28ffb98 100644
--- a/common.mk
+++ b/common.mk
@@ -760,35 +760,49 @@ $(arch)-fake.rb: $(srcdir)/template/fake.rb.in $(tooldir)/generic_erb.rb version https://github.com/ruby/ruby/blob/trunk/common.mk#L760
 btest: $(TEST_RUNNABLE)-btest
 no-btest: PHONY
 yes-btest: fake miniruby$(EXEEXT) PHONY
+	$(ACTIONS_GROUP)
 	$(Q)$(exec) $(BOOTSTRAPRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(BTESTRUBY) $(RUN_OPTS)" $(OPTS) $(TESTOPTS) $(BTESTS)
+	$(ACTIONS_ENDGROUP)
 
 btest-ruby: $(TEST_RUNNABLE)-btest-ruby
 no-btest-ruby: PHONY
 yes-btest-ruby: prog PHONY
+	$(ACTIONS_GROUP)
 	$(Q)$(exec) $(RUNRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(PROGRAM) -I$(srcdir)/lib $(RUN_OPTS)" -q $(OPTS) $(TESTOPTS) $(BTESTS)
+	$(ACTIONS_ENDGROUP)
 
 rtest: fake miniruby$(EXEEXT) PHONY
+	$(ACTIONS_GROUP)
 	$(Q)$(exec) $(BOOTSTRAPRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(BTESTRUBY) $(RUN_OPTS)" --sets=ractor -v
+	$(ACTIONS_ENDGROUP)
 
 test-basic: $(TEST_RUNNABLE)-test-basic
 no-test-basic: PHONY
 yes-test-basic: prog PHONY
+	$(ACTIONS_GROUP)
 	$(Q)$(exec) $(RUNRUBY) "$(srcdir)/basictest/runner.rb" --run-opt=$(RUN_OPTS) $(OPTS) $(TESTOPTS)
+	$(ACTIONS_ENDGROUP)
 
 test-knownbugs: test-knownbug
 test-knownbug: $(TEST_RUNNABLE)-test-knownbug
 no-test-knownbug: PHONY
 yes-test-knownbug: prog PHONY
+	$(ACTIONS_GROUP)
 	-$(exec) $(RUNRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(PROGRAM) $(RUN_OPTS)" $(OPTS) $(TESTOPTS) $(srcdir)/KNOWNBUGS.rb
+	$(ACTIONS_ENDGROUP)
 
 test-testframework: $(TEST_RUNNABLE)-test-testframework
 yes-test-testframework: prog PHONY
+	$(ACTIONS_GROUP)
 	$(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TESTOPTS) testunit minitest
+	$(ACTIONS_ENDGROUP)
 no-test-testframework: PHONY
 
 test-tool: $(TEST_RUNNABLE)-test-tool
 yes-test-tool: prog PHONY
+	$(ACTIONS_GROUP)
 	$(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TESTOPTS)
+	$(ACTIONS_ENDGROUP)
 no-test-tool: PHONY
 
 test-sample: test-basic # backward compatibility for mswin-build
@@ -799,7 +813,9 @@ test: test-short https://github.com/ruby/ruby/blob/trunk/common.mk#L813
 # for example, make test-all TESTOPTS="-j2 -v -n test-name -- test-file-name"
 test-all: $(TEST_RUNNABLE)-test-all
 yes-test-all: programs PHONY
+	$(ACTIONS_GROUP)
 	$(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS)
+	$(ACTIONS_ENDGROUP)
 TESTS_BUILD = mkmf
 no-test-all: PHONY
 	$(gnumake_recursive)$(MINIRUBY) -I"$(srcdir)/lib" "$(TESTSDIR)/runner.rb" $(TESTOPTS) $(TESTS_BUILD)
@@ -839,8 +855,10 @@ test-spec-precheck: programs https://github.com/ruby/ruby/blob/trunk/common.mk#L855
 
 test-spec: $(TEST_RUNNABLE)-test-spec
 yes-test-spec: test-spec-precheck
+	$(ACTIONS_GROUP)
 	$(gnumake_recursive)$(Q) \
 	$(RUNRUBY) -r./$(arch)-fake $(srcdir)/spec/mspec/bin/mspec run -B $(srcdir)/spec/default.mspec -I$(srcdir)/tool/lib $(MSPECOPT) $(SPECOPTS)
+	$(ACTIONS_ENDGROUP)
 no-test-spec:
 
 RUNNABLE = $(LIBRUBY_RELATIVE:no=un)-runnable
@@ -1352,8 +1370,10 @@ test-bundled-gems-prepare: test-bundled-gems-precheck test-bundled-gems-fetch https://github.com/ruby/ruby/blob/trunk/common.mk#L1370
 test-bundled-gems-prepare: $(TEST_RUNNABLE)-test-bundled-gems-prepare
 no-test-bundled-gems-prepare: no-test-bundled-gems-precheck
 yes-test-bundled-gems-prepare: yes-test-bundled-gems-precheck
+	$(ACTIONS_GROUP)
 	$(XRUBY) -C "$(srcdir)" bin/gem install --no-document \
 		--install-dir .bundle --conservative "bundler" "minitest:~> 5" "test-unit" "rake" "hoe" "yard" "pry" "packnga" "rexml" "json-schema" "rbs"
+	$(ACTIONS_ENDGROUP)
 
 PREPARE_BUNDLED_GEMS = test-bundled-gems-prepare
 test-bundled-gems: $(TEST_RUNNABLE)-test-bundled-gems
@@ -1373,8 +1393,10 @@ yes-test-bundler-precheck: main https://github.com/ruby/ruby/blob/trunk/common.mk#L1393
 
 no-test-bundler-prepare: no-test-bundler-precheck
 yes-test-bundler-prepare: yes-test-bundler-precheck
+	$(ACTIONS_GROUP)
 	$(XRUBY) -C "$(srcdir)" bin/gem install --no-document \
 		--install-dir .bundle --conservative "rspec:~> 3.8" "rake:~> 13.0" "parallel_tests:~> 2.29"
+	$(ACTIONS_ENDGROUP)
 
 RSPECOPTS =
 BUNDLER_SPECS =
diff --git a/defs/gmake.mk b/defs/gmake.mk
index 8e90ee8..37924b3 100644
--- a/defs/gmake.mk
+++ b/defs/gmake.mk
@@ -6,6 +6,11 @@ override mflags := $(filter-out -j%,$(MFLAGS)) https://github.com/ruby/ruby/blob/trunk/defs/gmake.mk#L6
 MSPECOPT += $(if $(filter -j%,$(MFLAGS)),-j)
 nproc = $(subst -j,,$(filter -j%,$(MFLAGS)))
 
+ifeq ($(GITHUB_ACTIONS),true)
+override ACTIONS_GROUP = @echo "\#\#[group]$(@:yes-=)"
+override ACTIONS_ENDGROUP = @echo "\#\#[endgroup]"
+endif
+
 ifneq ($(filter %darwin%,$(arch)),)
 INSTRUBY_ENV += SDKROOT=/
 endif
diff --git a/template/Makefile.in b/template/Makefile.in
index 60a068d..866fff1 100644
--- a/template/Makefile.in
+++ b/template/Makefile.in
@@ -256,6 +256,9 @@ MESSAGE_END = ; do echo "$$line"; done https://github.com/ruby/ruby/blob/trunk/template/Makefile.in#L256
 ECHO_BEGIN = @sep=''; for word in
 ECHO_END = ; do echo @ECHO_N@ "$$sep'$$word'@ECHO_C@"; sep=' '; done; echo
 
+ACTIONS_GROUP = @$(NULLCMD) $(empty)
+ACTIONS_ENDGROUP = @$(NULLCMD)
+
 DESTDIR       = @DESTDIR@
 
 configure_args = @configure_args@
diff --git a/tool/test-bundled-gems.rb b/tool/test-bundled-gems.rb
index 53c88c1..d4c4533 100644
--- a/tool/test-bundled-gems.rb
+++ b/tool/test-bundled-gems.rb
@@ -1,6 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/tool/test-bundled-gems.rb#L1
 require 'rbconfig'
 require 'timeout'
 
+github_actions = ENV["GITHUB_ACTIONS"] == "true"
+
 allowed_failures = ENV['TEST_BUNDLED_GEMS_ALLOW_FAILURES'] || ''
 allowed_failures = allowed_failures.split(',').reject(&:empty?)
 
@@ -13,7 +15,7 @@ File.foreach("#{gem_dir}/bundled_gems") do |line| https://github.com/ruby/ruby/blob/trunk/tool/test-bundled-gems.rb#L15
   next if /^\s*(?:#|$)/ =~ line
   gem = line.split.first
   next if ARGV.any? {|pat| !File.fnmatch?(pat, gem)}
-  puts "\nTesting the #{gem} gem"
+  puts "#{github_actions ? "##[group]" : "\n"}Testing the #{gem} gem"
 
   test_command = "#{ruby} -C #{gem_dir}/src/#{gem} -Ilib #{rake} test"
   first_timeout = 600 # 10min
@@ -33,6 +35,7 @@ File.foreach("#{gem_dir}/bundled_gems") do |line| https://github.com/ruby/ruby/blob/trunk/tool/test-bundled-gems.rb#L35
     test_command << " 'TESTOPTS=-e /test_stub_value_block_args_5__break_if_not_passed|test_no_method_error_on_unexpected_methods/'"
   end
 
+  print "[command]" if github_actions
   puts test_command
   pid = Process.spawn(test_command, "#{/mingw|mswin/ =~ RUBY_PLATFORM ? 'new_' : ''}pgroup": true)
   {nil => first_timeout, INT: 30, TERM: 10, KILL: nil}.each do |sig, sec|
@@ -55,6 +58,7 @@ File.foreach("#{gem_dir}/bundled_gems") do |line| https://github.com/ruby/ruby/blob/trunk/tool/test-bundled-gems.rb#L58
       exit_code = $?.exitstatus
     end
   end
+  print "##[endgroup]\n" if github_actions
 end
 
 puts "Failed gems: #{failed.join(', ')}" unless failed.empty?
diff --git a/win32/Makefile.sub b/win32/Makefile.sub
index a124236..6234bfb 100644
--- a/win32/Makefile.sub
+++ b/win32/Makefile.sub
@@ -526,6 +526,14 @@ GOLF_PRELUDE_C = golf_prelude.c https://github.com/ruby/ruby/blob/trunk/win32/Makefile.sub#L526
 !endif
 RBCONFIG      = ./.rbconfig.time
 
+!if "$(GITHUB_ACTIONS)" == "true"
+ACTIONS_GROUP = @echo ^#^#[group]$(@:yes-=)
+ACTIONS_ENDGROUP = @echo ^#^#[endgroup]
+!else
+ACTIONS_GROUP = @:: $(empty)
+ACTIONS_ENDGROUP = @::
+!endif
+
 !include $(srcdir)/common.mk
 
 !ifdef SCRIPTPROGRAMS
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]