From 0ffe2a4fb6035f0abfb3a0ef780be213e3f327c2 Mon Sep 17 00:00:00 2001 From: Mike Linksvayer Date: Mon, 16 Nov 2026 21:28:31 +0000 Subject: [PATCH 1/2] Avoid duplicate CI runs and skip inconclusive organization checks Run push checks only on gh-pages while retaining pull request checks. Retain entries when organization checks encounter unavailable responses, with collapsed diagnostics and offline regression tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/build.yml | 5 +- .github/workflows/ensure-alphabetize.yml | 1 + .github/workflows/ensure-orgs.yml | 5 ++ .github/workflows/ensure-unique.yml | 1 + .github/workflows/rubucop.yml | 1 + script/ensure-orgs | 33 ++++++++---- test/ensure_orgs_test.rb | 66 ++++++++++++++++++++++++ 7 files changed, 101 insertions(+), 11 deletions(-) create mode 100644 test/ensure_orgs_test.rb diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0e78642ba..bfd9474a6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,10 @@ name: Test site build permissions: contents: read -on: [push, pull_request] +on: + push: + branches: [gh-pages] + pull_request: jobs: build: diff --git a/.github/workflows/ensure-alphabetize.yml b/.github/workflows/ensure-alphabetize.yml index 1dc0f6b1f..39fd29914 100644 --- a/.github/workflows/ensure-alphabetize.yml +++ b/.github/workflows/ensure-alphabetize.yml @@ -4,6 +4,7 @@ permissions: on: push: + branches: [gh-pages] paths: - "Gemfile" - "script/alphabetize" diff --git a/.github/workflows/ensure-orgs.yml b/.github/workflows/ensure-orgs.yml index 8b62cf03d..895506a0a 100644 --- a/.github/workflows/ensure-orgs.yml +++ b/.github/workflows/ensure-orgs.yml @@ -4,15 +4,18 @@ permissions: on: push: + branches: [gh-pages] paths: - "Gemfile" - "script/ensure-orgs" + - "test/ensure_orgs_test.rb" - ".github/workflows/ensure-orgs.yml" - "_data/**" pull_request: paths: - "Gemfile" - "script/ensure-orgs" + - "test/ensure_orgs_test.rb" - ".github/workflows/ensure-orgs.yml" - "_data/**" @@ -27,5 +30,7 @@ jobs: uses: ruby/setup-ruby@de492cf36cbab201753d720ce4f4e336cd688c94 # v1.336.0 with: bundler-cache: true + - name: Test organization checks + run: bundle exec ruby test/ensure_orgs_test.rb - name: Ensure data entries are GitHub Orgs run: bundle exec script/ensure-orgs diff --git a/.github/workflows/ensure-unique.yml b/.github/workflows/ensure-unique.yml index 2010e5506..4254106c0 100644 --- a/.github/workflows/ensure-unique.yml +++ b/.github/workflows/ensure-unique.yml @@ -4,6 +4,7 @@ permissions: on: push: + branches: [gh-pages] paths: - "Gemfile" - "script/ensure-unique" diff --git a/.github/workflows/rubucop.yml b/.github/workflows/rubucop.yml index ec02c21ad..bc59e3977 100644 --- a/.github/workflows/rubucop.yml +++ b/.github/workflows/rubucop.yml @@ -4,6 +4,7 @@ permissions: on: push: + branches: [gh-pages] paths: - "Gemfile" - ".rubocop.yml" diff --git a/script/ensure-orgs b/script/ensure-orgs index 2e3b41eb8..44771e365 100755 --- a/script/ensure-orgs +++ b/script/ensure-orgs @@ -23,26 +23,32 @@ end Typhoeus::Config.cache = Cache.new -# Ideally this would be an API call, but given the volume of calls, -# We'd constantly hit any rate limit as each needs to be its own query -def org?(user) - response = Typhoeus.head "https://github.com/orgs/#{user}/people", accept_encoding: 'gzip' - response.success? || response.response_code == 429 -end - puts 'Checking that all orgs listed are in fact, an org...' data_folder_path = File.expand_path '../_data', File.dirname(__FILE__) files = Dir["#{data_folder_path}/*.yml"] valid = true +skipped = [] files.each do |file| data = YAML.load_file file data.each do |group, orgs| - not_orgs = Parallel.map(orgs) { |org| org unless org?(org) }.compact + responses = Parallel.map(orgs) do |org| + [org, Typhoeus.head("https://github.com/orgs/#{org}/people", accept_encoding: 'gzip')] + end + not_orgs = [] + responses.each do |org, response| + next if response.success? + + if response.response_code == 404 + not_orgs << org + else + skipped << "#{org}: HTTP #{response.response_code} (#{response.return_code})" + end + end next if not_orgs.empty? - puts "\nIn #{File.basename(file)}, in the #{group} group, the following entries are users, not orgs:\n\n" + puts "\nIn #{File.basename(file)}, in the #{group} group, the following entries are not organizations or no longer exist:\n\n" puts not_orgs valid = false data[group] = data[group] - not_orgs @@ -55,8 +61,15 @@ files.each do |file| File.write(file, output) end +unless skipped.empty? + puts '::group::Inconclusive organization checks' if ENV['GITHUB_ACTIONS'] == 'true' + puts skipped + puts '::endgroup::' if ENV['GITHUB_ACTIONS'] == 'true' + puts "Skipped #{skipped.length} organization checks due to unavailable responses; entries retained." +end + if valid - puts 'All orgs check out.' + puts(skipped.empty? ? 'All orgs check out.' : 'No non-organizations found among completed checks.') exit 0 else exit 1 diff --git a/test/ensure_orgs_test.rb b/test/ensure_orgs_test.rb new file mode 100644 index 000000000..2a73f66ed --- /dev/null +++ b/test/ensure_orgs_test.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +require 'minitest/autorun' +require 'fileutils' +require 'json' +require 'open3' +require 'tmpdir' +require 'yaml' + +class EnsureOrgsTest < Minitest::Test + def run_check(codes) + Dir.mktmpdir do |dir| + FileUtils.mkdir_p("#{dir}/script") + FileUtils.mkdir_p("#{dir}/_data") + FileUtils.cp(File.expand_path('../script/ensure-orgs', __dir__), "#{dir}/script/ensure-orgs") + data_path = "#{dir}/_data/orgs.yml" + File.write(data_path, "# Organizations\n\nTest:\n#{codes.keys.map { |org| " - #{org}\n" }.join}") + File.write("#{dir}/responses.rb", <<~RUBY) + require 'typhoeus' + require 'json' + Typhoeus::Config.block_connection = true + JSON.parse(ENV.fetch('ORG_RESPONSES')).each do |org, code| + Typhoeus.stub("https://github.com/orgs/\#{org}/people").and_return( + Typhoeus::Response.new(code: code, return_code: code.zero? ? :operation_timedout : :ok) + ) + end + RUBY + output, status = Open3.capture2e( + { 'ORG_RESPONSES' => codes.to_json, 'GITHUB_ACTIONS' => 'true' }, + Gem.ruby, '-r', "#{dir}/responses.rb", "#{dir}/script/ensure-orgs" + ) + [output, status, YAML.safe_load_file(data_path).fetch('Test')] + end + end + + def test_unavailable_responses_are_inconclusive_and_retained + codes = { 'org' => 200, 'forbidden' => 403, 'limited' => 429, 'server-error' => 500, + 'unavailable' => 503, 'timeout' => 0, 'redirect' => 302 } + output, status, entries = run_check(codes) + + assert status.success?, output + assert_equal codes.keys, entries + assert_includes output, 'Skipped 6 organization checks' + assert_includes output, "::group::Inconclusive organization checks\n" + assert_includes output, "::endgroup::\n" + refute_includes output, 'All orgs check out.' + end + + def test_not_found_still_fails_without_removing_inconclusive_entries + output, status, entries = run_check('org' => 200, 'user' => 404, 'limited' => 429) + + assert_equal 1, status.exitstatus, output + assert_equal %w[org limited], entries + assert_includes output, 'not organizations or no longer exist' + assert_includes output, 'Skipped 1 organization checks' + end + + def test_successful_checks_report_success + output, status, entries = run_check('org' => 200) + + assert status.success?, output + assert_equal ['org'], entries + assert_includes output, 'All orgs check out.' + refute_includes output, 'Skipped' + end +end From ab79e73515ee552bb0382ed5fbef5791ef877cd2 Mon Sep 17 00:00:00 2001 From: Mike Linksvayer Date: Mon, 16 Nov 2026 21:48:19 +0000 Subject: [PATCH 2/2] Summarize organization responses and remove missing accounts Log only failing entries and aggregate response statistics. Remove EVS-ATMOS, lblpbd, and nasajpl, which return 404. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- _data/research.yml | 3 --- script/ensure-orgs | 23 ++++++++++------------- test/ensure_orgs_test.rb | 9 +++++++-- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/_data/research.yml b/_data/research.yml index 24b71a9e1..da50b7a3c 100644 --- a/_data/research.yml +++ b/_data/research.yml @@ -299,7 +299,6 @@ U.S. Research Labs: - EMSL-MSC - epicsdeb - esgf - - EVS-ATMOS - exmatex - flux-framework - gatech @@ -322,7 +321,6 @@ U.S. Research Labs: - LANL-Bioinformatics - lbl-anp - lbl-cal - - lblpbd - libmesh - llnl - losalamos @@ -336,7 +334,6 @@ U.S. Research Labs: - mit-ll - mitre - NASA-Tensegrity-Robotics-Toolkit - - nasajpl - ncats - ncbi - ncip diff --git a/script/ensure-orgs b/script/ensure-orgs index 44771e365..ed1c5ba21 100755 --- a/script/ensure-orgs +++ b/script/ensure-orgs @@ -29,7 +29,7 @@ data_folder_path = File.expand_path '../_data', File.dirname(__FILE__) files = Dir["#{data_folder_path}/*.yml"] valid = true -skipped = [] +response_counts = Hash.new(0) files.each do |file| data = YAML.load_file file data.each do |group, orgs| @@ -38,17 +38,14 @@ files.each do |file| end not_orgs = [] responses.each do |org, response| + response_counts[response.response_code] += 1 next if response.success? - if response.response_code == 404 - not_orgs << org - else - skipped << "#{org}: HTTP #{response.response_code} (#{response.return_code})" - end + not_orgs << org if response.response_code == 404 end next if not_orgs.empty? - puts "\nIn #{File.basename(file)}, in the #{group} group, the following entries are not organizations or no longer exist:\n\n" + puts "\nIn #{File.basename(file)}, in the #{group} group, the following entries are not organizations or no longer exist (HTTP 404):\n\n" puts not_orgs valid = false data[group] = data[group] - not_orgs @@ -61,15 +58,15 @@ files.each do |file| File.write(file, output) end -unless skipped.empty? - puts '::group::Inconclusive organization checks' if ENV['GITHUB_ACTIONS'] == 'true' - puts skipped - puts '::endgroup::' if ENV['GITHUB_ACTIONS'] == 'true' - puts "Skipped #{skipped.length} organization checks due to unavailable responses; entries retained." +puts "Responses (#{response_counts.values.sum} total):" +response_counts.sort.each do |code, count| + puts "#{code.zero? ? 'No HTTP response' : "HTTP #{code}"}: #{count}" end +skipped = response_counts.sum { |code, count| code.between?(200, 299) || code == 404 ? 0 : count } +puts "Skipped #{skipped} organization checks due to unavailable responses; entries retained." if skipped.positive? if valid - puts(skipped.empty? ? 'All orgs check out.' : 'No non-organizations found among completed checks.') + puts(skipped.zero? ? 'All orgs check out.' : 'No non-organizations found among completed checks.') exit 0 else exit 1 diff --git a/test/ensure_orgs_test.rb b/test/ensure_orgs_test.rb index 2a73f66ed..32bbd8a87 100644 --- a/test/ensure_orgs_test.rb +++ b/test/ensure_orgs_test.rb @@ -41,8 +41,11 @@ def test_unavailable_responses_are_inconclusive_and_retained assert status.success?, output assert_equal codes.keys, entries assert_includes output, 'Skipped 6 organization checks' - assert_includes output, "::group::Inconclusive organization checks\n" - assert_includes output, "::endgroup::\n" + assert_includes output, 'Responses (7 total):' + assert_includes output, 'HTTP 403: 1' + assert_includes output, 'HTTP 429: 1' + assert_includes output, 'No HTTP response: 1' + codes.keys.drop(1).each { |org| refute_includes output, "#{org}:" } refute_includes output, 'All orgs check out.' end @@ -52,6 +55,8 @@ def test_not_found_still_fails_without_removing_inconclusive_entries assert_equal 1, status.exitstatus, output assert_equal %w[org limited], entries assert_includes output, 'not organizations or no longer exist' + assert_includes output, "(HTTP 404):\n\nuser\n" + assert_includes output, 'HTTP 404: 1' assert_includes output, 'Skipped 1 organization checks' end