From a615ad06068d355ce9b2c341106183cc8e9307fc Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 14 Oct 2026 09:01:23 +0900 Subject: [PATCH 1/3] Remove rubyci-screenshot It has not succeeded once in the last year, and the rubyzip 3.4.0 bump left no Ruby that can run it, because rubyzip now requires Ruby 3.0 while selenium-webdriver 3.142.6 does not work on Ruby 3. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/rubyci-screenshot.yml | 35 ----------- .gitignore | 2 - Gemfile | 3 - Gemfile.lock | 17 ------ rubyci-screenshot.rb | 79 ------------------------- 5 files changed, 136 deletions(-) delete mode 100644 .github/workflows/rubyci-screenshot.yml delete mode 100644 .gitignore delete mode 100644 Gemfile delete mode 100644 Gemfile.lock delete mode 100644 rubyci-screenshot.rb diff --git a/.github/workflows/rubyci-screenshot.yml b/.github/workflows/rubyci-screenshot.yml deleted file mode 100644 index 3c59b0482..000000000 --- a/.github/workflows/rubyci-screenshot.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: rubyci-screenshot - -on: - push: - branches: - - master - schedule: - - cron: '30 14 * * *' # Daily at 14:30 UTC - - -jobs: - latest: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - uses: ruby/setup-ruby@e81a8fa391b11a595c1b7ed84177cc0fe02faf83 # v1.328.0 - with: - ruby-version: 2.7 - - - name: Setup the environment - run: | - sudo snap install chromium - bundle install - - - name: Run the script - run: bundle exec ruby rubyci-screenshot.rb - env: - RUBYCI_SCREENSHOT_SLACK_API_TOKEN: ${{ secrets.RUBYCI_SCREENSHOT_SLACK_API_TOKEN }} - RUBYCI_SCREENSHOT_SLACK_CHANNEL_ID: ${{ secrets.RUBYCI_SCREENSHOT_SLACK_CHANNEL_ID }} - -# - uses: actions/upload-artifact@master -# with: -# name: rubyci-screenshot -# path: rubyci.png diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 77497590c..000000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -rubyci.orig.png -rubyci.png diff --git a/Gemfile b/Gemfile deleted file mode 100644 index dfba848bc..000000000 --- a/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source "https://rubygems.org" - -gem "selenium-webdriver" diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index b176b7cfe..000000000 --- a/Gemfile.lock +++ /dev/null @@ -1,17 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - childprocess (3.0.0) - rubyzip (3.4.0) - selenium-webdriver (3.142.6) - childprocess (>= 0.5, < 4.0) - rubyzip (>= 1.2.2) - -PLATFORMS - ruby - -DEPENDENCIES - selenium-webdriver - -BUNDLED WITH - 2.1.2 diff --git a/rubyci-screenshot.rb b/rubyci-screenshot.rb deleted file mode 100644 index 77ac16f13..000000000 --- a/rubyci-screenshot.rb +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env ruby - -require "selenium-webdriver" -require "net/http" -require "openssl" - -SLACK_API_TOKEN = ENV["RUBYCI_SCREENSHOT_SLACK_API_TOKEN"] -CHANNEL_ID = ENV["RUBYCI_SCREENSHOT_SLACK_CHANNEL_ID"] -FILES_UPLOAD_URI = "https://slack.com/api/files.upload" - -Dir.chdir(__dir__) - -system("/snap/bin/chromium.chromedriver", "-v") -Selenium::WebDriver::Chrome::Service.driver_path = "/snap/bin/chromium.chromedriver" - -options = Selenium::WebDriver::Chrome::Options.new -options.add_argument("--headless") -options.add_argument("--disable-gpu") -options.add_argument("--disable-dev-shm-usage") -options.add_argument("--no-sandbox") -options.add_argument("--window-size=1280,3000") -driver = Selenium::WebDriver.for(:chrome, options: options) - -driver.navigate.to("https://rubyci.org") -driver.execute_script(< Date: Wed, 14 Oct 2026 09:01:30 +0900 Subject: [PATCH 2/3] Run rubyci-alerts on Ruby 4.0 Ruby 2.7 is EOL. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/rubyci-alerts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rubyci-alerts.yml b/.github/workflows/rubyci-alerts.yml index 1bcf2c319..b4f03ee7e 100644 --- a/.github/workflows/rubyci-alerts.yml +++ b/.github/workflows/rubyci-alerts.yml @@ -12,7 +12,7 @@ jobs: - uses: ruby/setup-ruby@e81a8fa391b11a595c1b7ed84177cc0fe02faf83 # v1.328.0 with: - ruby-version: 2.7 + ruby-version: "4.0" - name: Use master branch run: git checkout master From d9cb9506bff1bcf8c81e178021d066a4f9a65d64 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 14 Oct 2026 09:01:39 +0900 Subject: [PATCH 3/3] Add tests and CI for rubyci-alerts Dependency bumps from dependabot had nothing to check them. The fixtures are records trimmed from rubyci.org's servers.json and reports.json. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/test.yml | 26 ++++++++++++++++++++ Gemfile | 4 +++ Gemfile.lock | 17 +++++++++++++ Rakefile | 5 ++++ rubyci-alerts.rb | 32 ++++++++++++------------ test/fixtures/reports.json | 50 ++++++++++++++++++++++++++++++++++++++ test/fixtures/servers.json | 20 +++++++++++++++ test/test_rubyci_alerts.rb | 41 +++++++++++++++++++++++++++++++ 8 files changed, 180 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 Rakefile create mode 100644 test/fixtures/reports.json create mode 100644 test/fixtures/servers.json create mode 100644 test/test_rubyci_alerts.rb diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..0185add6f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +name: test + +on: + push: + branches: + - master + pull_request: + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: ruby/setup-ruby@e81a8fa391b11a595c1b7ed84177cc0fe02faf83 # v1.328.0 + with: + ruby-version: "4.0" + bundler-cache: true + + - name: Run the tests + run: bundle exec rake test diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..eb8619204 --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source "https://rubygems.org" + +gem "rake" +gem "test-unit" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..4c27565fe --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,17 @@ +GEM + remote: https://rubygems.org/ + specs: + power_assert (3.1.0) + rake (13.4.2) + test-unit (3.7.8) + power_assert + +PLATFORMS + ruby + +DEPENDENCIES + rake + test-unit + +BUNDLED WITH + 4.0.20 diff --git a/Rakefile b/Rakefile new file mode 100644 index 000000000..5d28d9f1b --- /dev/null +++ b/Rakefile @@ -0,0 +1,5 @@ +require "rake/testtask" + +Rake::TestTask.new + +task default: :test diff --git a/rubyci-alerts.rb b/rubyci-alerts.rb index fccc7ae59..3e4ad773d 100644 --- a/rubyci-alerts.rb +++ b/rubyci-alerts.rb @@ -136,21 +136,23 @@ def filter_failure_reports(failure_reports, timestamps) end end -begin - timestamps = {} - timestamps = JSON.parse(File.read(TIMESTAMPS_JSON)) - - servers = get_servers - failure_reports = get_failure_reports(servers) - filter_failure_reports(failure_reports, timestamps) - failure_reports.each do |_key, report| - notify_simpler_alerts(report) - end +if __FILE__ == $0 + begin + timestamps = {} + timestamps = JSON.parse(File.read(TIMESTAMPS_JSON)) + + servers = get_servers + failure_reports = get_failure_reports(servers) + filter_failure_reports(failure_reports, timestamps) + failure_reports.each do |_key, report| + notify_simpler_alerts(report) + end - File.write(TIMESTAMPS_JSON, JSON.pretty_generate(timestamps)) -rescue => e - NOTIFY_CHANNELS.each do |channel| - notify_slack("ruby/rubyci-alerts failed: #{e.class}: #{ escape(e.message) }", channel: channel) + File.write(TIMESTAMPS_JSON, JSON.pretty_generate(timestamps)) + rescue => e + NOTIFY_CHANNELS.each do |channel| + notify_slack("ruby/rubyci-alerts failed: #{e.class}: #{ escape(e.message) }", channel: channel) + end + puts e.backtrace end - puts e.backtrace end diff --git a/test/fixtures/reports.json b/test/fixtures/reports.json new file mode 100644 index 000000000..22170a289 --- /dev/null +++ b/test/fixtures/reports.json @@ -0,0 +1,50 @@ +[ + { + "id": 4448056, + "server_id": 122, + "datetime": "2026-10-13T20:29:06.000Z", + "branch": "master", + "revision": "7ad8db2311523bc1af6a97154a65bb56758d8f7a", + "summary": "7ad8db23115 ruby (osx1400arm) 67W failed(dist) (diff:test-all,dist,success)", + "created_at": "2026-10-13T21:21:40.268Z", + "updated_at": "2026-10-13T21:21:40.268Z", + "option": null, + "ltsv": "host:osx1400arm\tdepsuffixed_name:ruby-master\tstart_time:20261013T202906Z\tresult:failure\ttitle:7ad8db23115 ruby (osx1400arm) 67W failed(dist)\tcompressed_loghtml_relpath:log/20261013T202906Z.log.html.gz\tcompressed_failhtml_relpath:log/20261013T202906Z.fail.html.gz\tcompressed_diffhtml_relpath:log/20261013T202906Z.diff.html.gz\tdifferent_sections:test-all,dist,success\tversion:7ad8db23115 ruby\tdep_versions:[]\thostname:(osx1400arm)\twarn:67W\tmark:\tstatus:\tfailure_dist:failed(dist)\thttps://github.com/ruby/ruby:7ad8db2311523bc1af6a97154a65bb56758d8f7a\truby_rev:7ad8db23115" + }, + { + "id": 4448111, + "server_id": 122, + "datetime": "2026-10-13T21:45:04.000Z", + "branch": "master", + "revision": "67abedae69744b89fb477f96568a9363addfb469", + "summary": "67abedae697 ruby (osx1400arm) 3W success (diff:src,miniversion,version,test-all,rubyspec,dist)", + "created_at": "2026-10-13T22:51:22.807Z", + "updated_at": "2026-10-13T22:51:22.807Z", + "option": null, + "ltsv": "host:osx1400arm\tdepsuffixed_name:ruby-master\tstart_time:20261013T214504Z\tresult:success\ttitle:67abedae697 ruby (osx1400arm) 3W\tcompressed_loghtml_relpath:log/20261013T214504Z.log.html.gz\tcompressed_failhtml_relpath:log/20261013T214504Z.fail.html.gz\tcompressed_diffhtml_relpath:log/20261013T214504Z.diff.html.gz\tdifferent_sections:src,miniversion,version,test-all,rubyspec,dist\tversion:67abedae697 ruby\tdep_versions:[]\thostname:(osx1400arm)\twarn:3W\tmark:\tstatus:\thttps://github.com/ruby/ruby:67abedae69744b89fb477f96568a9363addfb469\truby_rev:67abedae697" + }, + { + "id": 4448055, + "server_id": 122, + "datetime": "2026-10-13T20:29:06.000Z", + "branch": "3.3", + "revision": "7ad8db2311523bc1af6a97154a65bb56758d8f7a", + "summary": "7ad8db23115 ruby (osx1400arm) 67W failed(dist) (diff:test-all,dist,success)", + "created_at": "2026-10-13T21:21:40.268Z", + "updated_at": "2026-10-13T21:21:40.268Z", + "option": null, + "ltsv": "host:osx1400arm\tdepsuffixed_name:ruby-3.3\tstart_time:20261013T202906Z\tresult:failure\ttitle:7ad8db23115 ruby (osx1400arm) 67W failed(dist)\tcompressed_loghtml_relpath:log/20261013T202906Z.log.html.gz\tcompressed_failhtml_relpath:log/20261013T202906Z.fail.html.gz\tcompressed_diffhtml_relpath:log/20261013T202906Z.diff.html.gz\tdifferent_sections:test-all,dist,success\tversion:7ad8db23115 ruby\tdep_versions:[]\thostname:(osx1400arm)\twarn:67W\tmark:\tstatus:\tfailure_dist:failed(dist)\thttps://github.com/ruby/ruby:7ad8db2311523bc1af6a97154a65bb56758d8f7a\truby_rev:7ad8db23115" + }, + { + "id": 4447990, + "server_id": 40, + "datetime": "2026-10-13T18:30:12.000Z", + "branch": "master", + "revision": "15212f6c1cf04e18c43ca44601f525a3bbf32b62", + "summary": "15212f6c1cf ruby (icc-x64) 12W failed(test-all) (diff:test-all)", + "created_at": "2026-10-13T19:20:41.000Z", + "updated_at": "2026-10-13T19:20:41.000Z", + "option": null, + "ltsv": "host:icc-x64\tdepsuffixed_name:ruby-master\tstart_time:20261013T183012Z\tresult:failure\ttitle:15212f6c1cf ruby (icc-x64) 12W failed(test-all)\tcompressed_loghtml_relpath:log/20261013T183012Z.log.html.gz\tcompressed_failhtml_relpath:log/20261013T183012Z.fail.html.gz\tcompressed_diffhtml_relpath:log/20261013T183012Z.diff.html.gz\tdifferent_sections:test-all\tversion:15212f6c1cf ruby\tdep_versions:[]\thostname:(icc-x64)\twarn:12W\tmark:\tstatus:\tfailure_test-all:failed(test-all)\thttps://github.com/ruby/ruby:15212f6c1cf04e18c43ca44601f525a3bbf32b62\truby_rev:15212f6c1cf" + } +] diff --git a/test/fixtures/servers.json b/test/fixtures/servers.json new file mode 100644 index 000000000..25c4dbc5c --- /dev/null +++ b/test/fixtures/servers.json @@ -0,0 +1,20 @@ +[ + { + "id": 40, + "name": "icc 2025.3 x64 (Ubuntu)", + "uri": "http://rubyci.s3.amazonaws.com/icc-x64/", + "created_at": "2015-03-26T04:15:50.556Z", + "updated_at": "2026-09-10T06:53:58.177Z", + "ordinal": 17.0, + "eol_date": "2029-04-30" + }, + { + "id": 122, + "name": "macOS 14.8 Sonoma", + "uri": "http://rubyci.s3.amazonaws.com/osx1400arm/", + "created_at": "2024-10-30T03:19:22.970Z", + "updated_at": "2026-02-13T08:22:13.596Z", + "ordinal": 14.68, + "eol_date": null + } +] diff --git a/test/test_rubyci_alerts.rb b/test/test_rubyci_alerts.rb new file mode 100644 index 000000000..ff8e5212b --- /dev/null +++ b/test/test_rubyci_alerts.rb @@ -0,0 +1,41 @@ +require "test/unit" +require_relative "../rubyci-alerts" + +class TestRubyCIAlerts < Test::Unit::TestCase + FIXTURES = File.join(__dir__, "fixtures") + + # URI.open falls back to Kernel#open for a local path, so the fixtures go + # through the real fetch_json. + def fetch_json(url) + super(File.join(FIXTURES, File.basename(url))) + end + + def test_get_failure_reports + reports = get_failure_reports(get_servers).map {|_key, report| report.to_h } + assert_equal [ + { + name: "macOS 14.8 Sonoma", + commit: "7ad8db23115", + fail_uri: "http://rubyci.s3.amazonaws.com/osx1400arm/ruby-master/log/20261013T202906Z.fail.html.gz", + shortsummary: "67W failed(dist)", + }, + { + name: "icc 2025.3 x64 (Ubuntu)", + commit: "15212f6c1cf", + fail_uri: "http://rubyci.s3.amazonaws.com/icc-x64/ruby-master/log/20261013T183012Z.fail.html.gz", + shortsummary: "12W failed(test-all)", + }, + ], reports + end + + def test_filter_failure_reports + reports = get_failure_reports(get_servers) + notified = Time.iso8601("2026-10-13T20:29:06Z").to_i + timestamps = { "122" => notified } + + filter_failure_reports(reports, timestamps) + + assert_equal ["icc 2025.3 x64 (Ubuntu)"], reports.map {|_key, report| report.name } + assert_equal({ "122" => notified, "40" => Time.iso8601("2026-10-13T18:30:12Z").to_i }, timestamps) + end +end