Skip to content

Commit

Permalink
Merge branch 'joss' into jose
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanxu committed Mar 14, 2024
2 parents a59f78d + b798aab commit ce69121
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 95 deletions.
36 changes: 18 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ GEM
chronic (0.10.2)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
crack (0.4.6)
crack (1.0.0)
bigdecimal
rexml
diff-lcs (1.5.1)
Expand Down Expand Up @@ -50,7 +50,7 @@ GEM
net-http (0.4.1)
uri
nio4r (2.7.0)
nokogiri (1.16.0)
nokogiri (1.16.2)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
octokit (8.1.0)
Expand All @@ -64,34 +64,34 @@ GEM
puma (6.4.2)
nio4r (~> 2.0)
racc (1.7.3)
rack (3.0.9)
rack (3.0.9.1)
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.19.1)
redis-client (0.20.0)
connection_pool
reverse_markdown (2.1.1)
nokogiri
rexml (3.2.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.6)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
rspec-support (~> 3.13.0)
rspec-support (3.13.0)
ruby2_keywords (0.0.5)
rugged (1.7.1)
rugged (1.7.2)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
Expand All @@ -101,7 +101,7 @@ GEM
multi_json (~> 1.15)
rexml (~> 3.2, >= 3.2.5)
thor (~> 1.2, >= 1.2.1)
sidekiq (7.2.1)
sidekiq (7.2.2)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
Expand All @@ -121,7 +121,7 @@ GEM
thor (1.3.0)
tilt (2.3.0)
uri (0.13.0)
webmock (3.19.1)
webmock (3.22.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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/).

Expand Down
10 changes: 7 additions & 3 deletions app/lib/doi_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ def check_dois
# 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)
truncated_title = entry.title.to_s[0,50]
truncated_title += "..." if truncated_title.length < entry.title.to_s.length
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}")
doi_summary[:missing].push("#{candidate_doi} may be a valid DOI for title: #{truncated_title}")
else
doi_summary[:missing].push("No DOI given, and none found for title: #{truncated_title}")
end
else
doi_summary[:missing].push("Entry without DOI or title found")
end
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
7 changes: 0 additions & 7 deletions app/workers/repo_checks_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,13 @@ def repo_summary
message = "```\nSoftware report:\n"

cloc_result = run_cloc(path)
gitinspector_result = run_gitinspector(path)

if cloc_result
message << "#{cloc_result}"
else
message << "cloc failed to run analysis of the source code"
end
message << "\n\n"

if gitinspector_result
message << "#{gitinspector_result}"
else
message << "gitinspector failed to run statistical information for the repository"
end
message << "\n```"

respond(message)
Expand Down
59 changes: 44 additions & 15 deletions config/settings-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ buffy:
only: editors
reminders:
only: editors
check_references:
description: "Check the references of the paper for missing DOIs"
example_invocation: "@editorialbot check references"
repo_checks:
description: "Perform checks on the repository"
example_invocation: "@editorialbot check repository"
jose_reviewer_checklist:
if:
title: "^\\[REVIEW\\]:"
Expand Down Expand Up @@ -124,6 +118,30 @@ buffy:
success_msg: Invitation to edit this submission sent!
error_msg: "There was a problem inviting the user to edit this submission."
github_action:
- checks:
command: check repository
workflow_repo: openjournals/joss-papers
workflow_name: checks.yml
workflow_ref: master
description: "Run checks and provide information on the repository and the paper file"
data_from_issue:
- branch
- target-repository
- issue_id
mapping:
repository_url: target-repository
- references:
command: check references
workflow_repo: openjournals/joss-papers
workflow_name: references.yml
workflow_ref: master
description: "Check the references of the paper for missing DOIs"
data_from_issue:
- branch
- target-repository
- issue_id
mapping:
repository_url: target-repository
- draft_paper:
command: generate pdf
workflow_repo: openjournals/jose-papers
Expand Down Expand Up @@ -157,7 +175,8 @@ buffy:
mapping:
repository_url: target-repository
run_responder:
responder_key: check_references
responder_key: github_action
responder_name: references
- accept:
if:
value_matches:
Expand Down Expand Up @@ -234,20 +253,30 @@ buffy:
if:
title: "^\\[PRE REVIEW\\]:"
template_file: pre-review_welcome.md
check_references: true
repo_checks: true
run_responder:
responder_key: github_action
responder_name: draft_paper
- checks:
responder_key: github_action
responder_name: checks
- references:
responder_key: github_action
responder_name: references
- draft-paper:
responder_key: github_action
responder_name: draft_paper
- review_issue:
if:
title: "^\\[REVIEW\\]:"
template_file: review_welcome.md
check_references: true
repo_checks: true
run_responder:
responder_key: github_action
responder_name: draft_paper
- checks:
responder_key: github_action
responder_name: checks
- references:
responder_key: github_action
responder_name: references
- draft-paper:
responder_key: github_action
responder_name: draft_paper
- close_other_issues:
if:
title: "^(?!\\[REVIEW\\]:|\\[PRE REVIEW\\]:)"
Expand Down
2 changes: 0 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ This will be the "user" responding to the commands issued from a reviews reposit
Some applications and services must be available to use by Buffy:

