Skip to content

Commit

Permalink
Add descriptions to all rake tasks
Browse files Browse the repository at this point in the history
Related #378
  • Loading branch information
andrew committed Mar 1, 2022
1 parent bcdbd64 commit 1d6e73d
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 13 deletions.
1 change: 1 addition & 0 deletions lib/tasks/backfill.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ require 'open-uri'
require 'zlib'

namespace :backfill do
desc 'import event data for all non-internal repos with internal dependencies from gharchive'
task all: :environment do

repo_names = Repository.not_internal.with_internal_deps.pluck(:full_name)
Expand Down
2 changes: 2 additions & 0 deletions lib/tasks/changelog.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace :changelog do
desc 'list internal repos with no changelog or history file'
task missing: :environment do
release_events = Event.internal.event_type('ReleaseEvent').includes(:repository)
repos = release_events.map(&:repository).uniq.reject(&:archived?)
Expand All @@ -15,6 +16,7 @@ namespace :changelog do
end
end

desc "generate a changelog file for a repository based on it's releases"
task generate: :environment do
full_name = 'ipfs-shipyard/ipld-explorer-components'
repo = Repository.find_by_full_name(full_name)
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/contributions.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'csv'

namespace :contributions do
desc "generate output a csv of avg first response time for each contributor"
task research: :environment do
counts = Issue.not_core.group(:user).count

Expand Down
4 changes: 3 additions & 1 deletion lib/tasks/contributors.rake
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
require 'csv'

namespace :contributors do

desc "sync least recently updated contributors from discovered repositories"
task sync: :environment do
Repository.discovered_contributors.order('last_events_sync_at ASC nulls first').where(bot: false).limit(200).each(&:sync)
end

desc "output a csv of top contributor data"
task research: :environment do
contributors = Issue.not_core.group(:user).count.sort_by{|u,c| -c}.select{|u,c| c > 10 }.reject{|u,c| u == 'ghost'}

Expand All @@ -14,7 +17,6 @@ namespace :contributors do
collabs[username] = Issue.where(user: username).first.collabs
end


