Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing a Thor CLI task for managing RubyGems Gem administration #123

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
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

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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Gemfile.lock
.yardoc
coverage
doc
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
40 changes: 40 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
inherit_gem:
bixby: bixby_default.yml

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

Layout/LineLength:
Exclude:
- 'lib/samvera/git_hub.rb'
- 'lib/samvera/org.rb'
- 'spec/system/cli_spec.rb'

Metrics/AbcSize:
Exclude:
- 'lib/samvera/gem_query_service.rb'
- 'lib/samvera/org.rb'

Metrics/BlockLength:
Exclude:
- 'Rakefile'
- 'lib/samvera/gem_query_service.rb'
- 'spec/system/cli_spec.rb'

Metrics/MethodLength:
Exclude:
- 'lib/samvera/gem_query_service.rb'
- 'lib/samvera/org.rb'

Style/Documentation:
Exclude:
- 'lib/samvera.rb'
- 'lib/samvera/gem_query_service.rb'
- 'lib/samvera/git_hub.rb'
- 'lib/samvera/org.rb'
- 'lib/samvera/repository_query_service.rb'
- 'lib/samvera/ruby_gems.rb'

63 changes: 63 additions & 0 deletions CLI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Component Maintenance Interest Group
## Command-Line Interface (CLI) Utility

### Getting Started

