Skip to content

Commit

Permalink
Sample App: Todolist (#46)
Browse files Browse the repository at this point in the history
* Sample App: Todolist

This changeset adds a new sample app, which ties together all the
features thus far and adds some new ones to facilitate easy app
development. I'm using this sample to help define the underlying
framework structure, when used with Micronaut/Soy.

The sample is built with unified modelling via Protobuf, and RPC
dispatch via gRPC. The UI is built with Soy, with SSR support via
Soy/Java, and re-hydrated CSR support via Soy/JS (and `idom`).

The app's data backend is powered by Firestore, with objects
mediated for serialization by the framework. This process is also
driven by the protos. Auth is also powered by Firebase, which
enables easy data permissions.

Via the central API definition, the app can automatically generate
an API console, docs, and Open API/Swagger configs. It is also
dispatchable from nearly any platform (via either gRPC or REST).
Endpoints served in this manner support either Protobuf on the wire,
or JSON (when using REST).

Styles are defined in SASS but processed by both GSS and PostCSS,
which enables both (1) tight optimization on a per-browser basis,
and (2) style modularity when serving. The server can also rewrite
styles using a Soy/GSS rewrite map.

The sample additionally demonstrates testing, with coverage (where
supported by the framework, so far).

* Add simple tests for Soy renaming maps

* Cleanup cloudbuild targets

* Switch tests off in GCB

* Cleanup and testing for existing core.backend logic

* Fix definitions for JS interop

* Early `PageContext` logic and example

- Gather proto and other page context into `SoyContextMediator`
- Override Micronaut Views/Views Soy deps
  (see micronaut-projects/micronaut-views#34)
- Update Soy lib and jssrc deps
- Fix CSP error specified by default in `application.yml`
- Serve HTML from controller

* Refactor Java dependencies and rules

- Add better exclusions for Google coordinates
- Add source dependencies for Protobuf and gRPC
- Upgrade/conform dependency tree to Protobuf/gRPC latest

* Seal Java dependencies

* Further gRPC support in Todolist

- Add support for reflection service
- Make service / interceptor simple passthroughs

* New todolist port arrangement

- Run app on :8081
- Run API on :8082

* Add Todolist sample to cloudbuild config

* Eliminate remote build in GCB

* Adjust build stamp to fallback to COMMIT_SHA variable

* Apply fix for image tag in GCB

* Add K8S rules dependency

* Further adjustments to GCB config

* Fix misplaced deploy jar target

* Pull and tag latest todolist image on build

* Add initial ambassador config

* Remove failing build artifact upload in GCB

* Add initial test for PageContext

* Improvements to page context integration

- Add extended `SoyProtoContextMediator` interface
- Add efficient empty context use
- Cover `PageContext` with tests

* Adjust coverage reporting

* Refactor `HomeController` to use new `AppController`

- Add `PageContextManager` and factory
- Init `AppController` and `BaseController`
- Adjust Bazel flags to be normalized

* Cleanup and simplify PageContext/PageContextManager

- Remove embedded PageContextManager.Factory
- Clean up DI flow
- Fix issue injecting HTTP request

* Initial Todolist infrastructure configs

- Add full suite of K8S configs, scoped to `todolist` namespace
- Add customized Envoy configuration and image

* Toolchain support for Docker, Kubernetes and packaging

- Add macros for generic Docker images
- Add macros for Kubernetes configs
- Add macros for packaging

* Pull in Envoy base image, setup K9 defaults

* Add rules_pkg dependency

* Add yarn run alias for gRPC CLI

* Converge bazelrc and WORKSPACE for Todolist

* Major work on Envoy proxy

* Use manually-built Envoy image, for now

* Fix spacing issue in bazelrc

* Add external LB for testing

* Use fully-qualified service DNS

* Setup devops flow for Envoy and Todolist (including deploy)

- Add deploy routine to GCB (CI will likely fail)
- Enable reflection service (+add logging)
- Tweaks to Envoy config, including healthcheck logging

* Fixes for ingress configuration

* Transition to independent NEGs

* [skip ci] Change to Bazel 2.1.0 in GCB

* Prep version bump -> 1.0.0-alpha2

* Fix incorrect Bazel version in GCB

* Fix prefix for Bazel images in GCB (late steps)

* Pin and build K8S toolchain from source

* Attempt fix for K8S transitive load

* Upgrade K8S > 1.15.9

* Update K8S hash, add dep on infrastructure tools

* Switchup alias for K8S repo infra

* Apply incompatible trip flags to fix K8S in GCB

* Alias K8S repo

* Clean up K8S tools reference

* Add custom builder image for deploy, use it

* Switch up GCB image for 2nd-to-last build step

* Upgrade GCB image -> v1b

* Shift build steps to GCB image

* Add Alpine version of builder image

* Prep CI image for use

* Back to Ubuntu builder, install OpenJDK

* Add git to GCB environment

* Auto-remove packages in builder image

* Upgrade to builder v1d

* Add unzip to build image :eyeroll:

* Version bump for build image -> v1e

* Add regular Python package to GCB

* Version bump for GCB -> v1f

* Upgrade GCB image -> v1g (add symlink to gcloud)

* Fix Python rules in CI

* Add todolist internal gateway

* Fix pip issues in CI

* Remove external LB for Todolist

* Always use latest GCB builder

* Cleanup Python deps, add pypandoc to build env

* Support for ibazel-based development flow

- Call ibazel from Makefile when `m dev` is used
- Tweak flags and invocation to work
- Flush out issue with Soy render context

* Update Micronaut/Soy packages with context fix

* Fix access to ADC

* Add ibazel_live_reload to Java app targets

* Support Java-side live reload

* Re-enable test reporting, add Travis env vars

* Stop upgrading deps in CI image

* Add Makefile task to build builder image

* Major README and licensing cleanup/improvements

* Refactor app boot logic

* Cleanup after refactor, fix various issues reported by Codacy

* Cleanup startup exception flow

* Add GraphQL to readme

* Root folder cleanup

* Add new badges to README

* Tweaks to README

* Remove .develop aliases

* Adjust coverage config to be lenient until it settles

* Remove Makefile aliases

* Fix Makefile command list in README

* Small nits

* Fix spaces-in-tags in Soy templates

* Add interface to set page title

* Remove old page root

* Install logback as the underlying log implementation

* Add sugar for page context, title, assets

- Add ability to change page title, inject stylesheets/scripts
- Add ability to easily generate trusted URI protos
- Rename SoyProtoContextMediator > PageRender
- Make PageContextManager usable as a PageRender
- Use new fluent interface in HomeController

* 🚀 Fix Soy render with injected context

- Working injected context. Yay!
- Logback is working too
- Cleaned up page context manager with improved log messages

* Fix render bugs on homepage

* Remove empty table in README

* Feature: Model Layer (#65)

* Feature: Model Adapters

This changeset introduces backend logic to deal with business data
(i.e. *schema-driven models*). As part of this work, I'm also
building out underlying stuff needed for that, including managed
transport, generic model adapters/codecs, and so on.

Related issues:
- App Framework (#27)
- MVP Functionality Matrix (#43)

In this PR:
- [x] **Backend logic: Models**
  - [x] Interfaces for persistence managers, drivers, codecs
  - [x] Serializer and deserializer interfaces
  - [x] Cache-related manager interfaces
  - [x] Container for encoded models
  - [x] Codec for encoding models in proto formats
  - [x] Encoded (generic) model
    - [x] Serialization to `CollapsedModel`/`OutputStream`/`bytes`
    - [x] Deserialization from `InputStream`/`bytes`
  - [x] Interface support for simple CRUD operations
    - [x] `retrieve`: Fetch a structured record from storage.
    - [x] `persist`: Write a structured record to storage.
    - [x] `delete`: Erase a structured record from storage.
  - [x] Cache driver support for basic operations
    - [x] `put`: Write a model to a cache
    - [x] `fetch`: Retrieve a model from the cache
    - [x] `evict`: Evict one or more cached models, by key
    - [x] `flush`: Drop all keys from the cache
- [x] **Backend logic: Transport**
  - [x] Simple `TransportManager` interface
  - [x] Managed gRPC channels for Google APIs
    - [x] `GoogleTransportManager`: channel management
    - [x] Ability to refresh channels?
  - [x] Service support list
    - [x] Firestore
- [x] **Backend logic: Built-in Drivers**
  - [x] In-memory Adapter (reference)
    - [x] Initial `InmemoryManager` implementation
    - [x] Initial `InmemoryDriver` implementation
    - [x] Initial `InmemoryCache` implementation
- [x] Test suite
  - [x] Simple model interactions
  - [x] Update/create methods
  - [x] Delete methods
  - [x] Cache operations
  • Loading branch information
Sam Gammon authored Mar 10, 2020
1 parent 4ba341b commit 131f3a8
Show file tree
Hide file tree
Showing 327 changed files with 33,670 additions and 3,037 deletions.
16 changes: 0 additions & 16 deletions .bazelci/presubmit.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .bazelproject
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ workspace_type: java
java_language_level: 11

targets:
//proto/...
//gust/...
//java/...
//js/...
//style/...
Expand Down
99 changes: 13 additions & 86 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,89 +1,16 @@

##
# Base Settings
# Copyright © 2020, The Gust Framework Authors. All rights reserved.
#
# The Gust/Elide framework and tools, and all associated source or object computer code, except where otherwise noted,
# are licensed under the Zero Prosperity license, which is enclosed in this repository, in the file LICENSE.txt. Use of
# this code in object or source form requires and implies consent and agreement to that license in principle and
# practice. Source or object code not listing this header, or unless specified otherwise, remain the property of
# Elide LLC and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to
# Elide LLC and its suppliers and may be covered by U.S. and Foreign Patents, or patents in process, and are protected
# by trade secret and copyright law. Dissemination of this information, or reproduction of this material, in any form,
# is strictly forbidden except in adherence with assigned license requirements.
##

common --experimental_allow_incremental_repository_updates

build --watchfs
build --symlink_prefix=dist/
build --nolegacy_external_runfiles
build --disk_cache=~/.cache/bazel-disk-cache
build --incompatible_strict_action_env
build --javacopt="-encoding UTF-8"
build --strict_java_deps=strict
build --use_ijars
build --interface_shared_objects
build --java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
build --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
build --workspace_status_command=./tools/bazel_stamp_vars.sh
build --embed_label=alpha
build --define project=bloom-sandbox

run --incompatible_strict_action_env
run --workspace_status_command=./tools/bazel_stamp_vars.sh

build:ci --spawn_strategy=local

build:release --compilation_mode=opt

build:dev --compilation_mode=dbg
build:dev --spawn_strategy=local
build:dev --strategy=J2cl=worker
build:dev --strategy=Closure=worker
build:dev --strategy=TypeScriptCompile=worker
build:dev --experimental_persistent_javac
build:dev --define=jdk=zulu
build:dev --define=ZULUBASE=/Library/Java/JavaVirtualMachines/zulu-12.jdk/Contents/Home
build:dev --javabase=//defs/toolchain/java:java_runtime

query --output=label_kind

# This .bazelrc file contains all of the flags required for the provided
# toolchain with Remote Build Execution.
# Note your WORKSPACE must contain an rbe_autoconfig target with
# name="rbe_default" to use these flags as-is.
build:remote --jobs=5

# Platform flags:
# The toolchain container used for execution is defined in the target indicated
# by "extra_execution_platforms", "host_platform" and "platforms".
# More about platforms: https://docs.bazel.build/versions/master/platforms.html
build:remote --extra_toolchains=@rbe_default//config:cc-toolchain
build:remote --extra_execution_platforms=@rbe_default//config:platform
build:remote --host_platform=@rbe_default//config:platform
build:remote --platforms=@rbe_default//config:platform
build:remote --host_javabase=@rbe_default//java:jdk
build:remote --javabase=@rbe_default//java:jdk
build:remote --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
build:remote --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
build:remote --crosstool_top=@rbe_default//cc:toolchain
build:remote --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
build:remote --spawn_strategy=remote

# Starting with Bazel 0.27.0 strategies do not need to be explicitly
# defined. See https://github.com/bazelbuild/bazel/issues/7480
build:remote --define=EXECUTOR=remote

# Enable remote execution so actions are performed on the remote systems.
build:remote --remote_executor=grpcs://remotebuildexecution.googleapis.com

# Enforce stricter environment rules, which eliminates some non-hermetic
# behavior and therefore improves both the remote cache hit rate and the
# correctness and repeatability of the build.
build:remote --incompatible_strict_action_env=true

# Set a higher timeout value, just in case.
build:remote --remote_timeout=3600

# Enable authentication. This will pick up application default credentials by
# default. You can use --google_credentials=some_file.json to use a service
# account credential instead.
build:remote --google_default_credentials=true

test --instrumentation_filter=//...
test --instrument_test_targets
coverage --instrument_test_targets

try-import %workspace%/.bazelrc.user

# load bazelrc from the legacy location
# as recommended in https://github.com/bazelbuild/bazel/issues/6319
import %workspace%/tools/bazel.rc
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.1
2.1.0
20 changes: 20 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
##
# Copyright © 2020, The Gust Framework Authors. All rights reserved.
#
# The Gust/Elide framework and tools, and all associated source or object computer code, except where otherwise noted,
# are licensed under the Zero Prosperity license, which is enclosed in this repository, in the file LICENSE.txt. Use of
# this code in object or source form requires and implies consent and agreement to that license in principle and
# practice. Source or object code not listing this header, or unless specified otherwise, remain the property of
# Elide LLC and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to
# Elide LLC and its suppliers and may be covered by U.S. and Foreign Patents, or patents in process, and are protected
# by trade secret and copyright law. Dissemination of this information, or reproduction of this material, in any form,
# is strictly forbidden except in adherence with assigned license requirements.
##

steps:
- command: "make build CI=yes"
label: ":bazel: Build: Framework"
Expand All @@ -14,6 +27,9 @@ steps:
- command: "make build CI=yes TARGETS='//samples/rest_mvc/java:MicronautMVCSample-native-bin' && make build CI=yes TARGETS='//samples/soy_ssr/src:MicronautSSRSample-native-bin'"
label: ":java: Build: Native Binaries"
depends_on: framework-build
key: native-build
soft_fail:
- exit_status: 2

- wait

Expand All @@ -22,6 +38,9 @@ steps:

- command: "make build samples CI=yes"
label: ":gcloud: Publish: Images"
depends_on: native-build
soft_fail:
- exit_status: 2

- command: "echo 'registry=https://npm.pkg.github.com/sgammon' > .npmrc && npm publish"
label: ":octocat: + :npm: Staging: NPM"
Expand Down Expand Up @@ -53,4 +72,5 @@ steps:

- command: "make release-images CI=yes"
label: ":docker: Release: Docker"
depends_on: native-build
if: build.tag != null
111 changes: 111 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@

version: "2"

checks:
argument-count:
config:
threshold: 10

complex-logic:
config:
threshold: 20

file-lines:
config:
threshold: 2000

method-complexity:
config:
threshold: 20

method-count:
config:
threshold: 30

method-lines:
config:
threshold: 100

return-statements:
config:
threshold: 5

plugins:
bandit:
enabled: true

checkstyle:
enabled: true

csslint:
enabled: true

editorconfig:
enabled: true

eslint:
enabled: true

fixme:
enabled: true

gofmt:
enabled: true

golint:
enabled: true

govet:
enabled: true

markdownlint:
enabled: true

nodesecurity:
enabled: true

pep8:
enabled: true

pmd:
enabled: true

radon:
enabled: true

sass-lint:
enabled: true

scss-lint:
enabled: true

sonar-java:
enabled: true

sonar-python:
enabled: true

stylelint:
enabled: true

swiftlint:
enabled: true

tailor:
enabled: false

tslint:
enabled: true

exclude_patterns:
- "config/"
- "dist/"
- "**/node_modules/"
- "**/test/"
- "**/tests/"
- "**/javatests/"
- "**/jstests/"
- "**/vendor/"
- "**/*_test.go"
- "**/*.d.ts"

1 change: 0 additions & 1 deletion .develop/BUILD.bazel

This file was deleted.

1 change: 0 additions & 1 deletion .develop/LICENSES.txt

This file was deleted.

1 change: 0 additions & 1 deletion .develop/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion .develop/WORKSPACE

This file was deleted.

1 change: 0 additions & 1 deletion .develop/bazelrc

This file was deleted.

1 change: 0 additions & 1 deletion .develop/package.json

This file was deleted.

6 changes: 6 additions & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git/modules
node_modules/
dist/
build/
vendor/
#!include:.gitignore
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.* @sgammon
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.develop/
.gradle
build/
node_modules/
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@
[submodule "api_common"]
path = vendor/google/api-common
url = git@github.com:googleapis/api-common-protos.git
[submodule "safe_html_types"]
path = vendor/google/safe-html-types
url = git@github.com:google/safe-html-types.git
[submodule "bazel_common"]
path = vendor/bazel/common
url = git@github.com:sgammon/bazel-common.git
7 changes: 5 additions & 2 deletions .ijwb/.bazelproject
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import .bazelproject

build_flags:
--config=dev
--define=todolist_release_tag=latest

directories:
defs
external
js
java
proto
gust
tests
jstests
javatests
Expand All @@ -20,10 +21,12 @@ directories:
.develop
.buildkite
-node_modules
-dist
-build

targets:
//samples/...
//proto/...
//gust/...
//java/...
//js/...
//style/...
Expand Down
13 changes: 13 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
##
# Copyright © 2020, The Gust Framework Authors. All rights reserved.
#
# The Gust/Elide framework and tools, and all associated source or object computer code, except where otherwise noted,
# are licensed under the Zero Prosperity license, which is enclosed in this repository, in the file LICENSE.txt. Use of
# this code in object or source form requires and implies consent and agreement to that license in principle and
# practice. Source or object code not listing this header, or unless specified otherwise, remain the property of
# Elide LLC and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to
# Elide LLC and its suppliers and may be covered by U.S. and Foreign Patents, or patents in process, and are protected
# by trade secret and copyright law. Dissemination of this information, or reproduction of this material, in any form,
# is strictly forbidden except in adherence with assigned license requirements.
##

package(
default_visibility = ["//visibility:public"],
)
Expand Down
Loading

0 comments on commit 131f3a8

Please sign in to comment.