Skip to content

Commit

Permalink
Feature: Micronaut Support (#7)
Browse files Browse the repository at this point in the history
* Feature: Micronaut Support

This changeset adds basic initial support for Micronaut, with new
rule macros which inject dependencies, and support for a basic
testbed which works.

Changes so far:
- [x] Add Micronaut dependencies
- [x] Add rule macros for Micronaut libs/apps/etc.
- [x] Add a little testbed which executes controllers
  - [x] Add tests for Kotlin and Java
  - [x] Invoke Micronaut from a browser test
    - [x] From Java
    - [x] From Kotlin (this required a patch at
          bazelbuild/rules_webtesting#409)
- [x] Ability to opt-out of Micronaut dependencies

* Activate RBC locally and in CI

* Spawn locally in CI

* Use file-based service key in CI

* Add Redis dependency and CI support

* Add cache support back to CI

* Remove github cache: remote caching is working

* Update Skylib to latest

* Add Stardoc dependency

* Major build refactors, initial support for Starlark docs
  • Loading branch information
sgammon authored Jan 28, 2020
1 parent f8f8abf commit 847e2f9
Show file tree
Hide file tree
Showing 36 changed files with 3,135 additions and 120 deletions.
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ build --watchfs
build --symlink_prefix=dist/
build --workspace_status_command=./tools/bazel_stamp_vars.sh

build:ci --spawn_strategy=local

build:dev --spawn_strategy=local
build:dev --strategy=J2cl=worker
build:dev --strategy=Closure=worker
Expand Down
22 changes: 8 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:

env:
BAZELISK_VERSION: v1.2.1
BUILD_TARGETS: //java/... //js/... //proto/...
JAVA_TEST_TARGETS: //javatests/...

jobs:
build:
Expand All @@ -15,20 +13,14 @@ jobs:
strategy:
matrix:
os: [["Ubuntu", "ubuntu-latest", "linux-amd64"], ["macOS Catalina", "macos-latest", "darwin-amd64"]]
bazel: ["1.0.0", "2.0.0"]
bazel: ["2.0.0", "1.0.0"]

runs-on: ${{ matrix.os[1] }}

steps:
- name: Checkout Sources
uses: actions/checkout@v1

- name: Mount Cache
uses: actions/cache@v1
with:
path: "/home/runner/.cache/bazel"
key: bazel-${{ matrix.bazel }}-${{ matrix.os[2] }}

- name: Install Bazelisk
run: |
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_VERSION}/bazelisk-${{ matrix.os[2] }}"
Expand All @@ -42,11 +34,13 @@ jobs:
- name: Build & Test
run: |
"${GITHUB_WORKSPACE}/bin/bazelisk" build ${BUILD_TARGETS}
- name: Testsuite (Java)
run: |
"${GITHUB_WORKSPACE}/bin/bazelisk" test ${JAVA_TEST_TARGETS}
echo "$SERVICE_KEY" > service-key.json
export
make build BAZELISK="${GITHUB_WORKSPACE}/bin/bazelisk" CI=yes CACHE=yes
make test BAZELISK="${GITHUB_WORKSPACE}/bin/bazelisk" CI=yes CACHE=yes
env:
SERVICE_KEY: ${{ secrets.GOOGLE_CREDENTIALS }}
GOOGLE_APPLICATION_CREDENTIALS: service-key.json

docs:
name: "Documentation"
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
path = vendor/google/protobuf
url = [email protected]:protocolbuffers/protobuf.git
shallow = true
ignore = dirty
[submodule "J2CL"]
path = vendor/bazel/j2cl
url = [email protected]:sgammon/j2cl.git
Expand All @@ -12,3 +13,6 @@
path = vendor/bazel/rules_graal
url = [email protected]:sgammon/rules_graal.git
branch = feature/ee
[submodule "rules_webtesting"]
path = vendor/bazel/rules_webtesting
url = [email protected]:sgammon/rules_webtesting.git
2 changes: 2 additions & 0 deletions .ijwb/.bazelproject
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ directories:
javatests
tools
types
style
.github
node_modules

targets:
//proto/...
//java/...
//js/...
//style/...
//javatests/...
5 changes: 5 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ alias(
actual = "//defs/toolchain:java",
)

alias(
name = "docs",
actual = "//defs:gust-docs",
)

12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
##

CI ?= no
CACHE ?= no
CACHE ?= yes
REMOTE ?= no
VERBOSE ?= no
STRICT ?= no
Expand All @@ -13,11 +13,11 @@ PROJECT ?= bloom-sandbox
RBE_INSTANCE ?= default_instance
CACHE_KEY ?= GustBuild

TARGETS ?= //java/... //proto/... //js/...
TARGETS ?= //java/... //proto/... //js/... //style/...
TESTS ?= //javatests/...

TAG ?= --config=dev
TEST_ARGS ?= --combined_report=lcov
TEST_ARGS ?= --test_output=errors
BUILD_ARGS ?=

BAZELISK ?= $(shell which bazelisk)
Expand Down Expand Up @@ -81,6 +81,10 @@ forceclean: distclean ## Clean everything, and sanitize the codebase (DANGEROUS
test: ## Run all framework testsuites.
$(BAZELISK) $(BAZELISK_ARGS) $(TEST_COMMAND) $(TAG) $(BASE_ARGS) $(TEST_ARGS) $(TESTS)

docs: ## Build documentation for the framework.
@echo "Building GUST docs..."
$(BAZELISK) $(BAZELISK_ARGS) build $(TAG) $(BASE_ARGS) //:docs

help: ## Show this help text.
$(info GUST Framework Tools:)
@grep -E '^[a-z1-9A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Expand All @@ -91,7 +95,7 @@ devtools: ## Install local development dependencies.

update-deps: ## Re-seal and update all dependencies.
@echo "Updating devtools..."
git submodule update --remote --init --recursive
git submodule update --remote --init
@echo "Re-pinning Maven dependencies..."
$(BAZELISK) $(BAZELISK_ARGS) run @unpinned_maven//:pin

Expand Down
12 changes: 9 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ container_repositories()
container_deps()
_java_image_repos()

## Elemental2
load("@com_google_elemental2//build_defs:workspace.bzl", "setup_elemental2_workspace")
setup_elemental2_workspace()
## JS Interop
load("@com_google_jsinterop_generator//build_defs:rules.bzl", "setup_jsinterop_generator_workspace")
load("@com_google_jsinterop_generator//build_defs:repository.bzl", "load_jsinterop_generator_repo_deps")
load_jsinterop_generator_repo_deps()
setup_jsinterop_generator_workspace()

## Closure
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
Expand Down Expand Up @@ -145,3 +147,7 @@ browser_repositories(
load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")
rbe_autoconfig(name = "rbe_default")

## Stardoc
load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories")
stardoc_repositories()

32 changes: 32 additions & 0 deletions defs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
package(
default_visibility = ["//visibility:public"],
)

load(
"@io_bazel_stardoc//stardoc:stardoc.bzl",
"stardoc",
)


stardoc(
name = "gust-docs",
input = "docs.bzl",
out = "docs.md",
symbol_names = [
# Frontend: JS
"js_test",
"js_module",
"js_app",

# Backend: JDK (Java/Kotlin)
"jdk_test",
"jdk_library",
"jdk_binary",

# Backend: Micronaut
"micronaut_test",
"micronaut_library",
"micronaut_application",

# Tools: Protos
"proto",
"proto_module",
],
)
18 changes: 13 additions & 5 deletions defs/build.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ DEPS = {
"bazel_skylib": {
"type": "github",
"repo": "bazelbuild/bazel-skylib",
"target": "327d61b5eaa15c11a868a1f7f3f97cdf07d31c58",
"seal": "4542fed7aafdda95ee356dcb6bb5cc74cc6e5da1e54344ab206e550335804264"},
"target": "4b25373d12887f5add565197c4a163e9f1d9b716",
"seal": "67bd836ea57bc80e70473c1f840048a4f7cffc9b1530b05c81eb3e85de60f06f"},

# Bazel: Stardoc
"io_bazel_stardoc": {
"type": "github",
"repo": "bazelbuild/stardoc",
"target": "f13e3cac7022bd8bdd32233d1dae95a56df01a51",
"seal": "2dc75b384cf5cf5306aa1f6530b6e629f4547182d2203cfe8196d01ee4c6c23c"},

# Bazel: Gazelle
"bazel_gazelle": {
Expand Down Expand Up @@ -97,9 +104,10 @@ DEPS = {
# Rules: Web Testing
"io_bazel_rules_webtesting": {
"type": "github",
"repo": "bazelbuild/rules_webtesting",
"target": "528c49b5be3bca7b835f8c42ccf326f882e825e9",
"seal": "c017dfe15e60a3f7e3a774484fee8d0573aed6e0fe304bac9aa5b9e5eef36368"},
"repo": "sgammon/rules_webtesting",
"target": "0a1cbf2c5bb878eb2ccbc304342b6a3619ba6e7d",
"seal": "01a8fd568b26dff2c8afd68a673890c38d2ea5324d2259580106e7b8ad3f8e95",
"local": "/workspace/GUST/vendor/bazel/rules_webtesting"},

# Rules: SCSS/SASS
"rules_sass": {
Expand Down
27 changes: 27 additions & 0 deletions defs/docs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

## -- Doc Targets

load(
"//defs/toolchain:frontend.bzl",
"js_test",
"js_module",
"js_app",
)

load(
"//defs/toolchain:backend.bzl",
"jdk_test",
"jdk_binary",
"jdk_library",
"micronaut_test",
"micronaut_library",
"micronaut_application",
)

load(
"//defs:proto.bzl",
"proto",
"proto_module",
)

# Any symbol loaded here will be added to the docs.
2 changes: 1 addition & 1 deletion defs/proto.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ def _module(name, **kwargs):


proto = _proto
module = _module
proto_module = _module
16 changes: 16 additions & 0 deletions defs/toolchain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ package(
default_visibility = ["//visibility:public"],
)

load(
"@bazel_skylib//:bzl_library.bzl",
"bzl_library",
)


bzl_library(
name = "rules",
srcs = [
"backend.bzl",
"crosslib.bzl",
"deps.bzl",
"frontend.bzl",
],
)


## -- Public Interface -- ##

Expand Down
22 changes: 22 additions & 0 deletions defs/toolchain/backend.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

load(
"//defs/toolchain/java:rules.bzl",
_jdk_binary = "jdk_binary",
_jdk_library = "jdk_library",
_micronaut_library = "micronaut_library",
_micronaut_application = "micronaut_application",
)

load(
"//defs/toolchain/java:testing.bzl",
_jdk_test = "jdk_test",
_micronaut_test = "micronaut_test",
)


jdk_test = _jdk_test
jdk_binary = _jdk_binary
jdk_library = _jdk_library
micronaut_test = _micronaut_test
micronaut_library = _micronaut_library
micronaut_application = _micronaut_application
12 changes: 12 additions & 0 deletions defs/toolchain/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,16 @@ def _closure_path(*path):
return "@io_bazel_rules_closure//closure/library/%s" % genpath


def _maven(path):

""" Computes a Maven dependency path, based on the coordinates
for the artifact. """

return ("@maven//:" + path
.replace(":", "_")
.replace(".", "_")
.replace("-", "_"))


maven = _maven
closure = _closure_path
17 changes: 16 additions & 1 deletion defs/toolchain/java/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ load(
"java_runtime",
)

load(
"@bazel_skylib//:bzl_library.bzl",
"bzl_library",
)


bzl_library(
name = "rules",
srcs = [
"repos.bzl",
"rules.bzl",
"testing.bzl",
],
)


## Java Runtime: `zulu`
## ------------------------
Expand All @@ -17,8 +32,8 @@ java_runtime(
visibility = ["//visibility:private"],
)

## -- Public Interface -- ##

## -- Public Interface -- ##

## Java Runtime
## ------------------------
Expand Down
Loading

0 comments on commit 847e2f9

Please sign in to comment.