Git Product home page Git Product logo

bazel_tools_demo's Introduction

bazel_tools_demo

This repository is a complete Bazel workspace which demonstrates how to author Bazel rules and tools.

Each tool in //tools is implemented with a custom Bazel rule and macro, which can be found in each tool's internal package and defs.bzl Starlark config.

Tools

To use these tools and automatically setup tests, add the following to all BUILD.bazel files:

load("//tools:linters.bzl", "lint_tests")

lint_tests()

The //tools directory also contains binaries for managing a Bazel monorepo, such as consolidating go.mod files into a centralized location in the workspace root, e.g. //tools/go-mod-tidy.

Tools that write to the workspace root may be invoked all at once with bazel run //:fmt, which uses ./x.py fmt under the hood.

Formatters

//tools/black

Format Python code with black. This tool packages black for Bazel and exposes a black_check_test rule which installs a Bazel test to check formatting in each Bazel package. The tool also exposes a black macro which will run black in the workspace root and rewrite source files with correct formatting.

This rule takes the location of a pyproject.toml config as a parameter.

//tools/buildifier

Format Bazel and Starlark code with buildifier. This tool packages buildifier for Bazel and exposes a buildifier_check_test rule which installs a Bazel test to check formatting in each Bazel package. The tool also exposes a buildifier macro which will run buildifier in the workspace root and rewrite source files with correct formatting.

//tools/gofmt

Format go code with gofmt. This tool makes a runner for the gofmt tool packaged with rules_go and exposes a gofmt_check_test which installs a Bazel test to check formatting in each Bazel package. The tool also exposes a gofmt macro which will run gofmt in the workspace root and rewrite source filrs with correct formatting.

//tools/isort

Format Python code with isort. This tool packages isort for Bazel and exposes an isort_check_test rule which installs a Bazel test to check formatting in each Bazel package. The tool also exposes an isort macro which will run isort in the workspace root and rewrite source files with correct formatting.

This rule takes the location of a pyproject.toml config as a parameter.

//tools/prettier

Format many filetypes with prettier. This tool packages prettier for Bazel and exposes a prettier_check_test rule which installs a Bazel test to check formatting in each Bazel package. The tool also exposes a prettier macro which will run prettier in the workspace root and rewrite source files with correct formatting.

The rule takes the location of .prettierignore and .prettierrc (of any type) configs as parameters.

Linters

//tools/eslint

Lint JavaScript code with eslint. This tool packages eslint for Bazel and exposes an eslint_check_test which installs a Bazel test to lint code in each Bazel package.

The rule takes the location of .eslintignore and .eslintrc (of any type) configs as parameters.

//tools/flake8

Lint Python code with flake8. This tool packages flake8 for Bazel and exposes a flake8_check_test rule which installs a Bazel test to lint code in each Bazel package.

This rule takes the location of a .flake8 config as a parameter.

//tools/yamllint

Lint YAML code with yamllint. This tool packages yamllint for Bazel and exposes a yamllint_check_test rule which installs a Bazel test to lint code in each Bazel package.

This rule takes the location of a .yamllint.yaml config as a parameter.

bazel_tools_demo's People

Contributors

dependabot[bot] avatar lopopolo avatar

Stargazers

 avatar

Watchers

 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.