Skip to content

Commit

Permalink
chore: GA release for go-sql-spanner driver (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul2393 authored Sep 15, 2022
1 parent 2c97068 commit a9ea878
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 34 deletions.
11 changes: 11 additions & 0 deletions .github/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
handleGHRelease: true
manifest: true
releaseType: go-yoshi

branches:
- branch: main
releaseType: go-yoshi
handleGHRelease: true
manifest: true
manifestFile: .release-please-manifest.json
manifestConfig: release-please-config.json
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "1.0.0"
}
147 changes: 127 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,136 @@
# How to Contribute
# Contributing

We'd love to accept your patches and contributions to this project. There are
just a few small guidelines you need to follow.
1. [File an issue](https://github.com/googleapis/go-sql-spanner/issues/new/choose).
The issue will be used to discuss the bug or feature and should be created
before sending a PR.

## Contributor License Agreement
1. [Install Go](https://golang.org/dl/).
1. Ensure that your `GOBIN` directory (by default `$(go env GOPATH)/bin`)
is in your `PATH`.
1. Check it's working by running `go version`.
* If it doesn't work, check the install location, usually
`/usr/local/go`, is on your `PATH`.

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.
1. Sign one of the
[contributor license agreements](#contributor-license-agreements) below.

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.
1. Clone the repo:
`git clone https://github.com/googleapis/go-sql-spanner`

## Code Reviews
1. Change into the checked out source:
`cd go-sql-spanner`

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.
1. Fork the repo.

## Community Guidelines
1. Set your fork as a remote:
`git remote add fork [email protected]:GITHUB_USERNAME/go-sql-spanner.git`

This project follows [Google's Open Source Community
Guidelines](https://opensource.google/conduct/).
1. Make changes, commit to your fork.

Commit messages should follow the
[Conventional Commits Style](https://www.conventionalcommits.org). The scope
portion should always be filled with the name of the package affected by the
changes being made. For example:
```
feat(functions): add gophers codelab
```

1. Send a pull request with your changes.

To minimize friction, consider setting `Allow edits from maintainers` on the
PR, which will enable project committers and automation to update your PR.

1. A maintainer will review the pull request and make comments.

Prefer adding additional commits over amending and force-pushing since it can
be difficult to follow code reviews when the commit history changes.

Commits will be squashed when they're merged.

## Testing

We test code against two versions of Go, the minimum and maximum versions
supported by our clients. To see which versions these are checkout our
[README](README.md#supported-versions).

### Integration Tests

In addition to the unit tests, you may run the integration test suite.

#### GCP Setup

To run the integrations tests, creation and configuration of a project in
the Google Developers Console is required.

After creating the project, you must [create a service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount)
for project. Ensure the project-level **Owner**
[IAM role](https://console.cloud.google.com/iam-admin/iam/project) role is added to
each service account. During the creation of the service account, you should
download the JSON credential file for use later.

#### Local Setup

Once the project is created and configured, set the following environment
variables:

- `SPANNER_TEST_PROJECT`: Developers Console project's ID (e.g.
bamboo-shift-455).

Install the [gcloud command-line tool][gcloudcli] to your machine and use it to
create some resources used in integration tests.

From the project's root directory:

``` sh
# Sets the default project in your env.
$ gcloud config set project $SPANNER_TEST_PROJECT

# Authenticates the gcloud tool with your account.
$ gcloud auth login

# Creates a Spanner instance for the spanner integration tests.
$ gcloud beta spanner instances create go-integration-test --config regional-us-central1 --nodes 10 --description 'Instance for go client test'
# NOTE: Spanner instances are priced by the node-hour, so you may want to
# delete the instance after testing with 'gcloud beta spanner instances delete'.

$ export SPANNER_TEST_INSTANCE=go-integration-test
```

It may be useful to add exports to your shell initialization for future use.
For instance, in `.zshrc`:

```sh
#### START Test Variables
# Developers Console project's ID (e.g. bamboo-shift-455) for the general project.
export SPANNER_TEST_PROJECT=your-project

# Developers Console Spanner's instance ID (e.g. spanner-instance) for the running tests.
export SPANNER_TEST_INSTANCE=go-integration-test
#### END Test Variables
```

#### Running

Once you've done the necessary setup, you can run the integration tests by
running:

``` sh
$ go test -v ./...
```

## Contributor License Agreements

Before we can accept your pull requests you'll need to sign a Contributor
License Agreement (CLA):

- **If you are an individual writing original source code** and **you own the
intellectual property**, then you'll need to sign an [individual CLA][indvcla].
- **If you work for a company that wants to allow you to contribute your
work**, then you'll need to sign a [corporate CLA][corpcla].

You can sign these electronically (just scroll to the bottom). After that,
we'll be able to accept your pull requests.

[gcloudcli]: https://developers.google.com/cloud/sdk/gcloud/
[indvcla]: https://developers.google.com/open-source/cla/individual
[corpcla]: https://developers.google.com/open-source/cla/corporate
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
[Google Cloud Spanner](https://cloud.google.com/spanner) driver for
Go's [database/sql](https://golang.org/pkg/database/sql/) package.


This support is currently in the __Preview__ release status.

``` go
import _ "github.com/googleapis/go-sql-spanner"

Expand Down Expand Up @@ -148,3 +145,29 @@ initial attempt and the retry attempt, the Aborted error will be propagated
to the client application as an `spannerdriver.ErrAbortedDueToConcurrentModification`
error.

## [Go Versions Supported](#supported-versions)

Our libraries are compatible with at least the three most recent, major Go
releases. They are currently compatible with:

- Go 1.18
- Go 1.17
- Go 1.16
- Go 1.15

## Authorization

By default, each API will use [Google Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials)
for authorization credentials used in calling the API endpoints. This will allow your
application to run in many environments without requiring explicit configuration.

## Contributing

Contributions are welcome. Please, see the
[CONTRIBUTING](https://github.com/googleapis/go-sql-spanner/blob/main/CONTRIBUTING.md)
document for details.

Please note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms.
See [Contributor Code of Conduct](https://github.com/googleapis/go-sql-spanner/blob/main/CODE_OF_CONDUCT.md)
for more information.
23 changes: 12 additions & 11 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,21 @@ import (
"google.golang.org/grpc/status"
)

const userAgent = "go-sql-spanner/0.1"
const userAgent = "go-sql-spanner/1.0.0"

// dsnRegExpString describes the valid values for a dsn (connection name) for
// Google Cloud Spanner. The string consists of the following parts:
// 1. (Optional) Host: The host name and port number to connect to.
// 2. Database name: The database name to connect to in the format `projects/my-project/instances/my-instance/databases/my-database`
// 3. (Optional) Parameters: One or more parameters in the format `name=value`. Multiple entries are separated by `;`.
// The supported parameters are:
// - credentials: File name for the credentials to use. The connection will use the default credentials of the
// environment if no credentials file is specified in the connection string.
// - usePlainText: Boolean that indicates whether the connection should use plain text communication or not. Set this
// to true to connect to local mock servers that do not use SSL.
// - retryAbortsInternally: Boolean that indicates whether the connection should automatically retry aborted errors.
// The default is true.
// 1. (Optional) Host: The host name and port number to connect to.
// 2. Database name: The database name to connect to in the format `projects/my-project/instances/my-instance/databases/my-database`
// 3. (Optional) Parameters: One or more parameters in the format `name=value`. Multiple entries are separated by `;`.
// The supported parameters are:
// - credentials: File name for the credentials to use. The connection will use the default credentials of the
// environment if no credentials file is specified in the connection string.
// - usePlainText: Boolean that indicates whether the connection should use plain text communication or not. Set this
// to true to connect to local mock servers that do not use SSL.
// - retryAbortsInternally: Boolean that indicates whether the connection should automatically retry aborted errors.
// The default is true.
//
// Example: `localhost:9010/projects/test-project/instances/test-instance/databases/test-database;usePlainText=true`
var dsnRegExp = regexp.MustCompile("((?P<HOSTGROUP>[\\w.-]+(?:\\.[\\w\\.-]+)*[\\w\\-\\._~:/?#\\[\\]@!\\$&'\\(\\)\\*\\+,;=.]+)/)?projects/(?P<PROJECTGROUP>(([a-z]|[-.:]|[0-9])+|(DEFAULT_PROJECT_ID)))(/instances/(?P<INSTANCEGROUP>([a-z]|[-]|[0-9])+)(/databases/(?P<DATABASEGROUP>([a-z]|[-]|[_]|[0-9])+))?)?(([\\?|;])(?P<PARAMSGROUP>.*))?")

Expand Down
11 changes: 11 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"release-type": "go-yoshi",
"separate-pull-requests": true,
"include-component-in-tag": false,
"packages": {
".": {
"component": "main"
}
},
"plugins": ["sentence-case"]
}

0 comments on commit a9ea878

Please sign in to comment.