genbot

command
v0.0.0-...-31558c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

README

genbot

genbot is a binary for generating gapics and creating PRs with the results. It is intended to be used as a bot, though it can be run locally too.

Prerequisites for running locally

Note that only step one, listed below, is required if you plan to run the code in docker.

  1. Clone this project: git clone https://github.com/googleapis/google-cloud-go.git
  2. Install protoc
  3. Install Go
  4. Add $GOPATH/bin to PATH
  5. Create a GitHub access token.
  6. Install Go tools:
go get \
    github.com/golang/protobuf/protoc-gen-go \
    golang.org/x/lint/golint \
    golang.org/x/tools/cmd/goimports \
    honnef.co/go/tools/cmd/staticcheck \
    github.com/googleapis/gapic-generator-go/cmd/protoc-gen-go_gapic

Generating code and PRs(bot mode)

Run genbot locally

Note: this may change your ~/.gitconfig, ~/.gitcookies, and use up non-trivial amounts of space on your computer.

  1. Make sure you are on a non-Windows platform. If you are using windows continue on to the docker instructions.
  2. Make sure you have all the tools installed listed in genlocal's README.md
  3. Run:
cd /path/to/internal/gapicgen
go run cloud.google.com/go/internal/gapicgen/cmd/genbot \
    --githubAccessToken=$GITHUB_ACCESS_TOKEN \
    --githubUsername=$GITHUB_USERNAME \
    --githubName="Jean de Klerk" \
    --githubEmail=deklerk@google.com \
Run genbot with docker

Note: this can be quite slow (~10m).

Note: this may leave a lot of docker resources laying around. Use docker system prune to clean up after runs.

cd /path/to/internal/gapicgen/cmd/genbot
docker build . -t genbot
docker run -t --rm --privileged \
   -v `pwd`/../..:/gapicgen \
   -e GITHUB_ACCESS_TOKEN \
   -e GITHUB_USERNAME \
   -e GITHUB_NAME \
   -e GITHUB_EMAIL \
   genbot

Generating code (local mode)

Sometimes you may want to just generate gapic sources to test out new changes, test the generation of a new library, test new generator tweaks, run generators against googleapis-private, and various other local tasks. The local mode in genbot allows you to do just that.

Run genbot(local mode) locally
cd /path/to/internal/gapicgen
go run cloud.google.com/go/internal/gapicgen/cmd/genbot \
   -local \
   -only-gapics \
   -gocloud-dir=/path/to/google-cloud-go \
   -gapic=cloud.google.com/go/foo/apiv1
Run genbot(local mode) with docker
cd /path/to/internal/gapicgen
docker build -t genbot -f cmd/genbot/Dockerfile .
docker run --rm \
   -v `pwd`/../..:/gapicgen \
   -e GENBOT_LOCAL_MODE=true \
   -e ONLY_GAPICS=true \
   -e GOCLOUD_DIR=/gapicgen \
   -e GAPIC_TO_GENERATE=cloud.google.com/go/foo/apiv1 \
   genbot

Note you can optionally mount in your Go module cache if you have Go installed. This will speed up the build a bit:

-v `go env GOMODCACHE`:/root/go/pkg/mod
Generating new stubs

Flip status in aliasfix for gapics being migrated to in progress.

cd /path/to/internal/gapicgen
go run cloud.google.com/go/internal/gapicgen/cmd/genbot \
   -local \
   -only-gapics \
   -gocloud-dir=/path/to/google-cloud-go \
   -gapic=cloud.google.com/go/foo/apiv1

FAQ

How to bump to a later version of the microgenerator
cd /path/to/internal/gapicgen
go get -d github.com/googleapis/gapic-generator-go/cmd/protoc-gen-go_gapic

(it's just based on the go.mod entry)

Documentation

Overview

genbot is a binary for generating gapics and creating CLs/PRs with the results. It is intended to be used as a bot, though it can be run locally too.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL