Git Product home page Git Product logo

gerrit-linter's Introduction

GERRITFMT

This is a style verifier intended to be used with the Gerrit checks plugin.

HOW TO USE

  1. Install formatters:
go install github.com/bazelbuild/buildtools/buildifier
curl -o google-java-format.jar https://github.com/google/google-java-format/releases/download/google-java-format-1.7/google-java-format-1.7-all-deps.jar
  1. Obtain an HTTP password, and put it in testsite-auth. The format is username:secret.

  2. Register a checker

go run ./cmd/checker -auth_file=testsite-auth  --gerrit http://localhost:8080 \
  --language go --repo gerrit --register
  1. Make sure the checker is there
go run ./cmd/checker -auth_file=testsite-auth  --gerrit http://localhost:8080 \
  --list
  1. Start the server
go run ./cmd/checker -auth_file=testsite-auth  --gerrit http://localhost:8080

DESIGN

For simplicity of deployment, the gerrit-linter checker is stateless. All the necessary data is encoded in the checker UUID.

TODO

  • handle file types (symlink) and deletions

  • more formatters: clang-format, typescript, jsformat, ... ?

  • isolate each formatter to run with a separate gvisor/docker container.

  • tests: the only way to test this reliably is to spin up a gerrit server, and create changes against the server.

  • Update the list of checkers periodically.

SECURITY

This currently runs the formatters without sandboxing. Critical bugs (heap overflow, buffer overflow) in formatters can be escalated to obtain the OAuth2 token used for authentication.

The currently supported formatters are written in Java and Go, so this should not be an issue.

DOCKER ON GCP

The following example shows how to build a Docker image hosted on GCP, in the project api-project-164060093628.

VERSION=$(date --iso-8601=minutes | tr -d ':' | tr '[A-Z]' '[a-z]'| sed \
    's|\+.*$||')-$(git rev-parse --short HEAD)
NAME=gcr.io/api-project-164060093628/gerrit-linter:${VERSION}
docker build -t ${NAME} -f Dockerfile .
docker push ${NAME}

To deploy onto a GCP VM, configure the VM to have scope https://www.googleapis.com/auth/gerritcodereview:

cloud beta compute instances set-scopes VM-NAME --scopes=https://www.googleapis.com/auth/gerritcodereview

DISCLAIMER

This is not an official Google product

gerrit-linter's People

Contributors

hanwen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.