{"id":29483472,"url":"https://github.com/airyhq/bazel-tools","last_synced_at":"2025-07-15T03:33:05.792Z","repository":{"id":39704686,"uuid":"316510313","full_name":"airyhq/bazel-tools","owner":"airyhq","description":"Bazel tooling used by all Airy Bazel workspaces.","archived":false,"fork":false,"pushed_at":"2022-10-24T13:27:55.000Z","size":487,"stargazers_count":15,"open_issues_count":6,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2023-07-31T22:29:48.234Z","etag":null,"topics":["bazel","bazel-rules","build-tool","lint","typescript","webpack"],"latest_commit_sha":null,"homepage":null,"language":"Starlark","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/airyhq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-27T13:34:47.000Z","updated_at":"2023-06-30T18:19:48.000Z","dependencies_parsed_at":"2023-01-19T17:19:07.669Z","dependency_job_id":null,"html_url":"https://github.com/airyhq/bazel-tools","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/airyhq/bazel-tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airyhq%2Fbazel-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airyhq%2Fbazel-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airyhq%2Fbazel-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airyhq%2Fbazel-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/airyhq","download_url":"https://codeload.github.com/airyhq/bazel-tools/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airyhq%2Fbazel-tools/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265397526,"owners_count":23758443,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bazel","bazel-rules","build-tool","lint","typescript","webpack"],"created_at":"2025-07-15T03:30:46.512Z","updated_at":"2025-07-15T03:33:05.779Z","avatar_url":"https://github.com/airyhq.png","language":"Starlark","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Airy Bazel-tools\n\nBazel tooling used by all Airy Bazel workspaces.\n\n## Installation\n\nTo install, add this snippet to your `WORKSPACE`:\n\n```python\nload(\"@bazel_tools//tools/build_defs/repo:git.bzl\", \"git_repository\")\ngit_repository(\n    name = \"com_github_airyhq_bazel_tools\",\n    branch = \"main\",\n    remote = \"https://github.com/airyhq/bazel-tools.git\"\n)\n\nload(\"@com_github_airyhq_bazel_tools//:repositories.bzl\", \"airy_bazel_tools_dependencies\", \"airy_jvm_deps\")\nairy_bazel_tools_dependencies()\n\n# Required for Java Checkstyle\nload(\"@rules_jvm_external//:defs.bzl\", \"maven_install\")\n\nmaven_install(\n    artifacts = YOUR_JVM_ARTIFACTS_LIST + airy_jvm_deps,\n    # ...\n)\n```\n\n## Code formatting\n\nWe use language specific linters:\n\n- [Buildifier](https://github.com/bazelbuild/buildtools/tree/master/buildifier)\n  to lint Bazel files\n- [Prettier](https://prettier.io/) for TypeScript, JavaScript and SCSS\n- [CheckStyle](https://checkstyle.sourceforge.io/) for Java\n\n### Prettier\n\n**Prerequisite:** `prettier` is installed using [`rules_nodejs`](https://bazelbuild.github.io/rules_nodejs/)\n\nChecking a set of Type- or Javascript source files:\n\n```python\nload(\"@com_github_airyhq_bazel_tools//lint:prettier.bzl\", \"prettier\")\n\nprettier(\n    name = \"prettier\",\n    config = \"//:.prettierrc.json\",\n    srcs = [\"index.js\"], # Defaults to all js,jsx,ts,tsx,scss,css files\n    ignore = \"//:.prettierignore\", # Defaults to lint/.prettierignore\n)\n```\n\nBoth rules will add a `:prettier` test target to your package, which can be run like so:\n\n```shell script\nbazel test //my/package:prettier\n```\n\nTo try fixing prettier issues you instantiate the `prettier_fix` rule in your root `BUILD` file:\n\n```python\nload(\"@com_github_airyhq_bazel_tools//lint:prettier.bzl\", \"fix_prettier\")\n\nfix_prettier(\n    name = \"fix_prettier\",\n    config = \"//:.prettierrc.json\", # Defaults to lint/.prettierrc.json\n    ignore = \"//:.prettierignore\", # Defaults to lint/.prettierignore\n)\n```\n\nRun it like so:\n\n```shell script\nbazel run //:fix_prettier\n```\n\n### Eslint\n\nChecking a set of Type- or Javascript source files:\n\n```python\nload(\"@com_github_airyhq_bazel_tools//lint:eslint.bzl\", \"eslint\")\n\neslint(\n    name = \"eslint\",\n    config = \"//:.eslint.json\",\n    srcs = [\"index.ts\"], # Defaults to all js,jsx,ts,tsx,scss,css files in package\n    ignore = \"//:.eslintignore\", # Defaults to lint/.eslintignore\n)\n```\n\nThis rule will add an `:eslint` test target to your package, which can be run like so:\n\n```shell script\nbazel test //my/package:eslint\n```\n\n### Checkstyle\n\nChecking a set of Java source files:\n\n```python\nload(\"@com_github_airyhq_bazel_tools//lint:checkstyle.bzl\", \"checkstyle\")\n\ncheckstyle(\n    name = \"checkstyle\",\n    srcs = [\"src/main/java/airy/core/Main.java\"], #  Defaults to all .java files in package\n    config = \"//:checkstyle.xml\" # Defaults to lint/checkstyle.xml\n)\n```\n\nBoth rules will add a `:checkstyle` test target to your package, which can be run like so:\n\n```shell script\nbazel test //my/package:checkstyle\n```\n\n### Buildifier\n\n[Buildifier](https://github.com/bazelbuild/buildtools/tree/master/buildifier) is used for linting Bazel `BUILD` and `.bzl` files.\n\nMacro to check all starlark source files in a package:\n\n```python\nload(\"@com_github_airyhq_bazel_tools//lint:buildifier.bzl\", \"check_pkg\")\n\ncheck_pkg()\n```\n\nTo try fixing buildifier lint issues you can run:\n\n```shell script\nbazel run @com_github_airyhq_bazel_tools//lint:fix_buildifier\n```\n\nThese two rules are a very shallow wrapper of buildifier, but we package them for convenience. If you are looking\nto use its extensive API you can replace this implementation with your own.\n\n### Shellcheck\n\n[Shellcheck](https://www.shellcheck.net/) gives warnings and suggestions for\nbash/sh shell scripts.\n\nMacro to check all scripts including subdirectories ending with `.sh`:\n\n```python\nload(\"@com_github_airyhq_bazel_tools//lint:shellcheck.bzl\", \"shellcheck\")\n\nshellcheck()\n```\n\nAlternatively you can pass a glob of shellscript files with the `scripts` parameter.\n\n## Web builds\n\nFor web builds we use the [rules_nodejs](https://github.com/bazelbuild/rules_nodejs) repository. You have to install the \ndevelopment dependencies listed in the [`package.json`](./package.json) to use the web rules. \n\n### `ts_web_library`\n\nThis is a thin wrapper around the `ts_project` provided by `rules_nodejs`. It also aggregates asset dependencies so\nthat they are available to downstream bundling. \n\n```python\nload(\"@com_github_airyhq_bazel_tools//web:typescript.bzl\", \"ts_web_library\")\n\nts_web_library(\n    name = \"mylib\",\n    srcs = [\"index.ts\"],\n    deps = [\n        \"//my/web/library:ts_lib\",\n        \"@npm//react\",\n        \"@npm//@types/react\",\n    ],\n    data = [\"assets/logo.svg\"]\n)\n```\n\n**Parameters:**\n\n- `name`    Unique name of the rule. This will also be used as the js module name so that you can import it like so\n            `import {someFunction} from 'mylib'`.\n- `srcs`    (optional) Your components source files. By default we glob all `.ts` and `.tsx` files.\n- `deps`    (optional) Node module dependencies required to compile the library.\n- `data`    (optional) Files needed as imports to your typescript files. By default we glob typical web file extensions.\n- `tsconfig`    (optional) It's possible to extend tsconfigs (https://www.npmjs.com/package/@bazel/typescript#ts_config)\n- `lint_rule`    (optional) by default this is set to [check_pkg()](#prettier). Setting this flag to None, will\ndisable linting for this package.\n\n### `web_app`\n\nBundles your web resources using `webpack` and adds a target `*_server` that you can use for \nrunning a webpack server with hot code reloading.\n\n```shell script\nbazel run //my/web/package:bundle_server\n```\n\n```python\nload(\"@com_github_airyhq_bazel_tools//web:web_app.bzl\", \"web_app\")\n\nweb_app(\n    name = \"bundle\",\n    app_lib = \":app\",\n    static_assets = \"//my/web/package/public\",\n    entry = \"my/web/package/src/index.js\",\n    index = \":index.html\",\n    dev_index = \":dev_index.html\",\n    dev_tsconfig = \"//:tsconfig.json\",\n    output = {\n        \"publicPath\": \"/blog/\"\n    },\n    module_deps = module_deps,\n    webpack_prod_config = \":webpack.prod.config.js\",\n    webpack_dev_config = \":webpack.dev.config.js\",\n)\n```\n\n**Parameters:**\n\n- `name`    Unique name of the build rule. The dev server rule will be called `name_server`\n- `static_assets`   (optional) Filegroup (list of files) that should be copied \"as is\" to the webroot.\n                  Files need to be in a folder called 'public'.\n- `entry`   Relative path to your compiled index.js\n- `index`   index.html file used for the build\n- `dev_tsconfig`  (optional) Defaults to `tsconfig.json`, which has to include a mapping of modules to paths using `compilerOptions.paths`.\n- `output`  (optional) Dictionary that gets applied to the webpack output https://webpack.js.org/configuration/output/\n- `aliases` (optional) applied to webpack [alias](https://webpack.js.org/configuration/resolve/#resolvealias)\n- `show_bundle_report`  If set to true generates a static bundle size report\n- `dev_index`   (optional) index.html file used for the devserver (defaults to `index`)\n- `module_deps` (optional) app_lib dependencies on `ts_web_library` targets\n\n\n### `web_library`\n\n```python\nload(\"@com_github_airyhq_bazel_tools//web:web_library.bzl\", \"web_library\")\n\nweb_library(\n    name = \"bundle\",\n    app_lib = \":app\",\nentry = \"my/web/package/src/index.js\",\n    module_deps = [\"//package/lib:ts_web_lib_target\"],\n    output = {\n        \"publicPath\": \"/blog/\"\n    }\n)\n```\n\n**Parameters:**\n\n- `name`    Unique name of the build rule.\n- `app_lib` Label of the app `ts_web_library`\n- `entry`   Relative path to your compiled index.js\n- `output`  Dictionary that gets applied to the webpack output https://webpack.js.org/configuration/output/\n- `aliases` (optional) applied to webpack [alias](https://webpack.js.org/configuration/resolve/#resolvealias)\n- `show_bundle_report`  If set to true generates a static bundle size report\n- `externals`   (optional) Dependencies that should not be bundled, see https://webpack.js.org/guides/author-libraries/#externalize-lodash\n- `module_deps` (optional) app_lib dependencies on `ts_web_library` targets\n\n## Java\n\n### `avro_java_library`\n\nThis rule takes Avro schema definition files `.avsc` and compiles them to a Jar using the [Avro tools](https://avro.apache.org/docs/current/gettingstartedjava.html) \n\n```python\nload(\"@com_github_airyhq_bazel_tools//java:avro.bzl\", \"avro_java_library\")\n\navro_java_library(\n    name = \"user\", \n    srcs = [\"user.avsc\"]\n)\n\n# Example Usage\njava_library(\n    name = \"mylib\",\n    deps = [\":user\"],\n)\n```\n\n**Parameters:**\n\n- `name`    Unique name of the generated java library.  \n- `srcs`    Avro definition files to compile. If you leave this empty it will default to `[\"{name}.avsc\"]`.\n\n\n### `junit5`\n\nThis is an opinionated wrapper around the Bazel built-in [`java_test`](https://docs.bazel.build/versions/master/be/java.html#java_test).\nIt requires that the test path starts with `src/java/test` and that the test package name is the same as the file path.\nI.e. a test file in package `com.package` needs to be located in `src/test/java/com/package/`.\n\n```python\nload(\"@com_github_airyhq_bazel_tools//java:junit5.bzl\", \"junit5\")\n\njunit5(\n    file = \"src/java/test/com/package/Test.java\", \n    size = \"small\",\n)\n```\n\n**Parameters:**\n\n- `file`    Relative file path of the test file \n\nFor more options see the Bazel `java_test` [rule](https://docs.bazel.build/versions/master/be/java.html#java_test) \n\n## Helm\n\nCurrently the helm rule set supports: downloading the helm binary as a repository rule, `helm template` in a form of test rule and `helm push` to a Chartmuseum helm repository.\n\nFor downloading the helm binary, add this to your WORKSPACES file:\n\n```python\nload(\"@com_github_airyhq_bazel_tools//helm:helm.bzl\", \"helm_tool\")\n\nhelm_tool(\n    name = \"helm_binary\",\n)\n```\n\nThe chart needs to be packaged before it can be processed by Bazel. To do that, add this to your BUILD file in the directory where the `Chart.yaml` file resides:\n\n```python\nload(\"@rules_pkg//:pkg.bzl\", \"pkg_tar\")\n\nfilegroup(\n    name = \"files\",\n    srcs = glob([\n        \"**/*.yaml\",\n        \"**/*.tpl\",\n    ]),\n)\n\npkg_tar(\n    name = \"package\",\n    srcs = [\":files\"],\n    extension = \"tgz\",\n    strip_prefix = \"./\",\n)\n```\n\nFor running a test with `helm template`, add this to your BUILD file, in the same directory:\n\n\n```python\nload(\"@com_github_airyhq_bazel_tools//helm:helm.bzl\", \"helm_template_test\")\n\nhelm_template_test(\n    name = \"template\",\n    chart = \":package\",\n)\n```\n\nThen run:\n\n```shell\nbazel test //.../helm-chart:template\n```\n\n**Parameters:**\n\n- `name`    Unique name of the rule.\n- `_helm_binary`    Location of the Helm binary to be used (Defaults to the binary downloaded with the repository rule).\n- `chart`   A tgz archive containing the Helm chart.\n\nFor pushing to a Chartmuseum helm repository, add this to your BUILD file, in the same directory:\n\n```python\nload(\"@com_github_airyhq_bazel_tools//helm:helm.bzl\", \"helm_push\")\nhelm_push(\n    name = \"push_testing\",\n    repository_url = \"https://testing.helm.airy.co\",\n    repository_name = \"airy\",\n    auth = \"none\",\n    chart = chart,\n)\nhelm_push(\n    name = \"push\",\n    repository_url = \"https://helm.airy.co\",\n    repository_name = \"airy\",\n    auth = \"basic\",\n    chart = chart,\n)\n```\n\nThen run:\n\n```shell\nbazel run //.../helm-chart:push\n```\n\n**Parameters:**\n\n- `name`    Unique name of the rule.\n- `_helm_binary`    Location of the Helm binary to be used (Defaults to the binary downloaded with the repository rule).\n- `chart`   A tgz archive containing the Helm chart.\n- `repository_url`  The URL of the repository where the Helm chart is pushed.\n- `repository_name` The name of the temporary repoository added by Bazel.\n- `auth`    Authentication type for the Helm repository (currently only `none` and `basic` are supported).\n- `_push_script_template`   A script that is used and templated for running `helm push`.\n- `version` A string containing the version of the Helm chart.\n- `version_file`    An alternative to providing the version, a file can be used containing the version as a first line.\n\nNote that only `basic` auth is supported at the moment. If you are using it, you must export `HELM_REPO_USERNAME` and `HELM_REPO_PASSWORD` with the username and the password of your Chartmuseum helm repository.\n\n## Minikube\n\nCurrently the Minikube rule set supports starting (creating) and stopping (destroying) a Minikube Kubernetes cluster.\n\nFor downloading the Minikube binary, add this to your WORKSPACE file:\n\n```python\nload(\"@com_github_airyhq_bazel_tools//minikube:minikube.bzl\", \"minikube_tool\")\n\nminikube_tool(\n    name = \"minikube_binary\",\n)\n```\n\nFor creating a Kubernetes cluster add this to your BUILD file:\n\n```python\nload(\"@com_github_airyhq_bazel_tools//minikube:minikube.bzl\", \"minikube_start\")\n\nminikube_start(\n    name = \"minikube-start\",\n)\n```\n\nThen run:\n\n```shell\nbazel run //.../infrastructure:minikube-start\n```\n\n**Parameters:**\n\n- `name`    Unique name of the rule.\n- `_minikube_binary`    (optional) Location of the Minikube binary to be used (Defaults to the binary downloaded with the repository rule).\n- `profile`   (optional) The Minikube profile [default: airy-core].\n- `driver`   (optional) The Minikube driver [default: docker].\n- `cpus`  (optional) The number of CPU cores for the Kubernetes node [default: 4].\n- `memory` (optional) The amount of memory of the Kubernetes node [default: 7168].\n- `ingress_port`    (optional) The NodePort to be opened for the Ingress Controller [default: 80].\n\nFor destroying a Kubernetes cluster add this to your BUILD file:\n\n```python\nload(\"@com_github_airyhq_bazel_tools//minikube:minikube.bzl\", \"minikube_stop\")\n\nminikube_stop(\n    name = \"minikube-stop\",\n)\n```\n\nThen run:\n\n```shell\nbazel run //.../infrastructure:minikube-stop\n```\n\n**Parameters:**\n\n- `name`    Unique name of the rule.\n- `_minikube_binary`    (optional) Location of the Minikube binary to be used (Defaults to the binary downloaded with the repository rule).\n- `profile`   (optional) The Minikube profile [default: airy-core].\n\n## Aspects\n\nWe provide a simple [aspect](https://docs.bazel.build/versions/main/skylark/aspects.html) that helps discover the output groups of a target. \nIt can be used like so:\n\n```shell\nbazel build --nobuild //path/to:target  --aspects=@com_github_airyhq_bazel_tools//aspects:outputs.bzl%output_group_query_aspect\n```\n\n## How to contribute\n\nWe welcome (and love) every form of contribution! Good entry points to the\nproject are:\n\n- Our [contributing guidelines](CONTRIBUTING.md)\n- Issues with the tag\n  [gardening](https://github.com/airyhq/bazel-tools/issues?q=is%3Aissue+is%3Aopen+label%3Agardening)\n- Issues with the tag [good first\n  patch](https://github.com/airyhq/bazel-tools/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+patch%22)\n\nIf you're still not sure where to start, open a [new\nissue](https://github.com/airyhq/bazel-tools/issues/new) and we'll gladly help you get\nstarted.\n\n## Code of Conduct\n\nTo ensure a safe experience and a welcoming community, the project adheres to the [contributor\nconvenant](https://www.contributor-covenant.org/) [code of\nconduct](/code_of_conduct.md).\n\n\n## Airy Open Source\n\nAt Airy we ❤️ Open Source. Check out our other projects over at [docs.airy.co](https://docs.airy.co).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairyhq%2Fbazel-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fairyhq%2Fbazel-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairyhq%2Fbazel-tools/lists"}