Skip to content

Commit

Permalink
Fetch released migrations via the GitHub API
Browse files Browse the repository at this point in the history
This reverts the released migrations to using the GitHub API as was done
in 9fba1a4.  The concern for the GitHub
rate limits in 9568c7a is no longer a
problem now that migrations are in their own repo which should have much
less churn, unlike the main manageiq repo where the migrations would run
on *every* PR.

Fixes #6
  • Loading branch information
Fryguy committed Jun 22, 2017
1 parent 5fd0fe6 commit bd5ce03
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions lib/tasks_private/spec.rake
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,15 @@ class SetupReleasedMigrations
private

def released_migrations
return [] unless system(fetch_command)
files = `git ls-tree -r --name-only #{TEST_BRANCH} db/migrate/`
return [] unless $?.success?
require 'net/http'
json = Net::HTTP.get(URI("https://api.github.com/repos/ManageIQ/manageiq/contents/db/migrate?ref=#{RELEASED_BRANCH}"))

migrations = files.split.map do |path|
filename = path.split("/")[-1]
migrations = JSON.parse(json).map do |h|
filename = h["path"].split("/")[-1]
filename.split('_')[0]
end
end.sort

# eliminate any non-timestamp entries
migrations.keep_if { |timestamp| timestamp =~ /\d+/ }
ensure
`git branch -D #{TEST_BRANCH}`
end

def fetch_command
"git fetch #{'--depth=1 ' if ENV['CI']}http://github.com/ManageIQ/manageiq.git refs/heads/#{RELEASED_BRANCH}:#{TEST_BRANCH}"
end
end

0 comments on commit bd5ce03

Please sign in to comment.