This is a unified mono repo example that demonstrates how to develop, build, test, and deploy full-stack web projects, infrastructure code, and build tools using Bazel. It is designed for scalability, fast builds, and optimized deployment.
- Repo package managers:
- PNPM;
- PYPI;
- Programming languages support:
- TypeScript / JavaScript (Aspect's
rules_ts);- Building:
- Root package.json support for references across all projects;
- Build internal packages;
- Build external packages (PNPM package manager support);
- TSC TypeScript transpiler support;
- SWC TypeScript transpiler support (faster TSC alternative);
- Bundling support:
- SCSS-styles support;
- "use" imports support;
- Static assets support;
- Image support example;
- JSON files support example;
- Testing:
- Tests spec files separation from the source code in Bazel (
:tscand:tsc_testsare separate); - Tests coverage;
- Mocha/Chai support;
- Vitest support;
- Tests spec files separation from the source code in Bazel (
- Developing:
- Run local dev server (Webpack);
- Run local dev server (RSpack);
- Building:
- Python (Aspect's
rules_py);- Building:
- Build internal packages;
- Build external packages (PYPI package manager support);
- Testing:
- Tests support;
- Tests coverage;
- Building:
- GoLang;
- Building:
- Build internal packages;
- Build external packages (go_dependency support);
- Testing:
- Tests support;
- Tests coverage;
- Building:
- TypeScript / JavaScript (Aspect's
- Formatting:
- Ruff —> Python;
- Prettier —> JS, TS, HTML, CSS, SCSS, SQL, Markdown;
- Yamlfmt —> Yaml;
- Buildifier —> Starlark;
- Gofumpt —> Go;
- SHFMT —> shell/bash scripts;
- Terraform —> Terraform;
- Linting:
- Development:
- Add Remote Cache Execution support with BuildBuddy;
- Add watcher IBazel to re-build targets on source files change (instruction);
- Add custom Bazel rules examples:
- Auto-generate documentation;
- Use Gazelle to auto-update BUILD files;
- Custom scripts:
- New bazel command to create a new project using a template;
- CI/CD integration:
- Renovate bot support to update monorepo dependencies;
- Add dependencies review for PRs (license, Vulnerabilities, denied, etc...);
- Use local CI cache to store Bazel artifacts;
- Build all targets;
- Run all tests;
- Run format check;
- Run lint check;
- Infra:
- Docker: create image;
- Docker: push image to registry;
- K8s: generate manifests with concat;
- K8s: generate manifests with helm;
- K8s: manual manifests deploy;
- K8s: gitops manifests deploy;
- Terraform: run plan;
- Terraform: update cloud manifest;
$ bazel build ...— build all targets in the repo.$ bazel test ...— test all (testable) targets in the repo.$ bazel test --test_output=all ...- to see tests output in cli.
$ bazel coverage ...- generate tests coverage.$ bazel coverage --combined_report=lcov --test_output=all ...- to see tests output + tests coverage files (incoverage.dat).
$ bazel lint ...- lint all projects.$ bazel lint ... --fix- lint fix all projects.$ bazel lint //experimental/service_test_ts_webpack_react_tests/...— lint individual project.
$ pnpm update- update all projects in the monorepo.$ pnpm install- install all npm deps for all projects in monorepo.$ pnpm add— install package in some project (required$cdinto it, example:$ pnpm add typescript --save-dev).$ pnpm run— run script in package.json (example$ pnpm run build).
- Use
requirements.infile to manage (install new, update or remove old) Python dependencies in the entire monorepo. $ bazel run //:generate_requirements_txt- run to updaterequirements.txtautomatically.
$ bazel fetch //...— fetches all external dependencies required for building all targets in your workspace. Note: It does this without actually building them.$ bazel fetch @npm//...— update Bazel's copy of pnpm lockfile. Useful after adding new NPM packages.$ bazel mod tidy— (analog ofbazel syncin WORKSPACE) sync / check the status of dependencies in MODULES.$ bazel run format— formats everything in the repo.$ bazel run //:format— formats everything in the repo (explicit run from the root).$ bazel run //:format.check— check if formatting needs to be applied.
$ bazel lint ...— lints all projects.$ bazel lint //experimental/service_test_ts_webpack_react_tests/...— lints individual project.
BUILD_BUDDY_API_KEY- auth account key for BuildBuddy remote execution UI.- For CI use, it's stored in:
repo > settings > secrets > actions > BUILD_BUDDY_API_KEYkey. - Create a free personal account on BuildBuddy to get this key.
- For CI use, it's stored in: