Skip to content

Commit

Permalink
Add gapic-common gem (#180)
Browse files Browse the repository at this point in the history
Replaces google-gax 2.0 in order to avoid dependency conflicts.
  • Loading branch information
blowmage authored Jun 28, 2019
1 parent 21d6d71 commit 33cc606
Show file tree
Hide file tree
Showing 139 changed files with 8,918 additions and 2,055 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
command: dockerize -wait tcp://localhost:7469 -timeout 1m
- run:
name: run tests
command: bundle exec rake ci
command: bundle exec rake update ci

workflows:
version: 2
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ $ protoc googleapis/google/cloud/vision/v1/*.proto \
--ruby_gapic_opt=configuration=vision.yml --ruby_gapic_out=dest
```

Note that generated clients depend on the `google-gax` 2.0 gem, which is not
yet released. To test a client, you may need to modify it to pull `google-gax`
Note that generated clients depend on the `gapic-common` 2.0 gem, which is not
yet released. To test a client, you may need to modify it to pull `gapic-common`
from the github master branch.

### Create a custom generator
Expand Down
18 changes: 18 additions & 0 deletions gapic-common/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.DS_STORE
.bundle/
/.yardoc
/Gemfile.lock
/_yardoc/
/doc/
/pkg/
/spec/reports/
/tmp/
*.bundle
*.so
*.o
*.a
mkmf.log
vendor
*~
.idea
*.iml
43 changes: 43 additions & 0 deletions gapic-common/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
inherit_gem:
google-style: google-style.yml

AllCops:
Exclude:
- "gapic-common.gemspec"
- "test/**/*"

Metrics/ClassLength:
Exclude:
- "lib/google/gapic/configuration.rb"
- "lib/google/gapic/configuration/schema.rb"

Metrics/AbcSize:
Exclude:
- "lib/google/gapic/config.rb"
Metrics/CyclomaticComplexity:
Exclude:
- "lib/google/gapic/config.rb"
Metrics/MethodLength:
Exclude:
- "lib/google/gapic/config.rb"
Metrics/PerceivedComplexity:
Exclude:
- "lib/google/gapic/config.rb"
- "lib/google/gapic/grpc/stub.rb"

Style/Documentation:
Exclude:
- "lib/google/gapic/api_call.rb"
- "lib/google/gapic/configuration/deferred_value.rb"
- "lib/google/gapic/configuration/schema.rb"
- "lib/google/gapic/errors.rb"
- "lib/google/gapic/grpc/status_details.rb"
Style/GuardClause:
Exclude:
- "lib/google/gapic/grpc/stub.rb"
Style/CaseEquality:
Exclude:
- "lib/google/gapic/configuration.rb"
- "lib/google/gapic/configuration/derived.rb"
- "lib/google/gapic/configuration/schema.rb"
- "lib/google/gapic/config.rb"
6 changes: 6 additions & 0 deletions gapic-common/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: ruby
rvm:
- 2.6
- 2.5
- 2.4
- 2.3
3 changes: 3 additions & 0 deletions gapic-common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Release History

### 2.0.0 / Upcoming...
43 changes: 43 additions & 0 deletions gapic-common/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Contributor Code of Conduct

As contributors and maintainers of this project,
and in the interest of fostering an open and welcoming community,
we pledge to respect all people who contribute through reporting issues,
posting feature requests, updating documentation,
submitting pull requests or patches, and other activities.

We are committed to making participation in this project
a harassment-free experience for everyone,
regardless of level of experience, gender, gender identity and expression,
sexual orientation, disability, personal appearance,
body size, race, ethnicity, age, religion, or nationality.

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information,
such as physical or electronic
addresses, without explicit permission
* Other unethical or unprofessional conduct.

Project maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct.
By adopting this Code of Conduct,
project maintainers commit themselves to fairly and consistently
applying these principles to every aspect of managing this project.
Project maintainers who do not follow or enforce the Code of Conduct
may be permanently removed from the project team.

This code of conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community.

Instances of abusive, harassing, or otherwise unacceptable behavior
may be reported by opening an issue
or contacting one or more of the project maintainers.

This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
28 changes: 28 additions & 0 deletions gapic-common/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# How to Contribute

We'd love to accept your patches and contributions to this project. There are
just a few small guidelines you need to follow.

## Contributor License Agreement

Contributions to this project must be accompanied by a Contributor License
Agreement. You (or your employer) retain the copyright to your contribution;
this simply gives us permission to use and redistribute your contributions as
part of the project. Head over to <https://cla.developers.google.com/> to see
your current agreements on file or to sign a new one.

You generally only need to submit a CLA once, so if you've already submitted one
(even if it was for a different project), you probably don't need to do it
again.

## Code reviews

All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
information on using pull requests.

## Community Guidelines

This project follows [Google's Open Source Community
Guidelines](https://opensource.google.com/conduct/).
4 changes: 4 additions & 0 deletions gapic-common/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "https://rubygems.org"

# Specify your gem's dependencies in gapic-common.gemspec
gemspec
13 changes: 13 additions & 0 deletions gapic-common/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2019 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
40 changes: 40 additions & 0 deletions gapic-common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Google API Extensions for Ruby
================================

Generated API Client common code (gapic-common) is a set of modules which aids
the development of APIs for clients and servers based on [gRPC][] and Google API
conventions.

Application code will rarely need to use most of the classes within this library
directly, but code generated automatically from the API definition files in
[Google APIs][] can use services such as page streaming to provide a more
convenient and idiomatic API surface to callers.

[gRPC]: http://grpc.io
[Google APIs]: https://github.com/googleapis/googleapis/

## Supported Ruby Versions

This library is supported on Ruby 2.3+.

Google provides official support for Ruby versions that are actively supported
by Ruby Core—that is, Ruby versions that are either in normal maintenance or in
security maintenance, and not end of life. Currently, this means Ruby 2.3 and
later. Older versions of Ruby _may_ still work, but are unsupported and not
recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
about the Ruby support schedule.

## Contributing

Contributions to this library are always welcome and highly encouraged.

See the [CONTRIBUTING](CONTRIBUTING.md) documentation for more information on how to get started.

## Versioning

This library is currently a **preview** with no guarantees of stability or support. Please get
involved and let us know if you find it useful and we'll work towards a stable version.

## Disclaimer

This is not an official Google product.
76 changes: 76 additions & 0 deletions gapic-common/RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Releasing gapic-common

The Google Ruby GAX project uses [semantic versioning](http://semver.org). Replace the `<prev_version>` and `<version>` placeholders shown in the examples below with the appropriate numbers, e.g. `0.1.0` and `0.2.0`.

After all [pull requests](https://github.com/googleapis/gax-ruby/pulls) for a release have been merged and all [Travis builds](https://travis-ci.org/googleapis/gax-ruby) are green, you may create a release as follows:

1. If you haven't already, switch to the master branch, ensure that you have no changes, and pull from origin.

```sh
$ git checkout master
$ git status
$ git pull <remote> master --rebase
```

1. Build the gem locally. (Depending on your environment, you may need to `bundle exec` to rake commands; this will be shown.)

```sh
$ bundle exec rake build
```

1. Install the gem locally.

```sh
$ bundle exec rake install
```

1. Using IRB (not `rake console`!), manually test the gem that you installed in the previous step.

1. Update the `CHANGELOG.md`. Write bullet-point lists of the major and minor changes. You can also add examples, fixes, thank yous, and anything else helpful or relevant. See google-cloud-node [v0.18.0](https://github.com/GoogleCloudPlatform/google-cloud-node/releases/tag/v0.18.0) for an example with all the bells and whistles.

1. Edit `lib/google/gapic/version.rb` file, changing the value of `VERSION` to your new version number. This repo requires a PR for all changes so doing this in a branch is best.

1. Run the tests, one last time.

```sh
$ bundle update
$ bundle exec rake spec
```

1. Commit your changes. Copy and paste the significant points from your `CHANGELOG.md` edit as the description in your commit message.

```sh
$ git commit -am "Release gapic-common <version> ..."
```

1. Tag the version after all changes have been merged.

```sh
$ git tag gapic-common/v<version>
```

1. Push the tag.

```sh
$ git push <remote> gapic-common/v<version>
```

1. Wait until the [Travis build](https://travis-ci.org/googleapis/gax-ruby) has passed for the tag.

1. Push the gem to [RubyGems.org](https://rubygems.org/gems/google-cloud).

```sh
$ gem push gapic-common-<version>.gem
```

1. On the [gax-ruby releases page](https://github.com/googleapis/gax-ruby/releases), click [Draft a new release](https://github.com/googleapis/gax-ruby/releases/new). Complete the form. Include the bullet-point lists of the major and minor changes from the gem's `CHANGELOG.md`. You can also add examples, fixes, thank yous, and anything else helpful or relevant.
1. Click `Publish release`.
1. Wait until the last tag build job has successfully completed on Travis. Then push your commits to the master branch. This will trigger another [Travis](https://travis-ci.org/googleapis/gax-ruby) build on master branch.
```sh
$ git push <remote> master
```
High fives all around!
38 changes: 38 additions & 0 deletions gapic-common/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require "bundler/gem_tasks"
require "rake/testtask"
require "rubocop/rake_task"

RuboCop::RakeTask.new # Configuration is in .rubocop.yml
Rake::TestTask.new :test do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
end

desc "Run the CI build"
task :ci do
puts "\ngapic-common rubocop\n"
Rake::Task[:rubocop].invoke
puts "\ngapic-common test\n"
Rake::Task[:test].invoke
end

task default: :ci

task :gen do
# no-op
end
37 changes: 37 additions & 0 deletions gapic-common/gapic-common.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- ruby -*-
# encoding: utf-8

$LOAD_PATH.push File.expand_path("lib", __dir__)
require "google/gapic/common/version"

Gem::Specification.new do |gem|
gem.name = "gapic-common"
gem.version = Google::Gapic::Common::VERSION
gem.authors = ["Google API Authors"]
gem.email = "[email protected]"
gem.homepage = "https://github.com/googleapis/gapic-generator-ruby"
gem.summary = "Aids the development of APIs for clients and servers based"
gem.summary += " on GRPC and Google APIs conventions"
gem.description = "Generated API Client common code"
gem.files = %w[Rakefile README.md]
gem.files += Dir.glob "lib/**/*"
gem.files += Dir.glob "spec/**/*"
gem.require_paths = %w[lib]
gem.platform = Gem::Platform::RUBY
gem.license = "Apache-2.0"

gem.required_ruby_version = ">= 2.3.0"

gem.add_dependency "google-protobuf", "~> 3.2"
gem.add_dependency "googleapis-common-protos", ">= 1.3.9", "< 2.0"
gem.add_dependency "googleapis-common-protos-types", ">= 1.0.4", "< 2.0"
gem.add_dependency "googleauth", ">= 0.6.2", "< 0.10.0"
gem.add_dependency "grpc", ">= 1.7.2", "< 2.0"

gem.add_development_dependency "google-style", "~> 0.3"
gem.add_development_dependency "minitest", "~> 5.10"
gem.add_development_dependency "minitest-autotest", "~> 1.0"
gem.add_development_dependency "minitest-focus", "~> 1.1"
gem.add_development_dependency "minitest-rg", "~> 5.2"
gem.add_development_dependency "rake", ">= 10.0"
end
Loading

0 comments on commit 33cc606

Please sign in to comment.