Coder Social home page Coder Social logo

thundergolfer / example-bazel-monorepo Goto Github PK

View Code? Open in Web Editor NEW
315.0 315.0 31.0 603 KB

πŸŒΏπŸ’š Example Bazel-ified monorepo, supporting Golang, Java, Python, Scala, and Typescript

Home Page: https://buildkite.com/thundergolfer-inc/the-one-true-bazel-monorepo

License: MIT License

Python 14.73% Scala 0.28% Shell 21.88% Java 29.04% Go 1.72% Starlark 22.13% TypeScript 3.04% HTML 0.36% HCL 6.81%
bazel bazel-monorepo blaze buck build-tool platform-engineering

example-bazel-monorepo's Introduction

πŸ‘‹ Hi there, thanks for stopping by

I'm here a lot, building data-intensive products from the ground up. I'm bullish on, and a big booster of:

  • modal.com! Truly cloud-native application development. The fastest way to run code in the cloud.
  • πŸŒΏπŸ’š @bazelbuild and generally using functional principles to keep things sane. (I've open-sourced a few tools for the Bazel ecosystem, see below)
  • Good old-fashioned books πŸ“–. Two recent favourites are The Plot Against America and The Netanyahus.
  • Effective Altruism. Helping, not harming. Doing, not having. Building, not consuming. (Mosquito nets, not the SBF/FTX-style embarassment)

Active Projects

Past Projects

  • Growing Python in the Bazel ecosystem. See various projects in my pins. I previously did maintenance duty for bazelbuild/rules_python. Unfortunately, I no longer have time to dedicate to the ecosystem.
    • whitelist.sh - A goal-oriented, calendar aware content feed that I would have wanted to use during my undergrad. πŸ‘·πŸ»β€β™‚οΈ

Computing is pop culture. [...] Pop culture holds a disdain for history. Pop culture is all about identity and feeling like you're participating, It has nothing to do with cooperation, the past or the futureβ€”it's living in the present. I think the same is true of most people who write code for money. They have no idea where [their culture came from]. - Alan Kay

example-bazel-monorepo's People

Contributors

dependabot[bot] avatar thundergolfer avatar thundergolfer-two avatar willsalz 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  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  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  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

example-bazel-monorepo's Issues

Buildkite Pipeline - Add other relevant pipeline steps

Description

Running bazel test //... is great and all, but there are other CI steps that any respectable Bazel monorepo should run. Right now I can think of:

  1. BUILD file and other Bazel file linting. Important in context of project
  2. Code linting (this could be costly if this project involves 4-5 different languages)
  3. Some sort of WORKSPACE file validation

Failure after clone

Description of the problem / feature request:

I cloned the repositoy locally. Then executed bazel build //.... However, the build fails.

πŸ› Bug Report: Expected Behavior

Successful build.

πŸ› Bug Report: Actual Behavior

INFO: Invocation ID: 7dbc255e-7eeb-4176-a0c1-d5aff91a5ad1
INFO: Repository bazel_gazelle_go_repository_config instantiated at:
  /Users/brettw/Documents/dev/example-bazel-monorepo/WORKSPACE.bazel:40:21: in <toplevel>
  /private/var/tmp/_bazel_brettw/8b843efc2057a180abb205fca8381752/external/bazel_gazelle/deps.bzl:73:25: in gazelle_dependencies
Repository rule go_repository_config defined at:
  /private/var/tmp/_bazel_brettw/8b843efc2057a180abb205fca8381752/external/bazel_gazelle/internal/go_repository_config.bzl:57:39: in <toplevel>
ERROR: An error occurred during the fetch of repository 'bazel_gazelle_go_repository_config':
   Traceback (most recent call last):
	File "/private/var/tmp/_bazel_brettw/8b843efc2057a180abb205fca8381752/external/bazel_gazelle/internal/go_repository_config.bzl", line 25, column 31, in _go_repository_config_impl
		config_path = ctx.path(ctx.attr.config)
Error in path: Not a regular file: /Users/brettw/Documents/dev/example-bazel-monorepo/WORKSPACE
ERROR: Error fetching repository: Traceback (most recent call last):
	File "/private/var/tmp/_bazel_brettw/8b843efc2057a180abb205fca8381752/external/bazel_gazelle/internal/go_repository_config.bzl", line 25, column 31, in _go_repository_config_impl
		config_path = ctx.path(ctx.attr.config)
Error in path: Not a regular file: /Users/brettw/Documents/dev/example-bazel-monorepo/WORKSPACE
ERROR: error loading package '': Encountered error while reading extension file 'buildifier/def.bzl': no such package '@com_github_bazelbuild_buildtools//buildifier': no such package '@bazel_gazelle_go_repository_config//': Not a regular file: /Users/brettw/Documents/dev/example-bazel-monorepo/WORKSPACE
INFO: Elapsed time: 0.128s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded)
    currently loading: cli ... (6 packages)
    Fetching @py_deps; Restarting.
    Fetching @com_github_bazelbuild_buildtools; Restarting.
    Fetching @graknlabs_bazel_distribution; fetching

πŸ› Bug Report: Steps to Reproduce the Problem

  1. Clone the repo
  2. Execute bazel build //...

πŸ› Bug Report: Specifications

  • Platform: MacOS 11.6.6 (Intel)

What is the point of bootstrap_agent.sh

Description of the problem / feature request:

It looks like bootstrap_agent.sh does just about nothing. What is the point of this script, and why do you have it in a s3 bucket?

πŸ› Bug Report: Expected Behavior

