This repository has been archived by the owner on Nov 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRakefile
97 lines (77 loc) · 2.79 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
require_relative "dependapanda"
require_relative "lib/gateways/repositories"
require_relative "lib/gateways/pull_request"
require "vcr"
require "net/http"
begin
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
task default: :spec
rescue LoadError
p "Could not load RSpec"
end
desc "Send short form dependency audit"
task :dependapanda do
Dependapanda.new.send_simple_message
end
desc "Send complete dependency audit"
task :dependapanda_loud do
Dependapanda.new.send_full_message
end
desc "Fetch alphagov repos tagged to govuk"
task :fetch_repos do
Gateways::Repositories.new.raw_govuk_repos
end
desc "Fetch approved dependabot PR's"
task :fetch_approved_pull_requests do
Gateways::PullRequest.new.approved_pull_requests
end
desc "Fetch changes requested dependabot PR's"
task :fetch_changes_requested_pull_requests do
Gateways::PullRequest.new.changes_requested_pull_requests
end
desc "Fetch review required dependabot PR's"
task :fetch_review_required_pull_requests do
Gateways::PullRequest.new.review_required_pull_requests
end
desc "Fetch all of the data we need from github in a slow way, and write to the cache"
task :warm_the_cache do
puts "Fetching repos..."
Rake::Task["fetch_repos"].invoke
puts "Finished fetching repos."
puts "Sleeping for 60 seconds to avoid rate-limiting"
sleep 60
puts "Fetching approved PRs..."
Rake::Task["fetch_approved_pull_requests"].invoke
puts "Finished fetching approved PRs."
puts "Sleeping for 60 seconds to avoid rate-limiting"
sleep 60
puts "Fetching changes requested PRs..."
Rake::Task["fetch_changes_requested_pull_requests"].invoke
puts "Finished fetching changes requested PRs."
puts "Sleeping for 60 seconds to avoid rate-limiting"
sleep 60
puts "Fetching review required PRs..."
Rake::Task["fetch_review_required_pull_requests"].invoke
puts "Finished fetching review required PRs."
rescue Octokit::Forbidden
puts "We've been rate limited. Wait 60 seconds and then hit refresh on the app, or run this task again"
end
desc "Flush all data from the memcache server on production. Consider manually refilling the cache with fetch tasks above."
task :flush_cache do
GovukDependencies.cache.clear
end
desc "Recreate the vcr cassettes. For example `rake record_cassette[org:alphagov topic:govuk]`"
task :record_cassette, [:search_string] do |_, args|
octokit = Octokit::Client.new(auto_paginate: true)
puts "Deleting old cassette"
File.delete("spec/fixtures/vcr_cassettes/repositories.yml") if File.exist?("spec/fixtures/vcr_cassettes/repositories.yml")
VCR.configure do |config|
config.cassette_library_dir = "spec/fixtures/vcr_cassettes"
config.hook_into :webmock
end
puts "Recording new cassette"
VCR.use_cassette("repositories") do
octokit.search_repos(args[:search_string])
end
end