Skip to content

Commit

Permalink
Enabling CircleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgriffiniii committed May 25, 2022
1 parent 47c73bf commit 8801f61
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 11 deletions.
79 changes: 79 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
version: 2.1
orbs:
samvera: samvera/circleci-orb@1.0
jobs:
bundle_lint_test:
parameters:
ruby_version:
type: string
bundler_version:
type: string
default: 2.3.14
executor:
name: 'samvera/ruby'
ruby_version: << parameters.ruby_version >>
environment:
NOKOGIRI_USE_SYSTEM_LIBRARIES: true
steps:
- samvera/cached_checkout
- run:
name: Check for a branch named 'master'
command: |
git fetch --all --quiet --prune --prune-tags
if [[ -n "$(git branch --all --list master */master)" ]]; then
echo "A branch named 'master' was found. Please remove it."
echo "$(git branch --all --list master */master)"
fi
[[ -z "$(git branch --all --list master */master)" ]]
- samvera/bundle:
ruby_version: << parameters.ruby_version >>
bundler_version: << parameters.bundler_version >>
- samvera/rubocop
- run:
name: 'Lint the source code files using RuboCop'
command: 'bundle exec rubocop --config=./.rubocop.yml --parallel'
#- samvera/parallel_rspec
- run:
name: 'Executing the test suites using RSpec'
command: |
mkdir /tmp/test-results
bundle exec rspec spec/
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results

workflows:
version: 2
ci:
jobs:
- bundle_lint_test:
name: bundle_ruby3-1
ruby_version: 3.1.2
- bundle_lint_test:
name: bundle_ruby3-0
ruby_version: 3.0.4
- bundle_lint_test:
name: bundle_ruby2-7
ruby_version: 2.7.6

nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- main
jobs:
- bundle_lint_test:
name: bundle_ruby3-1
ruby_version: 3.1.2
- bundle_lint_test:
name: bundle_ruby3-0
ruby_version: 3.0.4
- bundle_lint_test:
name: bundle_ruby2-7
ruby_version: 2.7.6
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
inherit_gem:
bixby: bixby_default.yml

AllCops:
Exclude:
- 'Rakefile'
- 'script/**/*'
- 'vendor/**/*'

Layout/LineLength:
Exclude:
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ group :development do
gem 'bixby'
gem 'pry-byebug'
gem 'rspec'
gem 'rspec_junit_formatter'
gem 'simplecov'
gem 'webmock'
gem 'yard'
Expand Down
1 change: 1 addition & 0 deletions lib/samvera/gem_query_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ def remove(owners:)
add_command = RemoveOwnersCommand.new
add_command.options[:args] = [@gem_name]
owner_logins = owners.map(&:login)
add_command.options[:add] = []
add_command.options[:remove] = owner_logins

add_command.execute
Expand Down
6 changes: 3 additions & 3 deletions lib/samvera/git_hub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Samvera
class GitHub
class << self
def authorization_token
@authorization_token = ENV['GITHUB_SAMVERA_TOKEN'] || raise(
@authorization_token = ENV.fetch('GITHUB_SAMVERA_TOKEN', nil) || raise(
ArgumentError,
'GitHub authorization token was not found in the GITHUB_SAMVERA_TOKEN environment variable'
)
Expand Down Expand Up @@ -49,7 +49,7 @@ def samvera_team
end

def admin_team
@admin_team = samvera_team.select { |team| team.name == 'admins' }.first
@admin_team = samvera_team.find { |team| team.name == 'admins' }
end

def admin_response
Expand All @@ -70,7 +70,7 @@ def samvera_admins
end

def contrib_team
@contrib_team = samvera_team.select { |team| team.name == 'contributors' }.first
@contrib_team = samvera_team.find { |team| team.name == 'contributors' }
end

def contrib_response
Expand Down
12 changes: 6 additions & 6 deletions lib/samvera/org.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ def repositories
desc('add_owners', 'Ensure that all members of the administrator GitHub Team are Gem Owners for RubyGems entries')
def add_owners
GitHub.repositories.each do |repo|
if !RubyGems.gem_exists?(name: repo.name)
say("Could not find the Gem for #{repo.name}...", :red)
else
if RubyGems.gem_exists?(name: repo.name)
current_owners = RubyGems.show_gem_owners(name: repo.name)
owners = GitHub.samvera_admins.reject { |o| current_owners.map(&:login).include?(o.login) }

Expand All @@ -40,6 +38,8 @@ def add_owners
rescue StandardError => e
raise(Thor::Error, e.message)
end
else
say("Could not find the Gem for #{repo.name}...", :red)
end
end
end
Expand All @@ -48,9 +48,7 @@ def add_owners
'Ensure that all Gem Owners for RubyGems entries which are *not* members of the administrator GitHub Team are removed')
def remove_owners
GitHub.repositories.each do |repo|
if !RubyGems.gem_exists?(name: repo.name)
say("Could not find the Gem for #{repo.name}...", :red)
else
if RubyGems.gem_exists?(name: repo.name)
current_owners = RubyGems.show_gem_owners(name: repo.name)
owners = GitHub.samvera_admins.reject { |o| current_owners.map(&:login).include?(o.login) }

Expand All @@ -60,6 +58,8 @@ def remove_owners
rescue StandardError => e
raise(Thor::Error, e.message)
end
else
say("Could not find the Gem for #{repo.name}...", :red)
end
end
end
Expand Down
8 changes: 6 additions & 2 deletions spec/system/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,12 @@
].to_yaml
end

before do
before(:all) do
ENV["GEM_HOST_API_KEY"] = 'secret'
ENV['GITHUB_SAMVERA_TOKEN'] = 'secret'
end

before do
allow(::Github).to receive(:new).and_return(github_client)
allow(github_client).to receive(:orgs).and_return(github_orgs)
allow(github_client).to receive(:repos).with(user: 'samvera').and_return(github_samvera_repos)
Expand Down Expand Up @@ -205,7 +208,8 @@
cli
end

after do
after(:all) do
ENV["GEM_HOST_API_KEY"] = nil
ENV['GITHUB_SAMVERA_TOKEN'] = nil
end

Expand Down

0 comments on commit 8801f61

Please sign in to comment.