Skip to content

Commit

Permalink
feat(tasks): Reduce output for repos:licenses
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Jan 29, 2024
1 parent f8c6095 commit bc1b909
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 13 deletions.
4 changes: 1 addition & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ PROFILES = [
TEMPLATES = [
'standard_extension_template',
'standard_profile_template',
'field-level-mapping-template',
]

specifications = [
'infrastructure',
'ocds-extensions',
'standard',
'translations',
]
guides = [
'ocds-kibana-manual',
Expand Down Expand Up @@ -73,7 +71,7 @@ REPOSITORY_CATEGORIES = {
'Extension tools' => -> (repo) { extension_tools.include?(repo.name) },
'Internal tools' => -> (repo) { internal_tools.include?(repo.name) },
'Documentation dependencies' => -> (repo) { DOCUMENTATION_DEPENDENCIES.include?(repo.name) },
'Templates' => -> (repo) { template?(repo.name) },
'Templates' => -> (repo) { template?(repo.name) || repo_name == 'field-level-mapping-template' },
'Profiles' => -> (repo) { profile?(repo.name) },
'Extensions' => -> (repo) { extension?(repo.name, profiles: false, templates: false) },
}
Expand Down
59 changes: 49 additions & 10 deletions tasks/repos.rake
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,30 @@ Report issues for this extension in the [ocds-extensions repository](https://git

desc 'Lists missing or unexpected licenses'
task :licenses do
license_overrides = {
'lib-cove-oc4ids:other' => 'other:agpl-3.0-or-later',
'lib-cove-ocds:other' => 'other:agpl-3.0-or-later',
'cove-oc4ids:other' => 'other:agpl-3.0-or-later',
'cove-ocds:other' => 'other:agpl-3.0-or-later',
'software-development-handbook:other' => 'other:cc-by-4.0',
'standard-development-handbook:other' => 'other:cc-by-4.0',
}
language_overrides = {
'extension-explorer:SCSS' => 'Python',
'pelican-frontend:Vue' => 'Python',
}

repos.partition{ |repo| extension?(repo.name) }.each_with_index do |set, i|
puts
licenses = {}
set.each do |repo|
license = repo.license&.key.to_s
language = repo.language.to_s
license = license_overrides.fetch("#{repo.name}:#{license}", license)
language = language_overrides.fetch("#{repo.name}:#{language}", language)
licenses[license] ||= {}
licenses[license][language] ||= []
licenses[license][language] << repo.html_url
licenses[license][language] << repo
end

licenses.sort.each do |license, languages|
Expand All @@ -116,20 +131,44 @@ Report issues for this extension in the [ocds-extensions repository](https://git
next
end

if license.empty?
puts 'missing'.bold
else
puts license.bold
end
printed_license = false

languages.sort.each do |language, repos|
# JavaScript and Ruby are expected to be MIT. Python is expected to be BSD 3-Clause.
if i.nonzero? && (license == 'mit' && %w(JavaScript Ruby).include?(language) || license == 'bsd-3-clause' && language == 'Python')
if i.nonzero? && (
# https://blog.opensource.org/the-most-popular-licenses-for-each-language-2023/
license == 'mit' && ['JavaScript', 'Ruby', 'Rust', 'TypeScript'].include?(language) ||
# https://github.com/django/django/blob/main/LICENSE
# https://github.com/jupyter/notebook/blob/main/LICENSE
# https://github.com/pallets/click/blob/main/LICENSE.rst
# https://github.com/pallets/flask/blob/main/LICENSE.rst
license == 'bsd-3-clause' && ['Jupyter Notebook', 'Python'].include?(language) ||
# https://en.wikipedia.org/wiki/Robot_Framework
# https://en.wikipedia.org/wiki/Salt_(software)
license == 'apache-2.0' && ['RobotFramework', 'SaltStack'].include?(language)
)
next
end

repos.each do |html_url|
line = html_url
repos = repos.reject do |repo|
# Standard documentation.
license == 'apache-2.0' && ['standard', 'infrastructure', 'extension_registry', 'ocds-extensions-translations'].include?(repo.name) ||
# Forks, excluding manuals, can use upstream license.
repo.fork && !repo.name.end_with?('-manual') ||
# Archived and private repositories can have no license.
license.empty? && (repo.archived || repo.private)
end

if !printed_license && !repos.empty?
if license.empty?
puts 'missing'.bold
else
puts license.bold
end
printed_license = true
end

repos.each do |repo|
line = repo.html_url
if !language.empty?
line << " (#{language})"
end
Expand Down

0 comments on commit bc1b909

Please sign in to comment.