diff --git a/CHANGELOG.md b/CHANGELOG.md index 07bb446..a5c95d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1 @@ -See https://github.com/bigrails/bigrails-teams/releases +See https://github.com/rubyatscale/code_teams/releases diff --git a/Gemfile b/Gemfile index aa1ff83..97fb145 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' -# Specify your gem's dependencies in teams.gemspec +# Specify your gem's dependencies in code_teams.gemspec gemspec diff --git a/Gemfile.lock b/Gemfile.lock index c9ee10c..5270e65 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - bigrails-teams (0.1.1) + code_teams (1.0.0) sorbet-runtime GEM @@ -47,7 +47,7 @@ PLATFORMS x86_64-linux DEPENDENCIES - bigrails-teams! + code_teams! pry rake rspec (~> 3.0) diff --git a/README.md b/README.md index 2e82f51..d71f55e 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ -# Teams +# CodeTeams -This gem is a simple, low-dependency, plugin-based manager for engineering teams within a codebase. +This gem is a simple, low-dependency, plugin-based manager for teams within a codebase. ## Usage -To use teams, add YML files in `config/teams` that start with structure: +To use `code_teams`, add YML files in `config/teams` that start with structure: `config/teams/my_team.yml` ```yml name: My Team ``` -`teams` leverages a plugin system because every organization's team practices are different. Say your organization uses GitHub and wants to ensure every team YML files has a GitHub owner. To do this, you create a plugin: +`code_teams` leverages a plugin system because every organization's team practices are different. Say your organization uses GitHub and wants to ensure every team YML files has a GitHub owner. To do this, you create a plugin: ```ruby -class MyGithubPlugin < Teams::Plugin +class MyGithubPlugin < CodeTeams::Plugin extend T::Sig extend T::Helpers @@ -36,7 +36,7 @@ class MyGithubPlugin < Teams::Plugin members.include?(user) end - sig { override.params(teams: T::Array[Teams::Team]).returns(T::Array[String]) } + sig { override.params(teams: T::Array[CodeTeams::Team]).returns(T::Array[String]) } def self.validation_errors(teams) errors = T.let([], T::Array[String]) @@ -61,7 +61,7 @@ github: 1) You can now use the following API to get GitHub information about that team: ```ruby -team = Teams.find('My Team') +team = CodeTeams.find('My Team') MyGithubPlugin.for(team).github ``` 2) Running team validations (see below) will ensure all teams have a GitHub team specified @@ -76,8 +76,8 @@ Your plugins can be as simple or as complex as you want. Here are some other thi ## Configuration You'll want to ensure that all teams are valid in your CI environment. We recommend running code like this in CI: ```ruby -require 'teams' -errors = ::Teams.validation_errors(::Teams.all) +require 'code_teams' +errors = ::CodeTeams.validation_errors(::CodeTeams.all) if errors.any? abort <<~ERROR Team validation failed with the following errors: diff --git a/teams.gemspec b/code_teams.gemspec similarity index 74% rename from teams.gemspec rename to code_teams.gemspec index 1e02dbf..57a18a3 100644 --- a/teams.gemspec +++ b/code_teams.gemspec @@ -1,17 +1,17 @@ Gem::Specification.new do |spec| - spec.name = 'bigrails-teams' - spec.version = '0.1.1' + spec.name = 'code_teams' + spec.version = '1.0.0' spec.authors = ['Gusto Engineers'] spec.email = ['dev@gusto.com'] spec.summary = 'A low-dependency gem for declaring and querying engineering teams' spec.description = 'A low-dependency gem for declaring and querying engineering teams' - spec.homepage = 'https://github.com/bigrails/bigrails-teams' + spec.homepage = 'https://github.com/rubyatscale/code_teams' spec.license = 'MIT' if spec.respond_to?(:metadata) spec.metadata['homepage_uri'] = spec.homepage - spec.metadata['source_code_uri'] = 'https://github.com/bigrails/bigrails-teams' - spec.metadata['changelog_uri'] = 'https://github.com/bigrails/bigrails-teams/releases' + spec.metadata['source_code_uri'] = 'https://github.com/rubyatscale/code_teams' + spec.metadata['changelog_uri'] = 'https://github.com/rubyatscale/code_teams/releases' spec.metadata['allowed_push_host'] = 'https://rubygems.org' else raise 'RubyGems 2.0 or newer is required to protect against ' \ diff --git a/lib/bigrails-teams.rb b/lib/bigrails-teams.rb deleted file mode 100644 index 156723b..0000000 --- a/lib/bigrails-teams.rb +++ /dev/null @@ -1 +0,0 @@ -require 'teams' diff --git a/lib/teams.rb b/lib/code_teams.rb similarity index 89% rename from lib/teams.rb rename to lib/code_teams.rb index 4256d5e..55a3a76 100644 --- a/lib/teams.rb +++ b/lib/code_teams.rb @@ -6,10 +6,10 @@ require 'set' require 'pathname' require 'sorbet-runtime' -require 'teams/plugin' -require 'teams/plugins/identity' +require 'code_teams/plugin' +require 'code_teams/plugins/identity' -module Teams +module CodeTeams extend T::Sig class IncorrectPublicApiUsageError < StandardError; end @@ -24,7 +24,7 @@ def self.all sig { params(name: String).returns(T.nilable(Team)) } def self.find(name) - @index_by_name = T.let(@index_by_name, T.nilable(T::Hash[String, Teams::Team])) + @index_by_name = T.let(@index_by_name, T.nilable(T::Hash[String, CodeTeams::Team])) @index_by_name ||= begin result = {} all.each { |t| result[t.name] = t } @@ -57,7 +57,7 @@ def self.tag_value_for(string) # Generally, you should not ever need to do this, because once your ruby process loads, cached content should not change. # Namely, the YML files that are the source of truth for teams should not change, so we should not need to look at the YMLs again to verify. - # The primary reason this is helpful is for clients of Teams who want to test their code, and each test context has different set of teams + # The primary reason this is helpful is for clients of CodeTeams who want to test their code, and each test context has different set of teams sig { void } def self.bust_caches! @all = nil @@ -109,12 +109,12 @@ def name sig { returns(String) } def to_tag - Teams.tag_value_for(name) + CodeTeams.tag_value_for(name) end sig { params(other: Object).returns(T::Boolean) } def ==(other) - if other.is_a?(Teams::Team) + if other.is_a?(CodeTeams::Team) self.name == other.name else false diff --git a/lib/teams/plugin.rb b/lib/code_teams/plugin.rb similarity index 99% rename from lib/teams/plugin.rb rename to lib/code_teams/plugin.rb index 937fa62..81828bc 100644 --- a/lib/teams/plugin.rb +++ b/lib/code_teams/plugin.rb @@ -1,6 +1,6 @@ # typed: strict -module Teams +module CodeTeams # Plugins allow a client to add validation on custom keys in the team YML. # For now, only a single plugin is allowed to manage validation on a top-level key. # In the future we can think of allowing plugins to be gracefully merged with each other. diff --git a/lib/teams/plugins/identity.rb b/lib/code_teams/plugins/identity.rb similarity index 87% rename from lib/teams/plugins/identity.rb rename to lib/code_teams/plugins/identity.rb index 111b407..e0591a7 100644 --- a/lib/teams/plugins/identity.rb +++ b/lib/code_teams/plugins/identity.rb @@ -1,6 +1,6 @@ # typed: true -module Teams +module CodeTeams module Plugins class Identity < Plugin extend T::Sig @@ -15,7 +15,7 @@ def identity ) end - sig { override.params(teams: T::Array[Teams::Team]).returns(T::Array[String]) } + sig { override.params(teams: T::Array[CodeTeams::Team]).returns(T::Array[String]) } def self.validation_errors(teams) errors = T.let([], T::Array[String]) diff --git a/spec/lib/teams_spec.rb b/spec/lib/code_teams_spec.rb similarity index 71% rename from spec/lib/teams_spec.rb rename to spec/lib/code_teams_spec.rb index 58f8161..0c88ce1 100644 --- a/spec/lib/teams_spec.rb +++ b/spec/lib/code_teams_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe 'Teams' do +RSpec.describe CodeTeams do let(:team_yml) do <<~YML.strip name: My Team @@ -7,14 +7,14 @@ before do write_file('config/teams/my_team.yml', team_yml) - Teams.bust_caches! - allow(Teams::Plugin).to receive(:registry).and_return({}) + CodeTeams.bust_caches! + allow(CodeTeams::Plugin).to receive(:registry).and_return({}) end describe '.all' do it 'correctly parses the team files' do - expect(Teams.all.count).to eq 1 - team = Teams.all.first + expect(CodeTeams.all.count).to eq 1 + team = CodeTeams.all.first expect(team.name).to eq 'My Team' expect(team.raw_hash['name']).to eq 'My Team' expect(team.config_yml).to eq 'config/teams/my_team.yml' @@ -29,8 +29,8 @@ end it 'spits out a helpful error message' do - expect { Teams.all }.to raise_error do |e| - expect(e).to be_a Teams::IncorrectPublicApiUsageError + expect { CodeTeams.all }.to raise_error do |e| + expect(e).to be_a CodeTeams::IncorrectPublicApiUsageError expect(e.message).to eq('The YML in config/teams/my_team.yml has a syntax error!') end end @@ -38,7 +38,7 @@ end describe 'validation_errors' do - subject(:validation_errors) { Teams.validation_errors(Teams.all) } + subject(:validation_errors) { CodeTeams.validation_errors(CodeTeams.all) } context 'there is one definition for all teams' do it 'has no errors' do @@ -63,8 +63,8 @@ describe '==' do it 'handles nil correctly' do - expect(Teams.all.first == nil).to eq false # rubocop:disable Style/NilComparison - expect(nil == Teams.all.first).to eq false + expect(CodeTeams.all.first == nil).to eq false # rubocop:disable Style/NilComparison + expect(nil == CodeTeams.all.first).to eq false end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 80098fe..2f23b3e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,6 @@ require 'bundler/setup' require 'pry' -require 'teams' +require 'code_teams' RSpec.configure do |config| # Enable flags like --only-failures and --next-failure