Skip to content

Commit

Permalink
Seal v1 (stable) (#880)
Browse files Browse the repository at this point in the history
* Feature: Support for Cloud Spanner

This changeset introduces support for Google Cloud Spanner in the
Elide model layer and ORM. Basic support for reading, writing,
transactions, etc., are all planned. This is pretty easy, obviously,
since there is already a Firestore adapter to work from.

Fixes and closes sgammon/elide#856.

* Tune bazel.rc and Makefile configs

* Tweaks to build flow

* Disable labs in CI

* Promote strict_proto_deps / strict_system_includes

* Whoops, fix labs state

* Converge IntelliJ flags with Makefile

* Add DDL-based Spanner table generator

- Generate compliant DDL statements for creating Spanner tables
  from proto models
- Add ability to stub/mock `FieldPointer` objects

* Add concept of field size for Spanner columns

* Significantly more driver testing

- Add `TypeBuffet` to test conversion of different types
- Add tests for `SpannerUtil`
- Add initial tests for Spanner DDL generator
- Uncomment more tests from `GenericPersistenceDriverTests`

* Fixes for TypeScript-related tests

* Further model adapter testing tweaks

- Allow test caching (local only)
- Enable other adapter/driver tests

* Converge newer deps

* Re-enable ancillary `rules_closure` tests

- Fix CSS testing bugs
- Re-enable style tests
- Add suite targets for DOM/style tests

* Enable trace logging in model adapter objects during tests

* Refactor generic driver tests to allow opt-out pattern

- Allow drivers to opt-out of tests they don't yet support
- Enable all tests across the board

* Enable more logging targets in testing

* Add specialized Spanner tests to regular backend suite

- Add `SpannerDDLTest`
- Add `SpannerUtilTest`

* Disallow transport config construction

* Implement deletes in Spanner

- Implement singular delete method
- Enable standard driver `delete()` tests

* Implement `FieldMask` enforcement in Spanner

- Enforce `FieldMask` settings for fetched records
- Drop superfluous error checking

* Style and bug fixes from analysis tools

* Wrap `InvalidProtocolBufferException` in `IllegalStateException`

* Refactor error handling for embedded JSON models

* Bugfixes for Spanner DDL generator

- Fix bug with `ARRAY` fields missing inner types
- Add sensible default for `ENUM` fields implemented as `STRING`

* Better testing for DDL statements, fixes for `BYTES` fields

- Enable column sizes for `BYTES` fields
- Transition long string comparisons to Truth assertions

* Hook tests into the new DDL generator

- Generate tables for emulated testing
- Add method alias to generate DDL statements just from a model
  instance (with default settings)

* Drop branch coverage until logging settings don't bork it

* Update Javadoc

* Exclude docs/tests from CodeClimate

Create CNAME

Set theme jekyll-theme-cayman

* Add missing package-info in gust/backend/annotations

* Update javadoc

* Use remote 'sleek' Jekyll theme

* Drop empty method comment

* Further CodeClimate config tweaks

* Fix duplicate exclude_patterns in CodeClimate config

* [skip-ci] License header updates

* Drop docs from IDE project

* Refactor `DatabaseManager` to bind adapter/driver

- Bind adapter and driver together, that was the OG point
- Add `Closeable`/`AutoCloseable` support to `SpannerManager`
- Add full test coverage to `SpannerManager`
- Add shared run profile for debuggable Bazel testsuite

* Refresh docs

* Don't remove docroot when cleaning docs

* Disallow internal construction of `SpannerManagerSingleton`

* Downgrade to Micronaut v2.5.4

* Feature: 'suspend_debug' when running apps

* Support for `TIMESTAMP` and `DATE` types in Spanner

- Support generating DDL for temporal column types
- Codec support for converting between Spanner `DATE` and
  `com.google.type.Date`
- Codec support for converting between Spanner `TIMESTAMP`
  and `com.google.protobuf.Timestamp`

* Ungate serialization of `TIMESTAMP` and `DATE` types

- Drop exceptions
- Drop TODOs
- Enable serialization of `TIMESTAMP` types from PB timestamps
- Enable serialization of `DATE` types from PB common dates

* Support properly encoding/decoding ENUMs in Spanner

* Fix repeated field error in Spanner codec

* Add dedicated manager spawn route with settings control

The Spanner manager needs a way to spawn drivers with custom
settings. It has a way to now.

* Add ability to acquire Spanner client from manager

* Add granular configuration to `SpannerManager`

- Add ability to control executor
- Add ability to control cache
- Add ability to control base spanner options
- Add ability to control main driver options

* Add new Spanner tests to regular suite

* Fix bug with key column names

* Enforce singular KEY field state

* Converge tests with new ID behavior

* Resolve same key bug for generated DDL

* Add enforcement for ID column types

* Fix ID issues with default Spanner field sets

* Fix issue with Integer vs. Long decoding in Spanner

* Allow public acquisition of InMemoryCache instances

* Provide 'resolveColumnName' alias with no settings

* Open up 'SpannerStructDeserializer#forModel

* Expose better streaming support for calculating column fields

- Allow access to underlying field stream
- Pair fields to corresponding column names
- Maintain external API

* Update docs

* Fix missing license header

* Fix issues with ID presence on returned models

- Add tests to enforce ID presence on models returned via adapter
  fetch interfaces
- Fix related bugs on Spanner adapter

* [p0] Fix for debugger_support flag issue

* Fix debug race conditions for JDK app targets

* Better nullchecks for Spanner columns

* Upgrades to Java dependencies

- Upgrade GAX
- Upgrade Micronaut
- Upgrade Google Cloud SDK
- Upgrade Firestore

* Rollback GAX change

* Fixes for various analyzer warnings

* Implement transactional write/delete support

- Set `transactionContext` on mutation options for buffered
  serialization to an active transaction
- Acquire a transaction context via `TransactionManager.begin()`

* Implement codec support for `NUMERIC` columns

Following [Google's advice][1], I've implemented `NUMERIC` types
as proto-strings.

- Add deserializer support for `NUMERIC`s
- Add serializer support for `NUMERIC`s
- Add basic test for schema translation

[1]: https://cloud.google.com/spanner/docs/working-with-numerics

* Update docs

* Implement support for ancillary Spanner annotations

- Add `NONNULL` annotation
- Add basic support for field expressions (including `STORED`)
- Add `commit_update` support

* Rebuild docs

* Apply fixes for runtime jdeps

* Bump BoringSSL/Netty -> '2.0.40.Final'

* Netty/Micronaut version bumps

* Upgrade rules_closure and protobuf -> 3.17.3

* Re-pin maven deps

* Match gRPC's versions for Netty and BoringSSL

* Re-upgrade Netty/TCNative

* Force shaded version of Netty for gRPC

* Add remote Bazel settings profile

* Enable control of naming for Java image targets

* Wire up container-based dev

* General fixes for Bazel within dev containers

* Dev container env adjustments

* Add missing continuation slash

* Add container init and post-attach commands

* Add creds to codespaces image (via secrets)

* Don't require env for dev container

* Add default set of VSC extensions

* Fix path access to ibazel/bazelisk in devcontainer init

* Further adjustments to devcontainer env

* Drop initialize command from devcontainer

* Move container signal to env

* Drop initialize command

* Set container user to 'dev'

* Add container-init script

* Tweaks for init script safety

* Force version v1d for codespaces

* Upgrade devcontainer -> v1e

* Improvements to container init script

* Force container version v1f

* Fixes for project-wide RBE settings

* Upgrade container -> v1g

* Upgrade to latest Codespaces container

* Upgrade Bazel -> 4.2.0

* Apply lib overrides for Netty and Guava-JDK5

* Upgrade Bazel -> 4.2.1

* Add Micronaut Management dep

* Update Spanner -> 6.13.0

* Upgrade GAX -> 2.5.0

* Add renovate.json

* Switch Nonnull to NonNull (Micronaut) in AssetManager

* Update Maven pins

* Feature: Spanner JSON Columns

This changeset adds support for Spanner's new native JSON columns,
which essentially act as strings but with enforced JSON-friendly
semantics which improve queryability.

Spanner's JSON fields differ from strings in the following ways:
- Keys are sorted lexicographically
- Whitespace is not preserved
- Duplicate keys are elided
- Numeric and other primitive types are interpreted natively
- JSON `null` is treated as SQL `NON NULL`

These columns have advantages for various kinds of JSON document
storage based in Spanner. See docs here:

- [Spanner: Working with JSON](https://cloud.google.com/spanner/docs/working-with-json)
- [Spanner/J: Driver support PR](googleapis/java-spanner#872)

Changes enclosed:
- Add support to DDL generator for JSON columns
- Driver-side experimental flag to enable/disable
- Compliant with existing testsuite (fallback to `STRING`)
- Tests for tables with JSON columns
- Tests for DDL generator with JSON columns enabled

* Fix: Default `BOOL` values in Spanner

This changeset adds a fix for sgammon/elide#868, wherein default
`BOOL` column values should be the `false` value, rather than no
value at all. This PR implements the approach described in the
issue, gated behind a driver setting.

Fixes and closes sgammon/elide#868.

* Chore: General Deps Update

This changeset updates some key dependencies that have issued
newer releases since last pin.

- [x] Update GAX -> `2.7.0`
- [x] Update Google Cloud APIs -> `0.163.0`
- [x] Update common protos -> `2.6.0`

* Upgrade gRPC -> `1.42.0`, upgrade Protobuf -> `3.18.1`

* Seal deps

* Restore protobuf/gRPC versions

* Drop unsupported configsets property from Graal binary builds

* Restore protos, gRPC, GAX

* Fixes for deps in rules_closure

* Dependency tweaks (Proto/gRPC upgrade)

* Fix for decoding of enums from Spanner string fields

* Fix nasty Guava dependency alignment bug

* Fixes for `DATE` vs. `TIMESTAMP` types in Spanner

- Fallback to `TIMESTAMP` for `DATE` fields that error (seems to
  be a driver quirk)
- Allow decoding spanner `DATE` fields into standard
  `google.protobuf.Timestamp` types

Co-authored-by: Renovate Bot <bot@renovateapp.com>
  • Loading branch information
Sam Gammon and renovate-bot committed Mar 16, 2022
1 parent a69d644 commit 8c86272
Show file tree
Hide file tree
Showing 586 changed files with 233,079 additions and 6,607 deletions.
8 changes: 8 additions & 0 deletions .bazelproject
Expand Up @@ -22,8 +22,16 @@ targets:
//javatests/...
-//jstests/...

build_flags:
--config=dev
--config=labs
--define=project=elide-ai

ts_config_rules:
//:tsconfig.json
//defs/toolchain/ts:tsconfig-common
//defs/toolchain/ts:tsconfig-node
//defs/toolchain/ts:tsconfig-browser

test_sources:
- */tests/*
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
@@ -1 +1 @@
4.1.0
4.2.1
44 changes: 38 additions & 6 deletions .buildkite/pipeline.yml
Expand Up @@ -13,16 +13,40 @@

steps:
- command: "make build CI=yes QUIET=no"
label: ":bazel: Build: Framework"
key: framework-build
label: ":bazel: Build: Framework (Linux)"
key: framework-build-linux
agents:
"gcp:project-id": "cookies-co"

- command: "make build test report-coverage report-tests CI=yes QUIET=no"
label: ":coverage: Testsuite"
depends_on: framework-build
- command: "make build CI=yes QUIET=no"
label: ":bazel: Build: Framework (macOS)"
key: framework-build-macos
agents:
os_flavor: "macos"

# report-coverage report-tests
- command: "make test report-coverage CI=yes QUIET=no"
label: ":coverage: Testsuite (Linux)"
depends_on: framework-build-linux
env:
CODECOV_TOKEN: "8942c419-eb75-46a4-8f08-abfaadd11bb5"
CC_TEST_REPORTER_ID: "9d5646c30c5e1f267b4a7a6ae4d6aedb22edc797e87845564b812812fff81f3c"
artifact_paths:
- "reports/coverage/index.html"
- "reports/coverage.tar.gz"
- "reports/tests.xml.html"
agents:
"gcp:project-id": "cookies-co"

- command: "make test CI=yes QUIET=no"
label: ":coverage: Testsuite (macOS)"
depends_on: framework-build-macos
artifact_paths:
- "reports/coverage/index.html"
- "reports/coverage.tar.gz"
- "reports/tests.xml.html"
agents:
os_flavor: "macos"

- 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"
Expand All @@ -35,7 +59,14 @@ steps:
- wait

- command: "docker pull us.gcr.io/elide-ai/base/alpine"
label: ":docker: Pull Bases"
label: ":docker: Pull Bases: Alpine"
agents:
"gcp:project-id": "cookies-co"

- command: "docker pull us.gcr.io/elide-ai/base/node"
label: ":docker: Pull Bases: Node"
agents:
"gcp:project-id": "cookies-co"

- command: "make build samples CI=yes"
label: ":gcloud: Publish: Images"
Expand Down Expand Up @@ -76,3 +107,4 @@ steps:
label: ":docker: Release: Docker"
depends_on: native-build
if: build.tag != null

17 changes: 17 additions & 0 deletions .codeclimate.yml
Expand Up @@ -45,6 +45,12 @@ plugins:
config:
file: "tools/checkstyle.xml"
checks:
com.puppycrawl.tools.checkstyle.checks.coding.VariableDeclarationUsageDistanceCheck:
enabled: false
com.puppycrawl.tools.checkstyle.checks.naming.ClassTypeParameterNameCheck:
enabled: false
com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterNameCheck:
enabled: false
com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck:
enabled: false
com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck:
Expand Down Expand Up @@ -123,6 +129,10 @@ plugins:
sonar-java:
enabled: true
checks:
squid:S00107:
enabled: false
squid:S3358:
enabled: false
squid:S3776:
enabled: false
squid:SwitchLastCaseIsDefaultCheck:
Expand Down Expand Up @@ -159,4 +169,11 @@ exclude_patterns:
- "**/vendor/"
- "**/*_test.go"
- "**/*.d.ts"
- "docs/"
- "docs/**.*"
- "tests/"
- "tests/**.*"
- "*tests/**.*"
- "javatests/"
- "jstests/"

12 changes: 12 additions & 0 deletions .devcontainer/Dockerfile
@@ -0,0 +1,12 @@

FROM us-docker.pkg.dev/cookies-eng/public/base/codespaces:v1h

ENV SHELL=zsh \
HOME=/home/dev \
DEVCONTAINER=yes

USER dev
WORKDIR /home/dev

COPY defs/container.bazelrc /home/dev/bazelrc.remote

14 changes: 14 additions & 0 deletions .devcontainer/Dockerfile.gitpod
@@ -0,0 +1,14 @@

FROM us-docker.pkg.dev/cookies-eng/public/base/gitpod:latest

ENV SHELL=zsh \
C6S_CODESPACES_VERSION=v1a \
HOME=/home/gitpod \
DEVCONTAINER=yes

RUN echo "Installing BuildBuddy credentials..." \
&& echo "$BUILDBUDDY_CERT" > /home/dev/buildbuddy-cert.pem \
&& echo "$BUILDBUDDY_KEY" > /home/dev/buildbuddy-key.pem;

COPY defs/container.bazelrc /home/gitpod/.bazelrc

31 changes: 31 additions & 0 deletions .devcontainer/devcontainer.json
@@ -0,0 +1,31 @@
{
"build": {
"dockerfile": "./Dockerfile",
"context": ".."
},
"containerEnv": {
"DEVCONTAINER": "yes",
"HOME": "/home/dev",
"GOOGLE_APPLICATION_CREDENTIALS": "/home/dev/.config/gcloud/application_default_credentials.json"
},
"postCreateCommand": "bash tools/container-init.sh",
"postAttachCommand": "make help",
"containerUser": "dev",
"extensions": [
"BazelBuild.vscode-bazel",
"bufbuild.vscode-buf",
"redhat.java",
"redhat.vscode-commons",
"redhat.vscode-yaml",
"StackBuild.bazel-stack-vscode",
"TeamHub.teamhub",
"VisualStudioExptTeam.vscodeintellicode",
"vscjava.vscode-java-debug",
"vscjava.vscode-java-dependency",
"vscjava.vscode-java-pack",
"vscjava.vscode-java-test",
"vscjava.vscode-maven",
"zhengrenzhe.nyan-cat",
"zxh404.vscode-proto3"
]
}
13 changes: 13 additions & 0 deletions .ijwb/.run/Bazel Testsuite.run.xml
@@ -0,0 +1,13 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Bazel Testsuite" type="BlazeCommandRunConfigurationType" factoryName="Bazel Command">
<blaze-settings handler-id="BlazeCommandGenericRunConfigurationHandlerProvider" kind="java_test" context-element="$PROJECT_DIR$/../javatests/gust/backend/model/ModelMetadataTest.java#testResolveQualifiedName" blaze-command="test">
<blaze-target>//javatests:suite</blaze-target>
<blaze-user-flag>--config=dev</blaze-user-flag>
<blaze-user-flag>--combined_report=lcov</blaze-user-flag>
<blaze-user-flag>--test_output=errors</blaze-user-flag>
</blaze-settings>
<method v="2">
<option name="Blaze.BeforeRunTask" enabled="true" />
</method>
</configuration>
</component>
43 changes: 32 additions & 11 deletions Makefile
Expand Up @@ -35,6 +35,7 @@ ENABLE_REPORTCI ?= yes
JS_COVERAGE_REPORT ?= no
REPORTS ?= reports
CI_REPO ?= sgammon/elide
DEVCONTAINER ?= $(shell echo $$DEVCONTAINER)

SAMPLES ?= //samples/rest_mvc/java:MicronautMVCSample //samples/soy_ssr/src:MicronautSSRSample

Expand All @@ -54,13 +55,12 @@ OUTPATH ?= $(DISTPATH)/out
BINPATH ?= $(DISTPATH)/bin
UNZIP ?= $(shell which unzip)
REVISION ?= $(shell git describe --abbrev=7 --always --tags HEAD)
BASE_VERSION ?= v1b
BASE_VERSION ?= v2a
VERSION ?= $(shell (cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]' | sed 's/version\://g'))
CHROME_COVERAGE ?= $(shell find dist/out/$(OUTPUT_BASE)/bin -name "coverage*.dat" | grep chrome | xargs)
COVERAGE_DATA ?= $(OUTPATH)/_coverage/_coverage_report.dat
COVERAGE_REPORT ?= $(REPORTS)/coverage
COVERAGE_ARGS ?= --function-coverage \
--branch-coverage \
--highlight \
--demangle-cpp \
--show-details \
Expand All @@ -74,7 +74,7 @@ COVERAGE_ARGS ?= --function-coverage \
APP ?=
TARGETS ?= //java/... //gust/... //style/...
LABS_TARGETS ?= //js/...
TESTS ?= //javatests:suite
TESTS ?= //javatests:suite //tests:suite
LABS_TESTS ?= //jstests/...
COVERABLE ?= $(TESTS)

Expand All @@ -84,7 +84,7 @@ TEST_ARGS ?=
else
TEST_ARGS ?= --test_output=errors
endif
TEST_ARGS_WITH_COVERAGE ?= --combined_report=lcov --nocache_test_results
TEST_ARGS_WITH_COVERAGE ?= --combined_report=lcov
BUILD_ARGS ?= --define project=$(PROJECT)

BUILDKEY_PLAINTEXT ?= $(shell pwd)/crypto/build-key.json
Expand Down Expand Up @@ -168,15 +168,29 @@ LN ?= $(shell which ln)
CURL ?= $(shell which curl)
CHMOD ?= $(shell which chmod)
MKDIR ?= $(shell which mkdir)
BAZELISK ?= $(ENV)/bin/bazelisk
GENHTML ?= $(shell which genhtml)
DOCKER ?= $(shell which docker)

ifeq ($(DEVCONTAINER),yes)
BAZELISK ?= $(shell which bazelisk)
IBAZEL ?= $(shell which ibazel)
else
BAZELISK ?= $(ENV)/bin/bazelisk
IBAZEL ?= $(ENV)/bin/ibazel
endif

PYTHON ?= $(shell which python)
VIRTUALENV ?= $(shell which virtualenv)

# Flag: `CI`
ifeq ($(CI),yes)
TAG += --config=ci
else
TAG += --config=dev
ifeq ($(DEVCONTAINER),yes)
TAG += --config=dev --config=labs
else
TAG += --config=dev-local --config=labs
endif
endif

# Flag: `DEBUG`
Expand All @@ -202,7 +216,11 @@ endif

all: devtools build test ## Build and test all framework targets.

ifeq ($(DEVCONTAINER),yes)
build:
else
build: $(ENV) ## Build all framework targets.
endif
$(info Building $(PROJECT_NAME)...)
$(_RULE)$(BAZELISK) $(BAZELISK_ARGS) build $(TAG) $(BASE_ARGS) $(BUILD_ARGS) -- $(TARGETS)

Expand All @@ -218,11 +236,11 @@ clean: clean-docs clean-reports ## Clean ephemeral targets.

clean-docs: ## Clean built documentation.
@echo "Cleaning docs..."
$(_RULE)rm -fr $(POSIX_FLAGS) $(DOCS)
$(_RULE)rm -fr $(POSIX_FLAGS) $(DOCS)/java

clean-reports: ## Clean built reports.
@echo "Cleaning reports..."
$(_RULE) -fr $(POSIX_FLAGS) $(REPORTS)
$(_RULE)rm -fr $(POSIX_FLAGS) $(REPORTS)

bases: ## Build base images and push them.
@echo "Building Alpine base ('$(BASE_VERSION)')..."
Expand Down Expand Up @@ -287,8 +305,7 @@ serve-coverage: ## Serve the current coverage report (must generate first).

report-tests: ## Report test results to Report.CI.
@echo "Scanning for test results..."
$(_RULE)pip install -r tools/requirements.txt
$(_RULE)find dist/out/$(OUTPUT_BASE) -name test.xml | xargs python3 tools/merge_test_results.py reports/tests.xml
$(_RULE)find dist/out/$(OUTPUT_BASE) -name test.xml | xargs $(ENV)/bin/python tools/merge_test_results.py reports/tests.xml
@echo "Generating HTML test report..."
$(_RULE)cd reports && python3 -m junit2htmlreport tests.xml
ifeq ($(ENABLE_REPORTCI),yes)
Expand Down Expand Up @@ -348,6 +365,10 @@ $(ENV):
$(_RULE)$(LN) -s $(ENV)/bazel/ibazel-$(PLATFORM) $(ENV)/bin/ibazel
$(_RULE)$(CHMOD) +x $(ENV)/bazel/bazelisk-$(PLATFORM) $(ENV)/bin/bazelisk $(ENV)/bazel/ibazel-$(PLATFORM) $(ENV)/bin/ibazel
$(_RULE)$(ENV)/bin/bazelisk version
@echo "Creating virtualenv..."
$(_RULE)$(VIRTUALENV) $(ENV)/python --python=$(PYTHON)
$(_RULE)$(LN) -s $(ENV)/python/bin/python3 $(ENV)/bin/python
$(_RULE)$(ENV)/python/bin/pip install -r $(PWD)/tools/requirements.txt
@echo "Build environment ready."

## Crypto
Expand All @@ -366,5 +387,5 @@ decrypt: $(BUILDKEY_PLAINTEXT) ## Decrypt private key material.
@echo "Key material decrypted."


.PHONY: build test help samples release-images update-deps devtools
.PHONY: build test help samples release-images update-deps devtools docs

5 changes: 3 additions & 2 deletions WORKSPACE
Expand Up @@ -91,7 +91,6 @@ java_import(
)



#
# Extensions
#
Expand Down Expand Up @@ -147,7 +146,9 @@ graal_bindist_repository(

## Java Repos/Deps
load("//defs/toolchain/java:repos.bzl", "gust_java_repositories")
gust_java_repositories()
gust_java_repositories(
maven_install_json = "@gust//:maven_install.json",
)

load("@maven//:compat.bzl", "compat_repositories")
compat_repositories()
Expand Down

0 comments on commit 8c86272

Please sign in to comment.