Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Pipeline Service Validation
env:
WORKSPACE_DIR: ${{ github.workspace }}
run: bazel test //pipeline:test --test_output=all
run: bazel test //pipeline:unit_test --test_output=all
Comment thread
SuvabrataChowdhury marked this conversation as resolved.
Resolved

- name: OpenAPI Contract Check
uses: ./.github/actions/openapi-changes
Expand Down
27 changes: 21 additions & 6 deletions autobuild-docs/setup/bazel.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,27 @@ AutoBuild/

Comment thread
SuvabrataChowdhury marked this conversation as resolved.
Resolved
```sh
# Run pipeline (Java/Maven) tests
bazel test //pipeline:test
bazel test //pipeline:unit_test
Comment thread
SuvabrataChowdhury marked this conversation as resolved.
Resolved

# Run pipeline-ui (Node/npm) tests
bazel test //pipeline-ui:unit_test
```

## Local Development

`bazel run //<service-name>:local-dev` starts the local development server for that service.

```sh
# Start the Spring Boot backend
bazel run //pipeline:local-dev

# Start the UI with a Prism mock server (no backend needed)
bazel run //pipeline-ui:local-dev
```

The UI target uses `.env.local-with-mock` and spins up a Prism mock server driven by the
OpenAPI spec, so the full backend stack is not required for frontend development.

The `--test_env=WORKSPACE_DIR` flag is automatically applied to all `bazel test`
invocations via `.bazelrc`, so no extra flags are needed as long as `WORKSPACE_DIR`
is set in your shell.
Expand Down Expand Up @@ -76,13 +91,13 @@ By default Bazel only prints output on failure. Use `--test_output` to control t
`--test_output=streamed` is the most useful during development — you see Maven/npm output in real time:

```sh
bazel test //pipeline:test --test_output=streamed
bazel test //pipeline:unit_test --test_output=streamed
```

To read the log from a previous run:

```sh
cat $(bazel info bazel-testlogs)/pipeline/test/test.log
cat $(bazel info bazel-testlogs)/pipeline/unit_test/test.log
```

## Caching
Expand All @@ -91,13 +106,13 @@ Bazel caches test results based on input file changes. If no source files or `po
have changed since the last run, the result is served from cache:

```
//pipeline:test (cached) PASSED in 13.5s
//pipeline:unit_test (cached) PASSED in 13.5s
```

To force a re-run regardless of cache:

```sh
bazel test //pipeline:test --cache_test_results=no
bazel test //pipeline:unit_test --cache_test_results=no
```

## Adding Tests for a New Service
Expand All @@ -120,7 +135,7 @@ bazel test //pipeline:test --cache_test_results=no
load("@rules_shell//shell:sh_test.bzl", "sh_test")

sh_test(
name = "test",
name = "unit_test",
srcs = ["run_tests.sh"],
data = glob(["src/**", "pom.xml"], exclude = ["target/**"]),
tags = ["manual", "local"],
Expand Down
11 changes: 10 additions & 1 deletion pipeline-ui/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
load("@rules_shell//shell:sh_test.bzl", "sh_test")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")

# Inputs Bazel tracks for cache invalidation — if none of these change,
# both targets below are skipped entirely (cache hit).
_SRCS = glob(
["src/**", "test/**", "*.json", "*.js", "*.ts"],
["src/**", "test/**", "*.json", "*.js", "*.ts", "*.html"],
exclude = ["src/gen/**"],
)

Expand All @@ -16,4 +17,12 @@ sh_test(
tags = [],
)

# Starts the UI locally with a Prism mock server (no backend needed).
# Run with: bazel run //pipeline-ui:local-dev
sh_binary(
name = "local-dev",
srcs = ["run_local_dev.sh"],
data = _SRCS + ["//apis/openapi-spec:openapi-specs"] + [".env.local-with-mock"],
)


14 changes: 14 additions & 0 deletions pipeline-ui/run_local_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail

cd pipeline-ui

npm ci

# Dereference symlinks so Vite can resolve modules from this directory
find . -maxdepth 5 -type l ! -path './node_modules/*' | while read -r f; do
cp -Lf "$f" "${f}.deref" && mv "${f}.deref" "$f"
done

npm run generate:clean-client-code
npm run local-with-mock
19 changes: 16 additions & 3 deletions pipeline/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_shell//shell:sh_test.bzl", "sh_test")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")

# Inputs Bazel tracks for cache invalidation — if none of these change,
# both targets below are skipped entirely (cache hit).
Expand All @@ -7,15 +8,27 @@ _SRCS = glob(
exclude = ["target/**"],
) + ["//apis/protobuf:protobuf_files"]

# Runs the full Maven test suite.
# Run with: bazel test //pipeline:test
# TODO: Rename to run only unit tests (mvn test) once integration tests are separated
# (rename SecurityConfigTest.java -> SecurityConfigIT.java + add Failsafe plugin to pom.xml).
# Goal: unify with //pipeline-ui:unit_test which runs unit tests only.
# Runs the full Maven verify suite (unit + integration tests + package).
# Run with: bazel test //pipeline:unit_test
sh_test(
name = "test",
name = "unit_test",
srcs = ["run_tests.sh"],
data = _SRCS,
tags = ["local"],
)

# Starts the Spring Boot application locally.
# Run with: bazel run //pipeline:local-dev
sh_binary(
name = "local-dev",
srcs = ["run_local_dev.sh"],
data = _SRCS,
tags = ["local"],
)

# Generates the OpenAPI spec by starting the app and hitting /v3/api-docs.yaml.
# Output is written to //apis/openapi-spec:pipeline-service.yaml.
# Run with: bazel run //pipeline:generate-openapi
Expand Down
7 changes: 7 additions & 0 deletions pipeline/run_local_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

cd "./pipeline/"
SPRING_PROFILES_ACTIVE=default,sqlite \
SPRING_JPA_SHOW_SQL=false \
mvn --batch-mode -s maven-settings.xml spring-boot:run
Loading