csv_string = CSV.generate do |csv|
csv << [
'Name',
Expand Down
19 changes: 9 additions & 10 deletions lib/tasks/discovery.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace :discovery do
desc "search libraries.io for packages mentioning ipfs"
task packages: :environment do
# find all packages that mention ipfs
platforms = ['npm', 'maven', 'rubygems', 'pypi', 'cargo', 'packagist', 'nuget', 'clojars', 'cocoapods', 'hackage', 'hex', 'meteor', 'carthage', 'pub']

platforms.each do |platform|
Expand All @@ -23,6 +23,7 @@ namespace :discovery do
end
end

desc "find repositories for packages discovered in discovery:packages task"
task package_repos: :environment do
platforms = ['npm', 'maven', 'rubygems', 'pypi', 'cargo', 'packagist', 'nuget', 'clojars', 'cocoapods', 'hackage', 'hex', 'meteor', 'carthage', 'pub']

Expand All @@ -41,6 +42,7 @@ namespace :discovery do
end
end

desc "find dependent repositories for packages discovered in discovery:packages task"
task package_dependents: :environment do
platforms = ['npm', 'maven', 'rubygems', 'pypi', 'nuget']

Expand Down Expand Up @@ -81,19 +83,15 @@ namespace :discovery do
end
end

task local_repos: :environment do
# find collab repos that depend on ipfs packages

end

desc "find collab repos that depend on ipfs packages"
task local_search: :environment do
# find collab repos that depend on ipfs packages
search_repo_names = SearchResult.group(:repository_full_name).count.keys
File.open("data/search_results.json","w") do |f|
f.write(search_repo_names.to_json)
end
end

desc "list unique repo names from package_dependents, local_search and package_repos task outputs"
task all_repos: :environment do
search_results = JSON.load(File.open("data/search_results.json")).map{|name| "https://github.com/#{name}"}
package_repos = JSON.load(File.open("data/package_repos.json"))
Expand All @@ -106,6 +104,7 @@ namespace :discovery do
# puts names.length
end

desc 'list github orgs/users with most repos not already in the database'
task big_orgs: :environment do
# rows = []
orgs = {}
Expand All @@ -127,6 +126,7 @@ namespace :discovery do
# p rows.length
end

desc 'check repo repos listed in all_repos.csv still exist'
task check_status: :environment do
valid_rows = []
CSV.foreach("data/all_repos.csv") do |row,i|
Expand Down Expand Up @@ -154,7 +154,7 @@ namespace :discovery do
p valid_rows.uniq.length
end

task ranking: :environment do
# task ranking: :environment do
# Is it a fork? (fork)
# Is it archived? (archived)
# How many stars? (stargazers_count)
Expand All @@ -178,6 +178,5 @@ namespace :discovery do
# Does it use go-ipfs as a library?
# Does it use js-ipfs as a library?
# Does it use go-ipfs via docker?

end
# end
end
4 changes: 4 additions & 0 deletions lib/tasks/docker.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'csv'

namespace :docker do
desc 'search github for repositories that have Dockerfile files containing "ipfs"'
task search: :environment do
client = Issue.github_client
search = client.search_code("filename:Dockerfile ipfs")
Expand All @@ -26,6 +27,7 @@ namespace :docker do
end
end

desc 'load more data for repositories found in docker:search task'
task augment_docker: :environment do
client = Issue.github_client
repos = {}
Expand Down Expand Up @@ -69,6 +71,7 @@ namespace :docker do
end
end

desc 'search github for repositories that have docker-compose files containing "ipfs"'
task search_compose: :environment do
client = Issue.github_client

Expand All @@ -94,6 +97,7 @@ namespace :docker do
end
end

desc 'load more data for repositories found in docker:search_compose task'
task augment_compose: :environment do
client = Issue.github_client
repos = {}
Expand Down
3 changes: 3 additions & 0 deletions lib/tasks/graph.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace :graph do
desc "generate graphviz file to graph links between contributors and internal repos"
task generate: :environment do
issues = Issue.internal.not_core.humans.order('repo_full_name').map{|i| [i.user, i.repo_full_name] }.uniq

Expand Down Expand Up @@ -28,6 +29,7 @@ namespace :graph do
# rake graph:generate && dot -Tjpeg -Kneato test.gv > both.jpeg && open both.jpeg
end

desc "generate graphviz file to graph links between collaborators and internal repos"
task collabs: :environment do
issues = Issue.internal.not_core.humans.all_collabs.order('repo_full_name').map{|i| [i.collabs.first, i.repo_full_name] }.uniq

Expand Down Expand Up @@ -56,6 +58,7 @@ namespace :graph do
# rake graph:generate && dot -Tjpeg -Kneato test.gv > both.jpeg && open both.jpeg
end

desc "generate graphviz file to graph links internal repos and javascript dependencies"
task deps: :environment do

@scope = Repository.internal
Expand Down
3 changes: 3 additions & 0 deletions lib/tasks/issues.rake
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
namespace :issues do
desc 'sync recently active repos from each collaborator org'
task sync_collabs: :environment do
Organization.collaborator.each(&:sync_recently_active_repos)
end

desc 'sync issues from recently active repositories'
task sync_recent: :environment do
Repository.not_internal.triage.each(&:download_issues)
Repository.not_internal.triage.each(&:sync_events)
Expand All @@ -13,6 +15,7 @@ namespace :issues do
Organization.collaborator.each(&:update_counts)
end

desc 'sync internal issues that have not been synced in over 24 hours'
task sync_daily: :environment do
ids = Issue.internal.state('open').where('issues.last_synced_at < ? or issues.last_synced_at is null', 1.day.ago).limit(1000).order('issues.last_synced_at asc nulls first, issues.updated_at asc').pluck(:id)
Issue.where(id: ids).find_each(&:sync)
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/orgs.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace :orgs do
desc 'update count fields on collabortor organizations'
task update_counts: :environment do
Organization.collaborator.each(&:update_counts)
end
Expand Down
11 changes: 11 additions & 0 deletions lib/tasks/packages.rake
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
namespace :packages do
desc "sync internal packages"
task sync_internal: :environment do
Package.internal_or_partner.maintained.find_each(&:sync)
end

desc "find missing packages from npm, cargo, go and docker"
task find_missing_npm_packages: :environment do
Package.download_internal_dependent_packages

Expand All @@ -17,18 +19,22 @@ namespace :packages do
Organization.where('docker_hub_org is not null').each(&:sync_docker_packages)
end

desc 'sync 100 least recently updated packages'
task sync: :environment do
Package.order('last_synced_at ASC nulls first').limit(100).each(&:sync)
end

desc "download repositories for packages with no repository"
task find_missing_package_repos: :environment do
Package.find_missing_package_repos
end

desc "discover github repos that depend on internal packages"
task find_dependent_github_repos: :environment do
Package.find_dependent_github_repos
end

desc 'list repositories that directly depend upon internal packages'
task find_direct_dependent_repos: :environment do
internal_package_ids = Package.internal.pluck(:id)
direct_repo_ids = RepositoryDependency.where(package_id: internal_package_ids, direct: true).pluck(:repository_id).uniq
Expand All @@ -43,6 +49,7 @@ namespace :packages do
puts "#{direct_repo_ids.length} direct dependent repos total"
end

desc 'list repositories that indirectly depend upon internal packages'
task find_indirect_dependent_repos: :environment do
internal_package_ids = Package.internal.pluck(:id)

Expand All @@ -61,6 +68,7 @@ namespace :packages do
puts "#{only_indirect_repo_ids.length} indirect dependent repos total"
end

desc 'list packages that directly depend upon internal packages'
task find_direct_dependent_packages: :environment do
internal_package_ids = Package.internal.pluck(:id)
direct_version_ids = Dependency.where(package_id: internal_package_ids).pluck(:version_id).uniq
Expand All @@ -78,6 +86,7 @@ namespace :packages do
puts "#{direct_package_ids.length} direct dependent packages total"
end

desc 'list packages that indirectly depend upon internal packages'
task find_indirect_dependent_packages: :environment do
internal_package_ids = Package.internal.pluck(:id)

Expand All @@ -100,6 +109,7 @@ namespace :packages do
puts "#{all_indirect_dependent_ids.length} indirect dependent packages total"
end

desc 'list repositories that indirectly depend upon internal packages via recursive method'
task find_indirect_dependent_recursive_repos: :environment do
internal_package_ids = Package.internal.pluck(:id)

Expand All @@ -125,6 +135,7 @@ namespace :packages do
puts "#{indirect_repo_ids.length} indirect dependent repos total"
end

desc 'list the difference between find_indirect_dependent_recursive_repos and find_indirect_dependent_repos tasks'
task indirect_diff: :environment do
internal_package_ids = Package.internal.pluck(:id)

Expand Down
3 changes: 3 additions & 0 deletions lib/tasks/pmf.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace :pmf do
desc "list pmf states summary"
task states: :environment do
start_date = 6.week.ago
end_date = 2.week.ago
Expand All @@ -16,6 +17,7 @@ namespace :pmf do
end
end

desc "list pmf transitions summary"
task transitions: :environment do
start_date = 6.week.ago
end_date = 2.week.ago
Expand All @@ -33,6 +35,7 @@ namespace :pmf do
end
end

desc "calculate pmf windows for past year from yesterday"
task warm_caches: :environment do
# run this via cron just after midnight
# calculate pmf windows for past year from yesterday
Expand Down
4 changes: 4 additions & 0 deletions lib/tasks/repositories.rake
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
namespace :repositories do
desc "import new repositories discovered searching github "
task discover_from_search_results: :environment do
Repository.discover_from_search_results
end

desc "update ecosystem score for each repository"
task recalculate_scores: :environment do
Repository.recalculate_scores
end

desc "update 1200 least recently synced repositories"
task sync: :environment do
Repository.order('last_events_sync_at ASC nulls first').limit(1000).each(&:sync_if_updates)
Repository.order('last_sync_at ASC nulls first').limit(200).each(&:sync)
end

desc "import 200 new repositories from discovered contributor events to other repos"
task sync_discovered: :environment do
all_names = Repository.discovered_related_repo_names
existing_names = Repository.where(full_name: all_names).pluck(:full_name)
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/research.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace :research do
desc "download arweave org, repo and packages and output as csv"
task arweave: :environment do
# download all the repos
o = Organization.find_or_create_by(name: 'ArweaveTeam')
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/search.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace :search do
desc 'peform all search queries'
task run_all: :environment do
SearchQuery.run_all
end
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/stewards.rake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'csv'

namespace :stewards do
desc 'export all internal repositories as csv'
task export_repos: :environment do

exclude_fields = ['topics', 'direct_internal_dependency_package_ids', 'indirect_internal_dependency_package_ids']

scope = Repository.internal
Expand All @@ -16,8 +16,8 @@ namespace :stewards do
puts csv_string
end

desc 'export all internal events for the past 6 months as csv'
task export_events: :environment do

scope = Event.internal.this_period(180).humans
csv_string = CSV.generate do |csv|
csv << Event.attribute_names.excluding("payload")
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/upgrades.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'csv'

namespace :upgrades do
desc 'discover and export a csv of issues and pull requests on github related to updating ipfs'
task search: :environment do
search_to_csv(["update ipfs is:issue", "update ipfs is:pr", "upgrade ipfs is:issue", "upgrade ipfs is:pr", "bump ipfs", "ipfs 0.5", "go-ipfs", "ipfs docker"], 'ipfs')
end
Expand Down

0 comments on commit 1d6e73d

Please sign in to comment.