diff --git a/.bazeliskrc b/.bazeliskrc new file mode 100644 index 0000000..fe5e2c8 --- /dev/null +++ b/.bazeliskrc @@ -0,0 +1 @@ +USE_BAZEL_VERSION=3.7.2 diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 13fe30e..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,93 +0,0 @@ -version: 2.1 -commands: - install-bazel: - steps: - - run: - name: Install bazel - command: | - curl -OL https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VER/bazel-$BAZEL_VER-installer-linux-x86_64.sh - chmod +x bazel-$BAZEL_VER-installer-linux-x86_64.sh - sudo ./bazel-$BAZEL_VER-installer-linux-x86_64.sh - rm ./bazel-$BAZEL_VER-installer-linux-x86_64.sh - bazel info release - - pre-run-setup: - steps: - - run: - name: Prepare to run bazel - command: | - sudo apt-get update -q - sudo apt-get install libxml2-utils python-dev -y # Install some basics needed for python - sudo apt-get install openjdk-11-jdk-headless - cat .bazelrc.travis >> .bazelrc - - bazel-build: - steps: - - run: - name: Build with bazel - command: | - bazel build //... - - bazel-test: - steps: - - run: - name: Test with bazel - command: | - bazel test //... - - e2e-test: - steps: - - run: - name: End to end tests - command: | - ./test_e2e.sh - - restore-caches: - steps: - - run: echo "$BAZEL_VER" > _cache_ver_tmp - - restore_cache: - keys: - - bazel_cache_{{ checksum "_cache_ver_tmp" }} - - save-caches: - steps: - - run: echo "$BAZEL_VER" > _cache_ver_tmp - - save_cache: - key: bazel_cache_{{ checksum "_cache_ver_tmp" }} - paths: - - "/home/circleci/.cache/bazel/" - -jobs: - build-template: &build-template - docker: - - image: circleci/python:3.6 - working_directory: ~/app/ - environment: - BAZEL_VER: "override_this" - steps: - - setup_remote_docker: - docker_layer_caching: false - - checkout - - pre-run-setup - - install-bazel - - restore-caches - - bazel-build - - bazel-test - - save-caches - # - e2e-test - Leave this out for now until docker issues can be resolved - - build-bazel-3-4: - <<: *build-template - environment: - BAZEL_VER: "3.4.1" - build-bazel-3-7: - <<: *build-template - environment: - BAZEL_VER: "3.7.0" - -workflows: - version: 2 - default_workflow: - jobs: - - build-bazel-3-4 - - build-bazel-3-7 diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml new file mode 100644 index 0000000..6258893 --- /dev/null +++ b/.github/workflows/bazel.yml @@ -0,0 +1,16 @@ +on: push +name: Bazel Build and Test +jobs: + checks: + name: run + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: bazelbuild/setup-bazelisk@v3 + - name: Mount bazel cache # Optional + uses: actions/cache@v4 + with: + path: "~/.cache/bazel" + key: bazel + - run: bazel build //... + - run: bazel test //... diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 69bba70..0000000 --- a/.travis.yml +++ /dev/null @@ -1,62 +0,0 @@ -# Mostly copied from https://github.com/bazelbuild/rules_scala/blob/master/.travis.yml - -dist: bionic -sudo: required -language: sh - -addons: - apt: - packages: - - libxml2-utils - -cache: - directories: - - .bazel_cache - - ~/.bazel_binaries - -_linux: &linux - os: linux - -env: - # Bazel version to use for testing - - V=3.7.0 - -before_install: - - | - if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then - OS=darwin - else - sysctl kernel.unprivileged_userns_clone=1 - OS=linux - fi - if [[ $V =~ .*rc[0-9]+.* ]]; then - PRE_RC=$(expr "$V" : '\([0-9.]*\)rc.*') - RC_PRC=$(expr "$V" : '[0-9.]*\(rc.*\)') - URL="https://storage.googleapis.com/bazel/${PRE_RC}/${RC_PRC}/bazel-${V}-installer-${OS}-x86_64.sh" - else - URL="https://github.com/bazelbuild/bazel/releases/download/${V}/bazel-${V}-installer-${OS}-x86_64.sh" - fi - wget -O install.sh "${URL}" - chmod +x install.sh - ./install.sh --user - rm -f install.sh - - cat .bazelrc.travis >> .bazelrc - -script: - # Quick test of whatever changed to fail fast - - bazel query "kind(test, rdeps(//...,set($(git diff --name-only --diff-filter=d $TRAVIS_COMMIT_RANGE | xargs -L1 bazel query))))" || true - - # Ensure every file is a bazel asset - - find * -type f | xargs -L1 bazel query > /dev/null - - # Quick test for only things that have changed, include a simple test case just in case no tests that need to be rerun are found - - bazel test $(bazel query "kind(test, rdeps(//...,set($(git diff --name-only --diff-filter=d $TRAVIS_COMMIT_RANGE | xargs -L1 bazel query))))") //examples/python/simple/jpm:jpm_test - - # Full test, build, and e2e test - - bazel test //... - - bazel build //... - - ./test_e2e.sh - - # This command modifies bazel build files, it's used here for the incidental linting checks it does. - # Nothing should get modified from the gazelle command - - bazel run //:gazelle && git diff --exit-code \ No newline at end of file diff --git a/BUILD b/BUILD index 23f8d83..dd35f2b 100644 --- a/BUILD +++ b/BUILD @@ -7,7 +7,6 @@ filegroup( ".*", # mainly .git* files ], ) + [ - ".travis.yml", ], visibility = ["//src/test/shell/bazel:__pkg__"], ) diff --git a/README.md b/README.md index a606b8a..d9652e1 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ Playing around with monorepo setup and tools to see how it works for my personal [![Build Status](https://travis-ci.org/jmeagher/monorepo.svg?branch=master)](https://travis-ci.org/jmeagher/monorepo) [![Join the chat at https://gitter.im/jmeagher-monorepo/Lobby](https://badges.gitter.im/jmeagher-monorepo/Lobby.svg)](https://gitter.im/jmeagher-monorepo/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![CircleCI](https://circleci.com/gh/jmeagher/monorepo.svg?style=svg)](https://circleci.com/gh/jmeagher/monorepo) -This might be useful to someone out there of how to setup a monorepo using [Bazel](https://github.com/bazelbuild/bazel) and a variety of languages. To get started [install Bazel](https://docs.bazel.build/). `bazel build //...` will build everything. `bazel test //...` will run all the unit tests. [`./test_e2e.sh`](test_e2e.sh) will do a little extra validation of the compiled binaries. For more detail on the build setup see [the Travis-ci configuration](.travis.yml). +This might be useful to someone out there of how to setup a monorepo using [Bazel](https://github.com/bazelbuild/bazel) and a variety of languages. To get started [install Bazelisk](https://bazel.build/install/bazelisk). `bazel build //...` will build everything. `bazel test //...` will run all the unit tests. diff --git a/WORKSPACE b/WORKSPACE index 480a792..1c7b98f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -31,13 +31,13 @@ load_build_rules(rules_to_load) load("@rules_python//python:pip.bzl", "pip_repositories", "pip3_import") pip_repositories() -pip3_import( - name = "my_python_deps", - requirements = "//3rdparty:requirements.txt", -) +# pip3_import( +# name = "my_python_deps", +# requirements = "//3rdparty:requirements.txt", +# ) -load("@my_python_deps//:requirements.bzl", _python_3rd_party = "pip_install") -_python_3rd_party() +# load("@my_python_deps//:requirements.bzl", _python_3rd_party = "pip_install") +# # _python_3rd_party() # pip_install() # Scala setup @@ -73,43 +73,43 @@ load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository") # gazelle:repository_macro my-go-repositories.bzl%my_go_repositories gazelle_dependencies() -# Setup docker support -load( - "@io_bazel_rules_docker//repositories:repositories.bzl", - container_repositories = "repositories", -) -container_repositories() +# # Setup docker support +# load( +# "@io_bazel_rules_docker//repositories:repositories.bzl", +# container_repositories = "repositories", +# ) +# container_repositories() -# Docker testing images -load( - "@io_bazel_rules_docker//python:image.bzl", - _py_image_repos = "repositories", -) +# # Docker testing images +# load( +# "@io_bazel_rules_docker//python:image.bzl", +# _py_image_repos = "repositories", +# ) -load("@io_bazel_rules_docker//repositories:deps.bzl", container_deps = "deps") +# load("@io_bazel_rules_docker//repositories:deps.bzl", container_deps = "deps") -container_deps() +# container_deps() -load( - "@io_bazel_rules_docker//container:container.bzl", - "container_pull", -) +# load( +# "@io_bazel_rules_docker//container:container.bzl", +# "container_pull", +# ) -_py_image_repos() +# _py_image_repos() -load( - "@io_bazel_rules_docker//scala:image.bzl", - _scala_image_repos = "repositories", -) +# load( +# "@io_bazel_rules_docker//scala:image.bzl", +# _scala_image_repos = "repositories", +# ) -_scala_image_repos() +# _scala_image_repos() -load( - "@io_bazel_rules_docker//go:image.bzl", - _go_image_repos = "repositories", -) +# load( +# "@io_bazel_rules_docker//go:image.bzl", +# _go_image_repos = "repositories", +# ) -_go_image_repos() +# _go_image_repos() # Rust support # Removed for now since it's been delicate to maintain and I'm not working with it now @@ -120,24 +120,24 @@ _go_image_repos() # Load external docker containers -container_pull( - name = "cassandra3", - registry = "index.docker.io", - repository = "library/cassandra", - # 'tag' is also supported, but digest is encouraged for reproducibility. - # note: couldn't get digest version to work - tag = "3.11.1", - digest = "sha256:18698b13866b5e805420718e22ad32e3b3227182d3143aaaa937c6154bb5d2bb", -) - -container_pull( - name = "envoyproxy", - registry = "index.docker.io", - # Picked a recent build at random from https://hub.docker.com/r/envoyproxy/envoy-alpine/tags/ - repository = "envoyproxy/envoy-alpine", - tag = "200b0e41641be46471c2ce3d230aae395fda7ded", - digest = "sha256:ae046d3c3b1ebcdbf02cd924edfb2fe5e328ab462c3e44961cb4aac9be208491", -) +# container_pull( +# name = "cassandra3", +# registry = "index.docker.io", +# repository = "library/cassandra", +# # 'tag' is also supported, but digest is encouraged for reproducibility. +# # note: couldn't get digest version to work +# tag = "3.11.1", +# digest = "sha256:18698b13866b5e805420718e22ad32e3b3227182d3143aaaa937c6154bb5d2bb", +# ) + +# container_pull( +# name = "envoyproxy", +# registry = "index.docker.io", +# # Picked a recent build at random from https://hub.docker.com/r/envoyproxy/envoy-alpine/tags/ +# repository = "envoyproxy/envoy-alpine", +# tag = "200b0e41641be46471c2ce3d230aae395fda7ded", +# digest = "sha256:ae046d3c3b1ebcdbf02cd924edfb2fe5e328ab462c3e44961cb4aac9be208491", +# ) # Load external golang repos # To add or update new external go dependencies edit go.mod and run ... diff --git a/examples/docker/cassandra/BUILD b/examples/docker/cassandra/BUILD index 9c056bd..29290a4 100644 --- a/examples/docker/cassandra/BUILD +++ b/examples/docker/cassandra/BUILD @@ -6,10 +6,10 @@ # docker run --name mycassandra -d bazel/examples/docker/cassandra:cassandra_test # # For more help and options see https://hub.docker.com/_/cassandra/ -container_image( - name = "cassandra_single_node", - base = "@cassandra3//image", - entrypoint = "/load_data_and_run.sh", - files = glob(["*.sh"]), - visibility = ["//visibility:public"], -) +# container_image( +# name = "cassandra_single_node", +# base = "@cassandra3//image", +# entrypoint = "/load_data_and_run.sh", +# files = glob(["*.sh"]), +# visibility = ["//visibility:public"], +# ) diff --git a/examples/python/external_deps/BUILD b/examples/python/external_deps/BUILD index 9c2e30e..f9bf7cb 100644 --- a/examples/python/external_deps/BUILD +++ b/examples/python/external_deps/BUILD @@ -1,15 +1,15 @@ -py_binary( - name = "main", - srcs = ["main.py"], - deps = ["//examples/python/external_deps/jpm:numerics"], -) +# py_binary( +# name = "main", +# srcs = ["main.py"], +# deps = ["//examples/python/external_deps/jpm:numerics"], +# ) -py_image( - name = "main_docker", - srcs = ["main.py"], - main = "main.py", - deps = [":main"], -) +# py_image( +# name = "main_docker", +# srcs = ["main.py"], +# main = "main.py", +# deps = [":main"], +# ) filegroup( name = "srcs", diff --git a/examples/python/external_deps/jpm/BUILD b/examples/python/external_deps/jpm/BUILD index 21f0d61..26aa97f 100644 --- a/examples/python/external_deps/jpm/BUILD +++ b/examples/python/external_deps/jpm/BUILD @@ -1,24 +1,24 @@ package(default_visibility = ["//visibility:public"]) -py_library( - name = "numerics", - srcs = [ - "__init__.py", - "numerics.py", - ], - imports = [".."], - deps = [ - requirement("numpy"), - requirement("pandas"), - requirement("pytz"), - requirement("python-dateutil"), - requirement("six"), - ], -) +# py_library( +# name = "numerics", +# srcs = [ +# "__init__.py", +# "numerics.py", +# ], +# imports = [".."], +# deps = [ +# requirement("numpy"), +# requirement("pandas"), +# requirement("pytz"), +# requirement("python-dateutil"), +# requirement("six"), +# ], +# ) -py_test( - name = "numerics_test", - size = "small", - srcs = ["test/numerics_test.py"], - deps = [":numerics"], -) +# py_test( +# name = "numerics_test", +# size = "small", +# srcs = ["test/numerics_test.py"], +# deps = [":numerics"], +# ) diff --git a/examples/python/simple/BUILD b/examples/python/simple/BUILD index 321745e..04a0361 100644 --- a/examples/python/simple/BUILD +++ b/examples/python/simple/BUILD @@ -4,12 +4,12 @@ py_binary( deps = ["//examples/python/simple/jpm"], ) -py_image( - name = "main_docker", - srcs = ["main.py"], - main = "main.py", - deps = [":main"], -) +# py_image( +# name = "main_docker", +# srcs = ["main.py"], +# main = "main.py", +# deps = [":main"], +# ) filegroup( name = "srcs", diff --git a/tools/build_rules/prelude_bazel b/tools/build_rules/prelude_bazel index a06617a..f524483 100644 --- a/tools/build_rules/prelude_bazel +++ b/tools/build_rules/prelude_bazel @@ -1,15 +1,15 @@ load("@io_bazel_rules_scala//scala:scala.bzl", "scala_binary", "scala_library", "scala_test", "scala_repl") -load("@io_bazel_rules_docker//container:container.bzl", - "container_image", - ) +# load("@io_bazel_rules_docker//container:container.bzl", +# "container_image", +# ) load("@io_bazel_rules_docker//python:image.bzl", "py_image") load("@io_bazel_rules_docker//scala:image.bzl", "scala_image") # External python requirements -load("@my_python_deps//:requirements.bzl", "requirement") +# load("@my_python_deps//:requirements.bzl", "requirement") load( "@rules_python//python:python.bzl", "py_binary", "py_library", "py_test", @@ -21,4 +21,4 @@ load( load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test", "go_source", "go_library") -load("@io_bazel_rules_docker//go:image.bzl", "go_image") +# load("@io_bazel_rules_docker//go:image.bzl", "go_image") diff --git a/tracing/client/BUILD b/tracing/client/BUILD index 7cc0ac6..d8ee736 100644 --- a/tracing/client/BUILD +++ b/tracing/client/BUILD @@ -6,13 +6,13 @@ go_binary( visibility = ["//visibility:public"], ) -go_image( - name = "test_client_image", - embed = [":client_lib"], - goarch = "amd64", - goos = "linux", - pure = "on", -) +# go_image( +# name = "test_client_image", +# embed = [":client_lib"], +# goarch = "amd64", +# goos = "linux", +# pure = "on", +# ) filegroup( name = "srcs", diff --git a/tracing/envoyproxy/envoy.bzl b/tracing/envoyproxy/envoy.bzl index 7847420..3ec17f2 100644 --- a/tracing/envoyproxy/envoy.bzl +++ b/tracing/envoyproxy/envoy.bzl @@ -3,11 +3,12 @@ load("@io_bazel_rules_docker//container:container.bzl", ) def envoy_config(name, file, log_level="info"): - container_image( - name = name, - base = "@envoyproxy//image", - files = [file, "start_proxy.sh"], - # This is fairly delicate, it's copied from https://github.com/envoyproxy/envoy/blob/master/ci/Dockerfile-envoy-image - cmd = "/start_proxy.sh %s %s %s" % (name, file, log_level), - visibility = ["//visibility:public"], - ) + pass + # container_image( + # name = name, + # base = "@envoyproxy//image", + # files = [file, "start_proxy.sh"], + # # This is fairly delicate, it's copied from https://github.com/envoyproxy/envoy/blob/master/ci/Dockerfile-envoy-image + # cmd = "/start_proxy.sh %s %s %s" % (name, file, log_level), + # visibility = ["//visibility:public"], + # ) diff --git a/tracing/server/BUILD b/tracing/server/BUILD index 4b1d8ad..1c103ca 100644 --- a/tracing/server/BUILD +++ b/tracing/server/BUILD @@ -6,13 +6,13 @@ go_binary( visibility = ["//visibility:public"], ) -go_image( - name = "flaky_image", - embed = [":server_lib"], - goarch = "amd64", - goos = "linux", - pure = "on", -) +# go_image( +# name = "flaky_image", +# embed = [":server_lib"], +# goarch = "amd64", +# goos = "linux", +# pure = "on", +# ) filegroup( name = "srcs",