05-Specifications / 05.04.Speed-Up-CICD.spec

05.04.Speed Up CICD.spec

05.04. Speed Up CICD.spec

This document specifies the requirements for improving the CI/CD performance for both the API and WUI projects by implementing parallel execution, caching, and workflow restructuring.

1. Problem Statement

The current CI/CD workflows (ci.yaml in both API and WUI) are highly sequential and redundant: * Redundant Cloning: Every job re-clones all repositories in the monorepo structure. * Redundant Building: Deployment jobs often re-build Docker images that were already built and tested in previous steps. * Sequential Testing: Tests run one after another within a single large job. * Heavyweight Setup: Starting the entire Docker compose environment for simple unit tests or type checks adds significant overhead.

2. Proposed Optimization Strategy

2.1 Parallel Execution (Matrix & Independent Jobs)

We will split the monolithic build-and-test jobs into discrete, parallelizable jobs:

2.2 Build Once, Reuse Everywhere

2.3 Selective CI (Path Filtering)

Implement dorny/paths-filter to detect which sub-projects changed: * If only bnc-cpt-wui/ changed, skip the full API test suite. * If only bnc-cpt-api/ changed, skip the WUI E2E tests. * Always run full suite on merges to master.

2.4 Advanced Caching

3. Implementation Plan

3.1 Step 1: Workflow Restructuring (utl doc/md/)

Update the utl project with helper scripts for CI: * do_ci_upload_workspace: Script to bundle and upload the cloned repos. * do_ci_download_workspace: Script to restore the workspace.

3.2 Step 2: API Workflow Update

  1. Introduce a setup job that clones and uploads the workspace.
  2. Introduce a build job that pushes the candidate image to Artifact Registry.
  3. Split tests into parallel jobs that depend on build.
  4. Update deploy to use the image from build.

3.3 Step 3: WUI Workflow Update

  1. Apply similar setup and build separation.
  2. Parallelize type-check, lint, and e2e-tests.
  3. Optimize the E2E matrix so workers share a single pre-built WUI container.

4. Expected Outcomes

5. Constraints