πŸ› Bug Report: Actual Behavior

πŸ› Bug Report: Steps to Reproduce the Problem

πŸ› Bug Report: Specifications

  • Version:
  • Platform:

CI broken

Auto-Configuration Error: Cannot find gcc or CC; either correct your path or set the CC environment variable πŸ˜–

buildkite pre-command returns Error: No command has been provided

Description of the problem / feature request:

I setup a buildkite agent using the steps for aws in the builtkite UI. Now when the project builds I get this error. Not sure if this is a bug or I did something wrong...

πŸ› Bug Report: Expected Behavior

πŸ› Bug Report: Actual Behavior

πŸ› Bug Report: Steps to Reproduce the Problem

  1. Setup a buildkite agent using the steps for aws in the builtkite UI
  2. use the ami created by prepare.sh

πŸ› Bug Report: Specifications

  • Version:
  • Platform:

Properly document how Buildkite + Bazel was setup

Quick sketch of what I remember doing:

  • Create a new pipeline with a single step that just runs bazel test //...
  • Go the Buildkite (BK) agents page and select the AWS Quickstart guide. Click the button that auto-creates a CloudFormation stack in your account.
  • After that CloudFormation (CF) stack has spun up, it's likely that you'll be able to see some agents appear in your agents list in the BK UI, but they won't be able to run the step yet.
  • Follow the instructions here on how to create an SSH keypair that BK and Github will share so that your private code can be pulled
  • Create a bootstrap script like the boostrap_agent.sh script found in this repo that is able to install Bazel and its requirements (e.g Java SDK) on the BK-default 'Amazon Linux2' AMIs.
  • Upload that script into a new S3 bucket next to the S3 buckets buildkite created (like the one for private SSH keys).
  • Go into IAM in the AWS console and copy the policy that grants the buildkite-agent role access to the SSH keys bucket and modify it so that it grants that role access to the bucket that contains your bootstrap script.
  • If this is working correctly, then when you re-run BK pipeline tasks you should see Bazel correctly starting.
  • Go into the CloudFormation stack and click the "Update" button to update some parameters:
  • Update MaxInstances to 1 (it's cheaper)
  • Update MinInstances to 0 (it's cheaper)
  • Set BuildkiteTerminateInstanceAfterJobDecreaseDesiredCapacity and
    BuildkiteTerminateInstanceAfterJobtotrue`. This will scale down the ASG instances when BK jobs are finished, which is cheaper
  • Reduce the EBS volume size to 100GB, which should be plenty when starting out
  • Up the instance from t2-nano to at least t2-small, because otherwise you'll get out of memory errors.

Buildkite Pipeline - AWS infra related improvements

My Buildkite setup is now at a stage where I can run bazel test //... and have things pass πŸ˜„, but things are far from perfect.

Improvements to be made:

  1. Currently cannot access like buildkite-agent instances. The Buildkite CloudFormation template has something about ssh keyPair that can supposedly address this
  2. EC2 Instance setup currently happens in the bootstrap_agent.sh script. I think it would be much better to bake this setup into an AMI and then use that as the agent AMI instead of the base buildkite-stack AMIs. Having 1 from this list will help achieve this.
  3. Lower Priority: I had to go up from t2-nano to t2-small to avoid a JVM out-of-memory error. See if I can do some tuning or find a better instance type for these BK agents.

React app isn't working?

Description of the problem / feature request:

I may be missing something but when I run the frontend code it looks like only the html is rendered. The "React" code doesn't seem to be loading...

πŸ› Bug Report: Expected Behavior

πŸ› Bug Report: Actual Behavior

πŸ› Bug Report: Steps to Reproduce the Problem

πŸ› Bug Report: Specifications

  • Version:
  • Platform:

disable build buddy by default

Description of the problem / feature request:

please disable build buddy by default [ and remove https://app.buildbuddy.io/invocation/9a58fab0-e62e-4034-875d-b382e5f9a42b ]

'python_register_toolchains' not found

Description of the problem / feature request:

I have this in my WORKSPACE:

######################
# PYTHON SUPPORT
######################
rules_python_version = "0.7.0"

http_archive(
    name = "rules_python",
    sha256 = "15f84594af9da06750ceb878abbf129241421e3abbd6e36893041188db67f2fb",
    strip_prefix = "rules_python-0.7.0",
    url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.7.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "python_register_toolchains")

python_register_toolchains(
    name = "python39",
    # Available versions are listed in @rules_python//python:versions.bzl.
    python_version = "3.9",
)

load("@python39_resolved_interpreter//:defs.bzl", python_interpreter = "interpreter")
load("@rules_python//python:pip.bzl", "pip_install")

πŸ› Bug Report: Actual Behavior

When I run a build (of any target) I get this error:

ERROR: Traceback (most recent call last):
	File "/Users/brettw/Documents/dev/jnb-ping/WORKSPACE", line 94, column 49, in <toplevel>
		load("@rules_python//python:repositories.bzl", "python_register_toolchains")
Error: file '@rules_python//python:repositories.bzl' does not contain symbol 'python_register_toolchains'
ERROR: error loading package '': Encountered error while reading extension file 'defs.bzl': no such package '@python39_resolved_interpreter//': error loading package 'external': Could not load //external package
INFO: Elapsed time: 0.128s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

πŸ› Bug Report: Specifications

  • Platform: MacOS 11.6.6

My bazel version output:

Bazelisk version: development
Build label: 5.2.0
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jun 7 16:11:03 2022 (1654618263)
Build timestamp: 1654618263
Build timestamp as int: 1654618263

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.