Skip to content

Commit

Permalink
Merge branch 'main' into ropensci
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanxu committed Oct 24, 2024
2 parents 4958a28 + c475f48 commit ac0a7f4
Show file tree
Hide file tree
Showing 44 changed files with 358 additions and 217 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ jobs:
continue-on-error: ${{ matrix.failure-allowed }}
strategy:
matrix:
ruby-version: ['2.7.8', '3.0.6', '3.1.4', '3.2.2']
ruby-version: ['3.0.7', '3.1.6', '3.2.5', '3.3.4']
failure-allowed: [false]
include:
- ruby-version: 'truffleruby'
failure-allowed: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
18 changes: 18 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

python:
install:
- requirements: docs/requirements.txt
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.1
3.3.3
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ if ENV["CUSTOM_RUBY_VERSION"]
end

gem 'octokit'
gem 'sinatra', '3.0.5'
gem 'sinatra-contrib', '3.0.5'
gem 'sinatra', '4.0.0'
gem 'sinatra-contrib', '4.0.0'
gem 'openssl'
gem 'puma'
gem 'sidekiq'
Expand Down
148 changes: 82 additions & 66 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,94 +1,107 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
airrecord (1.0.12)
faraday (>= 1.0, < 3.0)
faraday-net_http_persistent
net-http-persistent
bibtex-ruby (6.0.0)
base64 (0.2.0)
bibtex-ruby (6.1.0)
latex-decode (~> 0.0)
cgi (0.3.6)
charlock_holmes (0.7.7)
racc (~> 1.7)
bigdecimal (3.1.8)
cgi (0.4.1)
charlock_holmes (0.7.9)
chronic (0.10.2)
concurrent-ruby (1.2.2)
connection_pool (2.4.0)
crack (0.4.5)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crack (1.0.0)
bigdecimal
rexml
diff-lcs (1.5.0)
dotenv (2.8.1)
faraday (2.7.4)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
diff-lcs (1.5.1)
dotenv (3.1.4)
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
json
logger
faraday-follow_redirects (0.1.0)
faraday (>= 2, < 3)
faraday-net_http (3.0.2)
faraday-net_http (3.3.0)
net-http
faraday-net_http_persistent (2.1.0)
faraday (~> 2.5)
net-http-persistent (~> 4.0)
faraday-retry (2.1.0)
faraday-retry (2.2.1)
faraday (~> 2.0)
github-linguist (7.25.0)
github-linguist (8.0.1)
cgi
charlock_holmes (~> 0.7.7)
mini_mime (~> 1.0)
rugged (~> 1.0)
hashdiff (1.0.1)
issue (1.0.0)
openssl
rack
hashdiff (1.1.1)
issue (1.0.2)
openssl (~> 3.2)
rack (~> 3.1)
json (2.7.2)
latex-decode (0.4.0)
licensee (9.16.0)
dotenv (~> 2.0)
octokit (>= 4.20, < 7.0)
licensee (9.17.1)
dotenv (>= 2, < 4)
octokit (>= 4.20, < 10.0)
reverse_markdown (>= 1, < 3)
rugged (>= 0.24, < 2.0)
thor (>= 0.19, < 2.0)
mini_mime (1.1.2)
mini_portile2 (2.8.1)
logger (1.6.1)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
multi_json (1.15.0)
mustermann (3.0.0)
mustermann (3.0.3)
ruby2_keywords (~> 0.0.1)
net-http (0.4.1)
uri
net-http-persistent (4.0.2)
connection_pool (~> 2.2)
nio4r (2.5.9)
nokogiri (1.14.3)
mini_portile2 (~> 2.8.0)
nio4r (2.7.3)
nokogiri (1.16.7)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
octokit (6.1.1)
octokit (9.1.0)
faraday (>= 1, < 3)
sawyer (~> 0.9)
openssl (3.1.0)
public_suffix (5.0.1)
puma (6.2.1)
openssl (3.2.0)
public_suffix (6.0.1)
puma (6.4.3)
nio4r (~> 2.0)
racc (1.6.2)
rack (2.2.6.4)
rack-protection (3.0.5)
rack
racc (1.8.1)
rack (3.1.7)
rack-protection (4.0.0)
base64 (>= 0.1.0)
rack (>= 3.0.0, < 4)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
redis-client (0.14.1)
redis-client (0.22.2)
connection_pool
reverse_markdown (2.1.1)
nokogiri
rexml (3.2.5)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.1)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.2)
rexml (3.3.7)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.1)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.5)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
ruby2_keywords (0.0.5)
rugged (1.6.3)
rugged (1.7.2)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
Expand All @@ -98,25 +111,28 @@ GEM
multi_json (~> 1.15)
rexml (~> 3.2, >= 3.2.5)
thor (~> 1.2, >= 1.2.1)
sidekiq (7.0.8)
sidekiq (7.3.2)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
logger
rack (>= 2.2.4)
redis-client (>= 0.11.0)
sinatra (3.0.5)
redis-client (>= 0.22.2)
sinatra (4.0.0)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.0.5)
rack (>= 3.0.0, < 4)
rack-protection (= 4.0.0)
rack-session (>= 2.0.0, < 3)
tilt (~> 2.0)
sinatra-contrib (3.0.5)
multi_json
sinatra-contrib (4.0.0)
multi_json (>= 0.0.2)
mustermann (~> 3.0)
rack-protection (= 3.0.5)
sinatra (= 3.0.5)
rack-protection (= 4.0.0)
sinatra (= 4.0.0)
tilt (~> 2.0)
thor (1.2.1)
tilt (2.1.0)
webmock (3.18.1)
thor (1.3.2)
tilt (2.4.0)
uri (0.13.1)
webmock (3.23.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
Expand All @@ -141,9 +157,9 @@ DEPENDENCIES
rspec
serrano
sidekiq
sinatra (= 3.0.5)
sinatra-contrib (= 3.0.5)
sinatra (= 4.0.0)
sinatra-contrib (= 4.0.0)
webmock

BUNDLED WITH
2.3.4
2.5.14
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Buffy

A service to provide a bot helping scientific journals manage submission reviews.
A service to provide a bot helping scientific journals and communities manage submission reviews.

Buffy automates common editorial tasks like those needed by [The Journal of Open Source Software](https://joss.theoj.org/) or [rOpenSci](https://ropensci.org/).
Buffy automates common editorial tasks like those needed by [The Journal of Open Source Software](https://joss.theoj.org/), [rOpenSci](https://ropensci.org/), [JuliaCon](https://proceedings.juliacon.org/) or [pyOpenSci](https://www.pyopensci.org/).

[![Build Status](https://github.com/openjournals/buffy/actions/workflows/tests.yml/badge.svg)](https://github.com/openjournals/buffy/actions/workflows/tests.yml)
[![Documentation Status](https://readthedocs.org/projects/buffy/badge/?version=latest)](https://buffy.readthedocs.io/en/latest/?badge=latest)
58 changes: 46 additions & 12 deletions app/lib/doi_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,52 @@ def initialize(entries=[])
end

def check_dois
doi_summary = {ok: [], missing: [], invalid: []}
doi_summary = {ok: [], skip: [], missing: [], invalid: []}

if @entries.any?
@entries.each do |entry|
if entry.has_field?('doi') && !entry.doi.empty?
# handle special cases first
if special_case = handle_special_case(entry)
doi_validity = special_case
elsif entry.has_field?('doi') && !entry.doi.empty?
# Validate entries with DOIs
doi_validity = validate_doi(entry.doi.value)
doi_summary[doi_validity[:validity]].push(doi_validity[:msg])
# If there's no DOI present, check Crossref to see if we can find a candidate DOI for this entry.
elsif entry.has_field?('title')
candidate_doi = crossref_lookup(entry.title.value)
if candidate_doi == "CROSSREF-ERROR"
truncated_title = entry.title.to_s[0,50]
truncated_title += "..." if truncated_title.length < entry.title.to_s.length
doi_summary[:missing].push("Errored finding suggestions for \"#{truncated_title}\", please try later")
elsif candidate_doi
doi_summary[:missing].push("#{candidate_doi} may be a valid DOI for title: #{entry.title}")
end
# Try and find candidate entries if doi absent, but title present
doi_validity = handle_missing_doi(entry)
else
doi_validity = {validity: :missing, msg: "Entry without DOI or title found"}
end

doi_summary[doi_validity[:validity]].push(doi_validity[:msg])
end
end

doi_summary
end

# any special case should return false if not applicable, and an object like
# {:validity => :ok, :msg => "whatever"} otherwise.
# Add additional special cases as private methods and chain in a tidy sequence plz <3
def handle_special_case(entry)
acm_105555_prefix(entry) || false
end


# If there's no DOI present, check Crossref to see if we can find a candidate DOI for this entry.
def handle_missing_doi(entry)
candidate_doi = crossref_lookup(entry.title.value)
truncated_title = entry.title.to_s[0,50]
truncated_title += "..." if truncated_title.length < entry.title.to_s.length
if candidate_doi == "CROSSREF-ERROR"
{ validity: :missing, msg: "Errored finding suggestions for \"#{truncated_title}\", please try later" }
elsif candidate_doi
{ validity: :missing, msg: "#{candidate_doi} may be a valid DOI for title: #{truncated_title}" }
else
{ validity: :skip, msg: "No DOI given, and none found for title: #{truncated_title}" }
end
end

def validate_doi(doi_string)
return { validity: :invalid, msg: "Empty DOI string" } if doi_string.nil? || doi_string.empty?

Expand Down Expand Up @@ -108,4 +130,16 @@ def levenshtein_distance(s, t)
def similar?(string_1, string_2)
levenshtein_distance(string_1, string_2) < 3
end

private

def acm_105555_prefix(entry)
if entry.has_field?('doi') && entry.doi.include?("10.5555/")
{ validity: :invalid, msg: "#{entry.doi} is INVALID - 10.5555 is a known broken prefix, replace with https://dl.acm.org/doi/{doi} in the {url} field" }
elsif entry.has_field?('url') && entry.url.include?("https://dl.acm.org/doi/10.5555")
{ validity: :skip, msg: "#{entry.url} - non-DOI with 10.5555 correctly placed in the url field, editor should ensure this resolves" }
else
false
end
end
end
2 changes: 1 addition & 1 deletion app/lib/paper_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def self.find(search_path)

if Dir.exist? search_path
Find.find(search_path).each do |path|
if path =~ /paper\.tex$|paper\.md$/
if path =~ /\/paper\.tex$|\/paper\.md$/
paper_path = path
break
end
Expand Down
1 change: 1 addition & 0 deletions app/lib/responder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def locals
from_context = Sinatra::IndifferentHash[
issue_id: context.issue_id,
issue_author: context.issue_author,
issue_title: context.issue_title,
repo: context.repo,
sender: context.sender,
bot_name: bot_name ]
Expand Down
2 changes: 1 addition & 1 deletion app/lib/responder_registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def self.available_responders
responder_class = Object.const_get(name)
available_responders[responder_class.key] = responder_class
rescue NameError => err
logger.warn("There is a mismatch in a Responder class name/module: #{err.message}")
Logger.new(STDOUT).warn("There is a mismatch in a Responder class name/module: #{err.message}")
end
end

Expand Down
5 changes: 0 additions & 5 deletions app/lib/utilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,4 @@ def run_cloc(local_path)
status.success? ? result : nil
end

def run_gitinspector(local_path)
result, stderr, status = Open3.capture3("PYTHONIOENCODING=utf-8 gitinspector -f** #{local_path}")
status.success? ? result : nil
end

end
Loading

0 comments on commit ac0a7f4

Please sign in to comment.