Skip to main content

Spring Boot application

A complete Java Spring Boot application with tests, linting, and container packaging.
load("@rbs//java/toolchain.rbs", "java_toolchain", "java_test_deps")
load("@rbs//java/dependencies.rbs", "java_repository")

# Auto-download JDK 17
java_toolchain(name = "java", version = "17.0.11")

# Auto-install JUnit 5 for tests
java_test_deps()

# Spring Boot dependency
java_repository(
    name = "spring_boot_web",
    package = "org.springframework.boot:spring-boot-starter-web",
    version = "3.2.2",
)

Node.js Express API

A Node.js Express server with libraries, development/production configs, and dependencies.
load("@rbs//nodejs/toolchain.rbs", "nodejs_toolchain")
load("@rbs//nodejs/dependencies.rbs", "nodejs_repository")

nodejs_toolchain(name = "nodejs", version = "20.11.0")

nodejs_repository(name = "express_repo", package = "express", version = "4.18.2")
nodejs_repository(name = "cors_repo", package = "cors", version = "2.8.5")
nodejs_repository(name = "helmet_repo", package = "helmet", version = "7.1.0")
nodejs_repository(name = "morgan_repo", package = "morgan", version = "1.10.0")

TypeScript application

TypeScript compilation with Express, OCI container images, and linting.
load("@rbs//nodejs/rules.rbs", "nodejs_binary", "nodejs_library")
load("@rbs//oci/rules.rbs", "oci_image")
load("@rbs//nodejs/lint.rbs", "nodejs_lint")

# TypeScript library with compiler options
nodejs_library(
    name = "utils",
    srcs = ["src/utils/math.ts", "src/utils/string.ts"],
    deps = [":lodash_repo", ":types_lodash_repo"],
    ts_compiler_options = {
        "target": "ES2020",
        "strict": True,
        "declaration": True,
    },
)

# TypeScript Express server
nodejs_binary(
    name = "server",
    srcs = ["src/server.ts"],
    main = "src/server.ts",
    deps = [":utils", ":express_repo", ":types_express_repo"],
    env = {"NODE_ENV": "development", "PORT": "4000"},
    ts_compiler_options = {
        "target": "ES2020",
        "module": "commonjs",
        "strict": True,
    },
)

# Container image
oci_image(
    name = "server_image",
    binary = ":server",
    base = "ubuntu:22.04",
    env = {"NODE_ENV": "production", "PORT": "8080"},
    ports = ["8080/tcp"],
    tag = "ts-server:latest",
)

# Lint with Prettier
nodejs_lint(
    name = "lint",
    srcs = glob(["src/**/*.ts"]),
    linters = ["prettier"],
)

Python with test coverage

Python project with library, binary, tests, and enforced coverage thresholds.
load("@rbs//python/rules.rbs", "py_binary", "py_library", "py_test")

py_library(
    name = "calculator",
    srcs = ["src/calculator.py"],
)

py_library(
    name = "string_utils",
    srcs = ["src/string_utils.py"],
)

py_binary(
    name = "app",
    srcs = ["src/main.py"],
    deps = [":calculator", ":string_utils"],
    main = "src/main.py",
)

# Basic test
py_test(
    name = "calculator_test",
    srcs = ["tests/test_calculator.py"],
    deps = [":calculator"],
)

# Test with coverage thresholds — fails if below threshold
py_test(
    name = "calculator_coverage_test",
    srcs = ["tests/test_calculator.py"],
    deps = [":calculator"],
    min_line_coverage = 85,
    min_branch_coverage = 75,
    min_function_coverage = 80,
)

Multi-package workspace

Organize a large project with multiple packages and cross-package dependencies.
my-app/
├── WORKSPACE.rbs
├── BUILD.rbs                    # Root orchestration
├── services/
│   ├── api/BUILD.rbs            # API service
│   └── worker/BUILD.rbs         # Background worker
└── libs/
    └── common/BUILD.rbs         # Shared library

Root BUILD.rbs

# Orchestrate all services
native.task(
    name = "build_all",
    command = ["echo", "All services built!"],
    deps = ["//services/api:build", "//services/worker:build"],
)

native.task(
    name = "test_all",
    command = ["echo", "All tests passed!"],
    deps = ["//services/api:test", "//services/worker:test"],
)

Build individual packages

# Traditional syntax
rbs build //services/api:build
rbs test //services/worker:test
rbs build //...                   # Build everything

# Natural syntax
rbs build services/api build
rbs test services/worker test

CI/CD pipeline

Define a complete CI/CD workflow directly in RBS:
# WORKSPACE.rbs
native.ci_workflow(
    name = "main",
    on = {
        "push": {"branches": ["main"]},
        "pull_request": {"branches": ["main"]},
    },
    jobs = {
        "lint": {
            "steps": [{"name": "Lint", "run": "rbs build //...:lint"}],
        },
        "build": {
            "needs": ["lint"],
            "steps": [{"name": "Build", "run": "rbs build //..."}],
        },
        "test": {
            "needs": ["build"],
            "steps": [{"name": "Test", "run": "rbs test //..."}],
        },
        "deploy": {
            "needs": ["test"],
            "if": "github.ref == 'refs/heads/main'",
            "steps": [{"name": "Deploy", "run": "rbs run //deploy:production"}],
        },
    },
)
rbs ci run                 # Run all matching workflows
rbs ci run --affected      # Run only on changed packages
rbs ci list                # List defined workflows

Infrastructure as Code

Provision cloud resources alongside your application code:
# infra.rbs
infra.register_provider(
    name = "aws",
    source = "hashicorp/aws",
    version = "5.31.0",
)

infra.provider_config(
    provider = "aws",
    config = {"region": "us-west-2"},
)

infra.resource(
    name = "web_server",
    type = "aws_instance",
    inputs = {
        "ami": "ami-0c55b159cbfafe1f0",
        "instance_type": "t3.micro",
        "tags": {"Name": "web-server"},
    },
)
rbs infra plan //...       # Preview changes
rbs infra apply            # Apply changes
rbs infra show             # Show current state