Skip to content

Commit

Permalink
Feature: Testsuite
Browse files Browse the repository at this point in the history
This changeset adds a substantive and useful testsuite, with tests
split based on coverage support and backend/frontend disposition.
Coverage support is included in this changeset (at least for tests
in languages that support it, which, for now, is Java).

Changes so far:
- [x] Refactor and cleanup testsuite
- [x] Move most app targets to samples
- [x] Get unified coverage working for Java
- [x] Change web tests to use Karma
- [x] Begin measuring coverage via Karma
- [ ] Unified coverage support for all languages
  - [x] Java: basic junit testing
  - [ ] JS: Via Karma/Istanbul
  - [ ] Python: unclear so far
  • Loading branch information
sgammon committed Feb 18, 2020
1 parent eb04980 commit 49278cb
Show file tree
Hide file tree
Showing 78 changed files with 1,245 additions and 2,079 deletions.
1 change: 0 additions & 1 deletion .bazelproject
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ ts_config_rules:

test_sources:
- */tests/*
- */test/*
- */javatests/*

additional_languages:
Expand Down
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,7 @@ build:remote --remote_timeout=3600
# account credential instead.
build:remote --google_default_credentials=true

test --instrumentation_filter=//...

try-import %workspace%/.bazelrc.user

4 changes: 2 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ steps:
- command: "make build CI=yes"
label: ":bazel: Build: Framework"

- command: "make build CI=yes && make test CI=yes TESTS='//javatests/... -javatests/server:BrowserBasicServerTest_chromium-local -javatests/server:BrowserBasicServerTest_firefox-local -javatests/server:BasicTestApplication-native -javatests/ssr:SSRTestApplication-native-bin'"
- command: "make build test CI=yes"
label: ":coverage: Testsuite"

- wait

- command: "make build CI=yes TARGETS='//javatests/ssr:SSRTestApplication-native-bin && make build CI=yes TARGETS='//javatests/server:BasicTestApplication-native-bin"
- 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"

- wait
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ bazel-out
*.DS_Store
*.swp
.bazelrc.user
reports
3 changes: 3 additions & 0 deletions .ijwb/.bazelproject
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ directories:
js
java
proto
tests
javatests
tools
types
Expand All @@ -20,8 +21,10 @@ directories:
-node_modules

targets:
//samples/...
//proto/...
//java/...
//js/...
//style/...
//tests/...
//javatests/...
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
registry=https://npm.pkg.github.com/sgammon

52 changes: 42 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,50 @@ REMOTE ?= no
VERBOSE ?= no
QUIET ?= no
STRICT ?= no
COVERAGE ?= no
COVERAGE ?= yes
FORCE_COVERAGE ?= no
PROJECT ?= bloom-sandbox
IMAGE_PROJECT ?= elide-tools
RBE_INSTANCE ?= default_instance
CACHE_KEY ?= GustBuild
REGISTRY ?= bloomworks
PROJECT_NAME ?= GUST

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

REVISION ?= $(shell git describe --abbrev=7 --always --tags HEAD)
VERSION ?= $(shell (cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]' | sed 's/version\://g'))
REGISTRY ?= bloomworks
COVERAGE_DATA ?= bazel-out/_coverage/_coverage_report.dat
COVERAGE_REPORT ?= reports/coverage
COVERAGE_ARGS ?= --function-coverage \
--branch-coverage \
--highlight \
--demangle-cpp \
--show-details \
--title "$(PROJECT_NAME)" \
--precision 2 \
--legend \
--rc genhtml_med_limit=60 \
--rc genhtml_hi_limit=90

APP ?=
TARGETS ?= //java/... //proto/... //js/... //style/...
TESTS ?= //javatests/...
TESTS ?= //tests/...
COVERABLE ?= //javatests/...

TAG ?=
TEST_ARGS ?= --test_output=errors
TEST_ARGS_WITH_COVERAGE ?= --combined_report=lcov --nocache_test_results
BUILD_ARGS ?=

BAZELISK_ARGS ?=
BASE_ARGS ?= --google_default_credentials=true --define project=$(PROJECT)


# Flag: `COVERAGE`
ifeq ($(COVERAGE),yes)
# Flag: `FORCE_COVERAGE`
ifeq ($(FORCE_COVERAGE),yes)
TEST_COMMAND ?= coverage
TEST_ARGS += --combined_report=lcov
TEST_ARGS += $(TEST_ARGS_WITH_COVERAGE)
else
TEST_COMMAND ?= test
endif
Expand Down Expand Up @@ -65,9 +84,11 @@ TAG += --config=ci
_DEFAULT_JAVA_HOME = $(shell echo $$JAVA_HOME_12_X64)
BASE_ARGS += --define=ZULUBASE=$(_DEFAULT_JAVA_HOME) --define=jdk=zulu
BAZELISK ?= /bin/bazelisk
GENHTML ?= /bin/genhtml
else
TAG += --config=dev
BAZELISK ?= $(shell which bazelisk)
GENHTML ?= $(shell which genhtml)
endif

# Flag: `VERBOSE`
Expand All @@ -84,6 +105,7 @@ endif
all: devtools build test

b build: ## Build all framework targets.
$(info Building $(PROJECT_NAME)...)
$(_RULE)$(BAZELISK) $(BAZELISK_ARGS) build $(TAG) $(BASE_ARGS) $(BUILD_ARGS) -- $(TARGETS)

r run: ## Run the specified target.
Expand All @@ -93,10 +115,10 @@ c clean: ## Clean ephemeral targets.
$(_RULE)$(BAZELISK) $(BAZELISK_ARGS) clean

samples: ## Build and push sample app images.
$(_RULE)$(BAZELISK) $(BAZELISK_ARGS) run $(TAG) $(BASE_ARGS) $(BUILD_ARGS) //javatests/server:BasicTestApplication-image-push
$(_RULE)$(BAZELISK) $(BAZELISK_ARGS) run $(TAG) $(BASE_ARGS) $(BUILD_ARGS) //javatests/server:BasicTestApplication-native-image-push
$(_RULE)$(BAZELISK) $(BAZELISK_ARGS) run $(TAG) $(BASE_ARGS) $(BUILD_ARGS) //javatests/ssr:SSRTestApplication-image-push
$(_RULE)$(BAZELISK) $(BAZELISK_ARGS) run $(TAG) $(BASE_ARGS) $(BUILD_ARGS) //javatests/ssr:SSRTestApplication-native-image-push
$(_RULE)for target in $(SAMPLES) ; do \
$(BAZELISK) $(BAZELISK_ARGS) run $(TAG) $(BASE_ARGS) $(BUILD_ARGS) $$(echo "$$target")-image-push && \
$(BAZELISK) $(BAZELISK_ARGS) run $(TAG) $(BASE_ARGS) $(BUILD_ARGS) $$(echo "$$target")-native-image-push; \
done

distclean: ## Clean targets, caches and dependencies.
$(_RULE)$(BAZELISK) $(BAZELISK_ARGS) clean --expunge_async
Expand All @@ -105,7 +127,13 @@ forceclean: distclean ## Clean everything, and sanitize the codebase (DANGEROUS
$(_RULE)git reset --hard && git clean -xdf

test: ## Run all framework testsuites.
ifeq ($(COVERAGE),yes)
$(_RULE)$(BAZELISK) $(BAZELISK_ARGS) coverage $(TAG) $(BASE_ARGS) $(TEST_ARGS) $(TEST_ARGS_WITH_COVERAGE) -- $(COVERABLE)
$(_RULE)$(BAZELISK) $(BAZELISK_ARGS) $(TEST_COMMAND) $(TAG) $(BASE_ARGS) $(TEST_ARGS) -- $(TESTS)
$(_RULE)$(GENHTML) $(COVERAGE_DATA) --output-directory $(COVERAGE_REPORT) $(COVERAGE_ARGS)
else
$(_RULE)$(BAZELISK) $(BAZELISK_ARGS) $(TEST_COMMAND) $(TAG) $(BASE_ARGS) $(TEST_ARGS) -- $(TESTS) $(COVERABLE)
endif

docs: ## Build documentation for the framework.
@echo "Building GUST docs..."
Expand All @@ -123,6 +151,10 @@ update-deps: ## Re-seal and update all dependencies.
@echo "Re-pinning Maven dependencies..."
$(_RULE)$(BAZELISK) $(BAZELISK_ARGS) run @unpinned_maven//:pin

serve-coverage: ## Serve the current coverage report (must generate first).
@echo "Serving coverage report..."
@cd reports/coverage && python -m SimpleHTTPServer

release-images: ## Pull, tag, and release Docker images.
@echo "Pulling images for revision $(REVISION)..."
$(_RULE)docker pull us.gcr.io/$(IMAGE_PROJECT)/sample/basic/jvm:$(REVISION)
Expand Down
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ setup_workspace()
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "591d2945b09ecc89fde53e56dd54cfac93322df3bc9d4747cb897ce67ba8cdbf",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.2.0/rules_nodejs-1.2.0.tar.gz"],
sha256 = "b6670f9f43faa66e3009488bbd909bc7bc46a5a9661a33f6bc578068d1837f37",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.3.0/rules_nodejs-1.3.0.tar.gz"],
)

load("@build_bazel_rules_nodejs//:index.bzl",
Expand Down
8 changes: 4 additions & 4 deletions defs/build.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ DEPS = {
"io_bazel_rules_closure": {
"type": "github",
"repo": "sgammon/rules_closure",
"target": "4dc8434e964fa69d9c16d0936a706614c430ee1d",
"target": "571e37db18cc2e559999049b7bc7c9112c8b195d",
"local": "/workspace/GUST/vendor/bazel/rules_closure",
"seal": "90fa364333565bd6ad26dd48a58285c54967f8e335471a388a2e046bfaec390d"},
"seal": "94c7f97d7200650583a444dc6fe0cb650b2856bd1d098ae7587b6bafa6400bc2"},

# Rules: SASS
"io_bazel_rules_sass": {
Expand Down Expand Up @@ -134,8 +134,8 @@ DEPS = {
"com_google_elemental2": {
"type": "github",
"repo": "google/elemental2",
"target": "6567f2ad00379f34f4a1e080faf90fc284615354",
"seal": "94a978b5b4ced58b0ce95bfa6d3e08a3c55af4c89e49449aa6b61c2f34b931ab"},
"target": "d328c1e688cc5e7e9eaec5c5d264423878827925",
"seal": None},

# Google: JS Interop (Generator)
"com_google_jsinterop_generator": {
Expand Down
6 changes: 5 additions & 1 deletion defs/toolchain/frontend.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
load(
"//defs/toolchain/js:rules.bzl",
_js_app = "js_app",
_js_test = "js_test",
_js_module = "js_module",
)

load(
"//defs/toolchain/js:testing.bzl",
_js_test = "js_test",
)

load(
"//defs/toolchain/ts:tsc.bzl",
_ts_module = "ts_module",
Expand Down
1 change: 1 addition & 0 deletions defs/toolchain/java/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ load(


INJECTED_MICRONAUT_DEPS = [
"@gust//java:framework",
"@gust//defs/toolchain/java/plugins:micronaut",
maven("com.google.guava:guava"),
maven("com.google.template:soy"),
Expand Down
16 changes: 0 additions & 16 deletions defs/toolchain/js/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ load(

load(
"@io_bazel_rules_closure//closure:defs.bzl",
_closure_js_test = "closure_js_test",
_closure_js_library = "closure_js_library",
_closure_js_binary = "closure_js_binary",
_closure_js_template_library = "closure_js_template_library",
Expand All @@ -20,20 +19,6 @@ load(
)


def _js_test(name, srcs = None, deps = None, defs = {}, **kwargs):

""" Build a closure JS test. """

overlay_defs = _annotate_defs_flags(defs)
_closure_js_test(
name = name,
srcs = srcs or [],
deps = (deps or []) + ["@io_bazel_rules_closure//closure/library:testing"],
defs = overlay_defs,
**kwargs
)


def _js_module(name, srcs = None, deps = None, **kwargs):

""" Build a closure JS library. """
Expand Down Expand Up @@ -71,5 +56,4 @@ def _js_app(name,


js_app = _js_app
js_test = _js_test
js_module = _js_module
Loading

0 comments on commit 49278cb

Please sign in to comment.