Skip to content

Commit

Permalink
sample checkers output
Browse files Browse the repository at this point in the history
  • Loading branch information
alevenberg committed Dec 5, 2023
1 parent 3f2843b commit 0d747a5
Show file tree
Hide file tree
Showing 27 changed files with 564 additions and 513 deletions.
1 change: 0 additions & 1 deletion .github/snippet-bot.yml
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

58 changes: 28 additions & 30 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
# 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,
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.
- 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.
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.
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/)
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/)
20 changes: 10 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

## Contributor License Agreements

We'd love to accept your patches! Before we can take them, we
have to jump a couple of legal hurdles.
We'd love to accept your patches! Before we can take them, we have to jump a
couple of legal hurdles.

Please fill out either the individual or corporate Contributor License Agreement
(CLA).

* If you are an individual writing original source code and you're sure you
own the intellectual property, then you'll need to sign an
[individual CLA](https://developers.google.com/open-source/cla/individual).
* If you work for a company that wants to allow you to contribute your work,
then you'll need to sign a
[corporate CLA](https://developers.google.com/open-source/cla/corporate).
- If you are an individual writing original source code and you're sure you own
the intellectual property, then you'll need to sign an
[individual CLA](https://developers.google.com/open-source/cla/individual).
- If you work for a company that wants to allow you to contribute your work,
then you'll need to sign a
[corporate CLA](https://developers.google.com/open-source/cla/corporate).

Follow either of the two links above to access the appropriate CLA and
instructions for how to sign and return it. Once we receive it, we'll be able to
Expand All @@ -33,5 +33,5 @@ accept your pull requests.

## Style

Samples in this repository follow the [Google C++ Style Guide](
https://google.github.io/styleguide/cppguide.html).
Samples in this repository follow the
[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
31 changes: 18 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
# C++ Samples

A small collection of samples that demonstrate how to call Google Cloud services from C++.
A small collection of samples that demonstrate how to call Google Cloud services
from C++.

[![style][style-badge]][style-link] [![cloud build][cloud-build-badge]][cloud-build-link]
[![style][style-badge]][style-link]
[![cloud build][cloud-build-badge]][cloud-build-link]

The samples in this repo cover only a _small fraction_ of the total APIs that you can call from C++. See
the [googleapis repo](https://github.com/googleapis/googleapis) to see the full list of APIs callable from C++.
The samples in this repo cover only a _small fraction_ of the total APIs that
you can call from C++. See the
[googleapis repo](https://github.com/googleapis/googleapis) to see the full list
of APIs callable from C++.

These samples will only build and run on **Linux**.

There is a growing collection of [C++ client libraries] for Google Cloud services. These include Cloud Bigtable, Cloud
Pub/Sub, Cloud Spanner, and Google Cloud Storage. These libraries include
examples of how to use most functions. The examples in this repository typically
involve using a combination of services, or a more specific use-case.
There is a growing collection of [C++ client libraries] for Google Cloud
services. These include Cloud Bigtable, Cloud Pub/Sub, Cloud Spanner, and Google
Cloud Storage. These libraries include examples of how to use most functions.
The examples in this repository typically involve using a combination of
services, or a more specific use-case.

## Contributing changes

* See [CONTRIBUTING.md](CONTRIBUTING.md)
- See [CONTRIBUTING.md](CONTRIBUTING.md)

## Licensing

* See [LICENSE](LICENSE)
- See [LICENSE](LICENSE)

[C++ client libraries]: https://github.com/googleapis/google-cloud-cpp
[style-badge]: https://github.com/GoogleCloudPlatform/cpp-samples/actions/workflows/style.yaml/badge.svg
[style-link]: https://github.com/GoogleCloudPlatform/cpp-samples/actions/workflows/style.yaml
[c++ client libraries]: https://github.com/googleapis/google-cloud-cpp
[cloud-build-badge]: https://img.shields.io/badge/cloud%20build-TODO-yellowgreen
[cloud-build-link]: https://github.com/GoogleCloudPlatform/cpp-samples/issues/119
[style-badge]: https://github.com/GoogleCloudPlatform/cpp-samples/actions/workflows/style.yaml/badge.svg
[style-link]: https://github.com/GoogleCloudPlatform/cpp-samples/actions/workflows/style.yaml
6 changes: 4 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

To report a security issue, please use [g.co/vulnz](https://g.co/vulnz).

The Google Security Team will respond within 5 working days of your report on g.co/vulnz.
The Google Security Team will respond within 5 working days of your report on
g.co/vulnz.

We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue.
We use g.co/vulnz for our intake, and do coordination and disclosure here using
GitHub Security Advisory to privately discuss and fix the issue.
30 changes: 16 additions & 14 deletions bigquery/write/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Using BigQuery Storage Write

This example shows how to upload some data to BigQuery using the BigQuery Storage API.
For simplicity, the example uses a hard-coded dataset, table, and schema. It uses
the default "write stream" and always uploads the same data.
This example shows how to upload some data to BigQuery using the BigQuery
Storage API. For simplicity, the example uses a hard-coded dataset, table, and
schema. It uses the default "write stream" and always uploads the same data.

If you are not familiar with the BigQuery Storage Write API, we recommend you
first read the [API overview] before starting this guide.

## Compiling the Example

This project uses `vcpkg` to install its dependencies. Clone `vcpkg` in your `$HOME`:
This project uses `vcpkg` to install its dependencies. Clone `vcpkg` in your
`$HOME`:

```shell
git clone -C $HOME https://github.com/microsoft/vcpkg.git
Expand All @@ -21,8 +22,8 @@ Install the typical development tools, on Ubuntu you would use:
apt update && apt install -y build-essential cmake git ninja-build pkg-config g++ curl tar zip unzip
```

In this directory compile the dependencies and the code, this can take as long as an hour, depending on the performance
of your workstation:
In this directory compile the dependencies and the code, this can take as long
as an hour, depending on the performance of your workstation:

```shell
cd cpp-samples/bigquery/write
Expand All @@ -35,10 +36,10 @@ The program will be in `.build/single_threaded_write`.

## Pre-requisites

You are going to need a Google Cloud project to host the BigQuery dataset and table used in this example.
You will need to install and configure the BigQuery CLI tool. Follow the
[Google Cloud CLI install][install-sdk] instructions, and then the [quickstart][BigQuery CLI tool] for
the BigQuery CLI tool.
You are going to need a Google Cloud project to host the BigQuery dataset and
table used in this example. You will need to install and configure the BigQuery
CLI tool. Follow the [Google Cloud CLI install][install-sdk] instructions, and
then the [quickstart][bigquery cli tool] for the BigQuery CLI tool.

Verify the CLI is working using a simple command to list the active project:

Expand All @@ -63,7 +64,8 @@ bq update cpp_samples.singers schema.json

## Run the sample

Run the example, replace the `[PROJECT ID]` placeholder with the id of your project:
Run the example, replace the `[PROJECT ID]` placeholder with the id of your
project:

```shell
.build/single_threaded_write [PROJECT ID]
Expand All @@ -84,6 +86,6 @@ bq rm -f cpp_samples.singers
bq rm -f cpp_samples
```

[API overview]: https://cloud.google.com/bigquery/docs/write-api
[BigQuery CLI tool]: https://cloud.google.com/bigquery/docs/bq-command-line-tool
[install-sdk]: https://cloud.google.com/sdk/docs/install-sdk
[api overview]: https://cloud.google.com/bigquery/docs/write-api
[bigquery cli tool]: https://cloud.google.com/bigquery/docs/bq-command-line-tool
[install-sdk]: https://cloud.google.com/sdk/docs/install-sdk
28 changes: 14 additions & 14 deletions ci/builds/setup-bazel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@
set -euo pipefail

args=(
"--test_output=errors"
"--verbose_failures=true"
"--keep_going"
"--experimental_convenience_symlinks=ignore"
"--cache_test_results=auto"
"--test_output=errors"
"--verbose_failures=true"
"--keep_going"
"--experimental_convenience_symlinks=ignore"
"--cache_test_results=auto"
)
if [[ -n "${BAZEL_REMOTE_CACHE:-}" ]]; then
args+=("--remote_cache=${BAZEL_REMOTE_CACHE}")
args+=("--google_default_credentials")
# See https://docs.bazel.build/versions/main/remote-caching.html#known-issues
# and https://github.com/bazelbuild/bazel/issues/3360
args+=("--experimental_guard_against_concurrent_changes")
args+=("--remote_cache=${BAZEL_REMOTE_CACHE}")
args+=("--google_default_credentials")
# See https://docs.bazel.build/versions/main/remote-caching.html#known-issues
# and https://github.com/bazelbuild/bazel/issues/3360
args+=("--experimental_guard_against_concurrent_changes")
fi

# Make some attempts to download dependencies. This is a common source of
# flakes, and worth doing for less spurious failures. If they all fail we just
# let the `bazel build` invocation below try its luck.
for i in 1 2 3; do
if env -C /workspace/setup bazel fetch ...; then
break
fi
sleep 60
if env -C /workspace/setup bazel fetch ...; then
break
fi
sleep 60
done

env -C /workspace/setup bazel build ...
2 changes: 1 addition & 1 deletion ci/builds/setup-conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ conda config --set channel_priority strict
conda install -y -c conda-forge cmake ninja cxx-compiler google-cloud-cpp libgoogle-cloud
# [END cpp_setup_conda_install]

cmake -G Ninja -S /workspace/setup -B /var/tmp/build/setup-conda
cmake -G Ninja -S /workspace/setup -B /var/tmp/build/setup-conda
cmake --build /var/tmp/build/setup-conda
2 changes: 1 addition & 1 deletion ci/builds/setup-vcpkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
set -euo pipefail

cmake -S /workspace/setup -B /var/tmp/build/setup-vcpkg \
-DCMAKE_TOOLCHAIN_FILE=/usr/local/vcpkg/scripts/buildsystems/vcpkg.cmake
-DCMAKE_TOOLCHAIN_FILE=/usr/local/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build /var/tmp/build/setup-vcpkg
2 changes: 1 addition & 1 deletion ci/cloudbuild-setup-bazel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ steps:
env: [
'BAZEL_REMOTE_CACHE=https://storage.googleapis.com/${_CACHE_BUCKET}/cpp-samples/setup-bazel',
]
args: [ '/workspace/ci/builds/setup-bazel.sh' ]
args: [ '/workspace/ci/builds/setup-bazel.sh' ]

# Remove the images created by this build.
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
Expand Down
2 changes: 1 addition & 1 deletion ci/cloudbuild-setup-vcpkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ steps:
]

- name: 'gcr.io/${PROJECT_ID}/cpp-samples/ci/devtools:${BUILD_ID}'
args: [ '/workspace/ci/builds/setup-vcpkg.sh' ]
args: [ '/workspace/ci/builds/setup-vcpkg.sh' ]

# Remove the images created by this build.
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
Expand Down
2 changes: 1 addition & 1 deletion ci/conda.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y bzip2 curl python3
RUN apt update && apt install -y bzip2 curl python3
4 changes: 2 additions & 2 deletions cloud-run-hello-world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export GOOGLE_CLOUD_PROJECT=...
```

This script will enable the necessary APIs, build a Docker image using Cloud
Build, create a service account for the Cloud Run deployment, and then create
a Cloud Run deployment using the Docker image referenced earlier.
Build, create a service account for the Cloud Run deployment, and then create a
Cloud Run deployment using the Docker image referenced earlier.

```bash
cd google/cloud/examples/cloud_run_hello
Expand Down
36 changes: 18 additions & 18 deletions cloud-run-hello-world/bootstrap-cloud-run-hello.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,45 @@
set -eu

if [[ -z "${GOOGLE_CLOUD_PROJECT:-}" ]]; then
echo "You must set GOOGLE_CLOUD_PROJECT to the project id hosting Cloud Run C++ Hello World"
exit 1
echo "You must set GOOGLE_CLOUD_PROJECT to the project id hosting Cloud Run C++ Hello World"
exit 1
fi

readonly GOOGLE_CLOUD_PROJECT="${GOOGLE_CLOUD_PROJECT:-}"
readonly GOOGLE_CLOUD_REGION="${REGION:-us-central1}"

# Enable (if they are not enabled already) the services will we will need
gcloud services enable cloudbuild.googleapis.com \
"--project=${GOOGLE_CLOUD_PROJECT}"
"--project=${GOOGLE_CLOUD_PROJECT}"
gcloud services enable containerregistry.googleapis.com \
"--project=${GOOGLE_CLOUD_PROJECT}"
"--project=${GOOGLE_CLOUD_PROJECT}"
gcloud services enable run.googleapis.com \
"--project=${GOOGLE_CLOUD_PROJECT}"
"--project=${GOOGLE_CLOUD_PROJECT}"

# Build the Docker Images
gcloud builds submit \
"--project=${GOOGLE_CLOUD_PROJECT}" \
"--config=cloudbuild.yaml"
"--project=${GOOGLE_CLOUD_PROJECT}" \
"--config=cloudbuild.yaml"

# Create a service account that will update the index
readonly SA_ID="cloud-run-hello"
readonly SA_NAME="${SA_ID}@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com"
if gcloud iam service-accounts describe "${SA_NAME}" \
"--project=${GOOGLE_CLOUD_PROJECT}" >/dev/null 2>&1; then
echo "The ${SA_ID} service account already exists"
"--project=${GOOGLE_CLOUD_PROJECT}" >/dev/null 2>&1; then
echo "The ${SA_ID} service account already exists"
else
gcloud iam service-accounts create "${SA_ID}" \
"--project=${GOOGLE_CLOUD_PROJECT}" \
--description="C++ Hello World for Cloud Run"
gcloud iam service-accounts create "${SA_ID}" \
"--project=${GOOGLE_CLOUD_PROJECT}" \
--description="C++ Hello World for Cloud Run"
fi

# Create the Cloud Run deployment to update the index
gcloud run deploy cloud-run-hello \
"--project=${GOOGLE_CLOUD_PROJECT}" \
"--service-account=${SA_NAME}" \
"--image=gcr.io/${GOOGLE_CLOUD_PROJECT}/cloud-run-hello:latest" \
"--region=${GOOGLE_CLOUD_REGION}" \
"--platform=managed" \
"--no-allow-unauthenticated"
"--project=${GOOGLE_CLOUD_PROJECT}" \
"--service-account=${SA_NAME}" \
"--image=gcr.io/${GOOGLE_CLOUD_PROJECT}/cloud-run-hello:latest" \
"--region=${GOOGLE_CLOUD_REGION}" \
"--platform=managed" \
"--no-allow-unauthenticated"

exit 0
Loading

0 comments on commit 0d747a5

Please sign in to comment.