1. Get a personal access token from GitHub (https://github.com/settings/tokens) with the following scopes enabled:
* `public_repo`
* `read:org`
* `user:email`
1. Set an ENV variable named `GITHUB_SAMVERA_TOKEN` containing your token

The CLI commands may then be listed using the following:

```bash
$ bundle exec thor list
```

...yielding:

```bash
samvera
-------
thor samvera:org:add_owners # Ensure that all members of the administrator GitHub Team are Gem Owners for RubyGems entries
thor samvera:org:admins # list members of the GitHub administrative Team
thor samvera:org:contributors # list members of the GitHub administrative Team
thor samvera:org:remove_owners # Ensure that all Gem Owners for RubyGems entries which are *not* members of the administrator ...
thor samvera:org:repositories # list Samvera repositories
```

### Queries

One may retrieve the current GitHub administrators using the following:

```bash
$ bundle exec thor samvera:org:admins
```

One may retrieve the current GitHub contributors using the following:

```bash
$ bundle exec thor samvera:org:contributors
```

One may also retrieve the current GitHub repositories managing Ruby Gem projects using the following:

```bash
$ bundle exec thor samvera:org:repositories
```

### Gem Management

As an administrator, one may grant ownership privileges for RubyGems entries to all GitHub contributors using the following:

```bash
$ bundle exec thor samvera:org:add_owners
```

As an administrator, one may revoke ownership privileges for RubyGems entries to owners who are neither GitHub contributors nor GitHub administrators using the following:

```bash
$ bundle exec thor samvera:org:remove_owners
```

16 changes: 15 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'github_api'
gem 'huborg'
gem 'rake'
gem 'rake'
gem 'thor'

group :development do
gem 'bixby'
gem 'pry-byebug'
gem 'rspec'
gem 'rspec_junit_formatter'
gem 'simplecov'
gem 'webmock'
gem 'yard'
end
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ This template is something to push to all samvera repositories. The goal in
applying a common mailmap is to help understand contributions as people move
and change roles/functions/laptops.

## Command-Line Interface (CLI) Utility

There exists a command-line interface utility which may be used to query for GitHub Team data and in order to perform RubyGems administrative tasks. [Please reference the CLI documentation for an overview of the usage for this](./CLI.md).

## Ruby Scripts

There exist Ruby scripts in this repository that can be used to propagate some of these templates:
Expand Down
20 changes: 11 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
# frozen_string_literal: true

namespace :templates do
desc "Push CODE_OF_CONDUCT.md to all repositories, this requires ENV['GITHUB_ACCESS_TOKEN']"
task :code_of_conduct do
require 'huborg'
client = Huborg::Client.new(org_names: ["samvera", "samvera-labs"])
client = Huborg::Client.new(org_names: %w[samvera samvera-labs])
client.push_template!(
template: File.expand_path("./templates/CODE_OF_CONDUCT.md"),
filename: "CODE_OF_CONDUCT.md",
template: File.expand_path('./templates/CODE_OF_CONDUCT.md'),
filename: 'CODE_OF_CONDUCT.md',
overwrite: true
)
end
desc "Push CONTRIBUTING.md to all repositories, this requires ENV['GITHUB_ACCESS_TOKEN']"
task :contributing do
require 'huborg'
client = Huborg::Client.new(org_names: ["samvera", "samvera-labs"])
client = Huborg::Client.new(org_names: %w[samvera samvera-labs])
client.push_template!(
template: File.expand_path("./templates/CONTRIBUTING.md"),
filename: "CONTRIBUTING.md",
template: File.expand_path('./templates/CONTRIBUTING.md'),
filename: 'CONTRIBUTING.md',
overwrite: true
)
end
desc "Push SUPPORT.md to all repositories, this requires ENV['GITHUB_ACCESS_TOKEN']"
task :support do
require 'huborg'
client = Huborg::Client.new(org_names: ["samvera", "samvera-labs"])
client = Huborg::Client.new(org_names: %w[samvera samvera-labs])
client.push_template!(
template: File.expand_path("./templates/SUPPORT.md"),
filename: "SUPPORT.md",
template: File.expand_path('./templates/SUPPORT.md'),
filename: 'SUPPORT.md',
overwrite: true
)
end
Expand Down
5 changes: 5 additions & 0 deletions cli.thor
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

require_relative 'lib/samvera'

Samvera::Org.new
89 changes: 89 additions & 0 deletions config/github.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
rubygems:
gems:
# [GitHub Repository]: [RubyGems Gem]
active_fedora: active-fedora
fcrepo-admin: fcrepo_admin
questioning_authority: qa
repositories:
invalid:
# samvera
- cla-bot
- cla-bot-old
- hyku
- maintenance
- samvera-circleci-orb
- samvera.github.io
# samvera-labs
- ActiveTriples
- starter-react-component-npm
- stencil-test-components
- sufia.io
- samvera-connect
- samvera-labs.github.io
- samvera-persona
- samvera-virtual-connect
- samvera.org
- samvera_docs
- serverless-iiif
- sessionizer
- uri_selection_wg
- ValkyrieAPI
- repository_utils
- power-steering
- openseadragon-react-viewer
- nurax-pg
- node-iiif
- nectar-iiif
- browse-everything-components
- browse-everything-redux-react
- iiif-image-api
- iiif-react-media-player
- hyku-api
- hyku.github.io
- docker-fcrepo
- fcrepo-charts
- fcrepo3
- fcrepo3-ldp
- core-dependency-report
- digital_collections_elixir_example
- branch-renaming-wg
- bloom-iiif
- AdvancingHyku
- ansible-sufia7-playbook
- clover-iiif
- houndstooth
- image-downloader
- allinson_flex
- analytics_nurax
- avalon-bundle
- book_concerns
- doi_registrar
- hybox-ideas
- hydra-admin-collections
- hydra-shibboleth
- hydra_controlled_vocabularies
- hydra_documentation_wg
- hydra_file_sets_wg
- hydra_plugins_wg
- hyrax-batch_ingest..
- hyrax-google_analytics
- hyrax-hirmeos
- hyrax-json_fields
- hyrax-orcid
- hyrax-speed_test
- karmabot
- open_annotation_models
- rdf-proxy_list
- ruby-oai
- samvera-external_storage
- samvera-shibboleth
- sipity
- speedy_af
- storage_proxy_api
- valkyrie-cloud_search
- valkyrie-derivatives
- valkyrie-dynamodb
- valkyrie-redis
- valkyrie_pg_demo
- hyrax-batch_ingest
16 changes: 16 additions & 0 deletions config/rubygems.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
github:
owners:
# [GitHub Account]: [RubyGems Account]
aaron-collier: acollier
billdueber: BillDueber
carolyncole: cam156
hackartisan: HackmasterA
jrgriffiniii: jrgriffiniii
julesies: geekycoder
no-reply: no_reply
owners:
invalid:
- kelynch
- mlooney
- orangewolf
21 changes: 21 additions & 0 deletions lib/samvera.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module Samvera
def self.relative_file_path
File.dirname(__FILE__)
end

def self.absolute_file_path
File.absolute_path(relative_file_path)
end

def self.root_path
Pathname.new(absolute_file_path)
end

autoload(:GemQueryService, root_path.join('samvera', 'gem_query_service'))
autoload(:RubyGems, root_path.join('samvera', 'ruby_gems'))
autoload(:RepositoryQueryService, root_path.join('samvera', 'repository_query_service'))
autoload(:GitHub, root_path.join('samvera', 'git_hub'))
autoload(:Org, root_path.join('samvera', 'org'))
end
Loading