- **[Redis](https://redis.io/)**: To process background jobs Buffy needs `redis` installed.
- **[Gitinspector](https://github.com/ejwa/gitinspector)**: The *Respository Checks Responder* performs a statistical analysis using it.
- **[cloc](https://github.com/AlDanial/cloc)**: The *Respository Checks Responder* can analyze source code, to run this check `cloc` is used.

#### Deployment
Expand All @@ -47,7 +46,6 @@ As an example, we will use [Heroku](https://www.heroku.com) to deploy Buffy. How

- To process background jobs, Buffy needs a `redis` add-on, such as Heroku Redis or RedisGreen etc.
- You can use [this Heroku buildpack](https://github.com/openjournals/heroku-buildpack-cloc) to install the `cloc` dependency.
- You can install Gitinspector using npm by following the instructions [here](https://www.npmjs.com/package/gitinspector). If you plan to deploy to Heroku, you can add the `heroku/nodejs` buildpack to your app.

**2.** In the app settings add the following Config Vars:

Expand Down
2 changes: 1 addition & 1 deletion docs/responders/repo_checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The body of the issue should have the url of the repository marked with HTML com

The following values are valid for the `:checks` list:

* `repo summary`: This check performs an analysis of the source code and list authorship, contributions and file types information.
* `repo summary`: This check performs an analysis of the source code and list file types information.
* `languages`: This will detect the languages used in the repository and tagged the issue with the top three used languages.
* `wordcount`: This will count the number of words in the paper file.
* `license`: This will look for an Open Source License in the target repo and reply an error message if no license is found.
Expand Down
9 changes: 0 additions & 9 deletions package.json

This file was deleted.

19 changes: 15 additions & 4 deletions spec/doi_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@
expect(doi_summary[:missing][0]).to eq("Errored finding suggestions for \"#{expected_title}\", please try later")
end

it "should ignore entries no DOI and no crossref alternative" do
missing_doi = BibTeX::Entry.new({title: "No DOI"})
it "should report entries with no DOI and no crossref alternative as missing DOIs" do
title = "No DOI"
missing_doi = BibTeX::Entry.new({title: title})
doi_checker = DOIChecker.new([missing_doi])

expect(doi_checker).to receive(:crossref_lookup).with("No DOI").and_return(nil)
Expand All @@ -92,7 +93,17 @@

expect(doi_summary[:ok]).to be_empty
expect(doi_summary[:invalid]).to be_empty
expect(doi_summary[:missing]).to be_empty
expect(doi_summary[:missing][0]).to eq("No DOI given, and none found for title: #{title}")
end

it "should report entries with no DOI or title as missing both" do
entry = BibTeX::Entry.new(journal: "A Well Respected Journal")
doi_checker = DOIChecker.new([entry])

doi_summary = doi_checker.check_dois
expect(doi_summary[:ok]).to be_empty
expect(doi_summary[:invalid]).to be_empty
expect(doi_summary[:missing][0]).to eq("Entry without DOI or title found")
end
end

Expand Down Expand Up @@ -203,4 +214,4 @@
end
end

end
end
18 changes: 0 additions & 18 deletions spec/utilities_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,4 @@ class TestingUtilities
end
end

describe "#run_gitinspector" do
it "should run cloc return true" do
expect(Open3).to receive(:capture3).
with("PYTHONIOENCODING=utf-8 gitinspector -f** tmp/543/repo").
and_return(["OK", "", OpenStruct.new(success?: true)])

expect(subject.run_gitinspector("tmp/543/repo")).to be_truthy
end

it "should return nil if command fails" do
expect(Open3).to receive(:capture3).
with("PYTHONIOENCODING=utf-8 gitinspector -f** tmp/543/repo").
and_return(["", "stats failed", OpenStruct.new(success?: false)])

expect(subject.run_gitinspector("tmp/543/repo")).to be_falsy
end
end

end
12 changes: 0 additions & 12 deletions spec/workers/repo_checks_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,18 @@
describe "#repo_summary" do
before do
allow(@worker).to receive(:run_cloc).and_return("Ruby 50%, Julia 50%")
allow(@worker).to receive(:run_gitinspector).and_return("Author: Buffy Summers")
end

it "should include cloc report" do
expect(@worker).to receive(:respond).with(/Ruby 50%, Julia 50%/)
@worker.repo_summary
end

it "should include gitinspector report" do
expect(@worker).to receive(:respond).with(/Author: Buffy Summers/)
@worker.repo_summary
end

it "should include error message if cloc fails" do
expect(@worker).to receive(:run_cloc).and_return(nil)
expect(@worker).to receive(:respond).with(/cloc failed to run/)
@worker.repo_summary
end

it "should include gitinspector report" do
expect(@worker).to receive(:run_gitinspector).and_return(nil)
expect(@worker).to receive(:respond).with(/gitinspector failed to run/)
@worker.repo_summary
end
end

describe "#detect_languages" do
Expand Down

0 comments on commit ce69121

Please sign in to comment.