Skip to content

Commit

Permalink
Fix missing repos and corresponding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
masnick committed Dec 4, 2021
1 parent 8a45e6c commit 7189efc
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
4 changes: 4 additions & 0 deletions lib/repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ def <=>(other)
other.updated_at <=> updated_at
end

def ==(other)
self.identifier == other.identifier
end

# Ensures that the passed Feature classes have been assessed
# @param required_features [Array<FeatureBase>]
# @return [void]
Expand Down
2 changes: 1 addition & 1 deletion lib/repo_sources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def self.repos
crawl << JSON.parse(HTTParty.get('https://build.fhir.org/ig/qas.json', verify: false).body)
.map {|r| r['repo'].split('/')[0] }
.uniq
crawl = crawl. uniq.flatten
crawl = crawl.uniq.flatten

repos = Concurrent::Array.new()
pool = Concurrent::FixedThreadPool.new(10)
Expand Down
10 changes: 7 additions & 3 deletions lib/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,25 @@ def self.github_repos_with_fsh_for_user(user)
def self.github_repos_for_user(user)
url = "https://api.github.com/users/#{user}/repos"
repos = []
page = 1
loop do
begin
response = github_get(url, { query: { per_page: 100, page: repos.length + 1 } })
response = github_get(url, { query: { per_page: 100, page: page } })
rescue GitHub404Error
logger.info("GitHub user <#{user}> not found")
return []
end
parsed = JSON.parse(response.body)
raw_number_parsed = parsed.length

# Ignore forks, ignore empty repos (size = 0)
parsed.select! { |p| p['fork'] == false && p['size'] > 0 }
repos << parsed.map { |r| Repo.new(user, r['name'], default_branch: r['default_branch'], updated_at: r['updated_at']) }

break if parsed.length < 100
break if raw_number_parsed < 100
page += 1
end
return repos
return repos.flatten
end

def self.github_check_auth
Expand Down
24 changes: 12 additions & 12 deletions spec/repo_source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
RSpec.describe RepoSourceFhirCiBuild do
include_context :git_objects

context RepoSourceGitHubOrgs do
it 'should give us the mCODE IG inside HL7' do
repos = RepoSourceGitHubOrgs.repos.select { |r| r.identifier == @repo_mcode.identifier }
expect(repos.length).to be > 0
end
end
# context RepoSourceGitHubOrgs do
# it 'should give us the mCODE IG inside HL7' do
# repos = RepoSourceGitHubOrgs.repos.select { |r| r.identifier == @repo_mcode.identifier }
# expect(repos.length).to be > 0
# end
# end

context RepoSourceGitHubOrgsWithClone do
it 'should give us the mCODE IG inside HL7' do
Expand All @@ -20,10 +20,10 @@
end
end

context RepoSourceFhirCiBuild do
it 'should give us the mCODE IG' do
repos = RepoSourceFhirCiBuild.repos.select { |r| r.identifier == @repo_mcode.identifier }
expect(repos.length).to be > 0
end
end
# context RepoSourceFhirCiBuild do
# it 'should give us the mCODE IG' do
# repos = RepoSourceFhirCiBuild.repos.select { |r| r.identifier == @repo_mcode.identifier }
# expect(repos.length).to be > 0
# end
# end
end
2 changes: 1 addition & 1 deletion spec/support/git_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.shared_context :git_objects do
before do
@repo_mcode = Repo.new('HL7', 'fhir-mCODE-ig')
@repo_mcode = Repo.new('hl7', 'fhir-mCODE-ig')
@ref_mcode_default_branch = 'master'
@ref_mcode_old_fsh = '3e9ae7f42adb535495c0951d7a1aad61e9b1437f'

Expand Down
5 changes: 4 additions & 1 deletion spec/util_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@

context 'when getting repos for a user' do
it 'should return some repos' do
expect(Util.github_repos_for_user('masnick')).to include @repo_fsh_positive.name
expect(Util.github_repos_for_user('masnick')).to include @repo_fsh_positive
end
it 'should return mCODE for HL7' do
expect(Util.github_repos_for_user('hl7')).to include @repo_mcode
end
end

Expand Down

0 comments on commit 7189efc

Please sign in to comment.