Skip to content

CI Optimization: Proposals to reduce PR workflow execution time #690

Closed

Description

@ad-claw000

I have been investigating the CI times for the pr.yaml workflow and found that test jobs (http and non_http) regularly take 40m to 1h30m+ to complete.
After analyzing the job execution logs, the majority of the time is spent in three sequential bottlenecks:

  1. Building the aperturedb-notebook image (20-25 mins)
  2. Building the aperturedb-python-tests image (15-20 mins)
  3. Running pytest sequentially (30-45 mins)

To drastically reduce CI feedback time, I propose 3 alternative solutions for us to prioritize. We can implement one or more of these:

Alternative 1: Optimize Dockerfile Layer Caching (Quick Win)

In docker/notebook/Dockerfile and docker/tests/Dockerfile, the entire source tree is added (ADD docker/notebook/aperturedata /aperturedata) before installing heavy external dependencies like CLIP (pip install git+...) and system packages (apt install curl). This causes any code change in the PR to invalidate the Docker cache, forcing a slow rebuild of CLIP and other dependencies.

  • Fix: Reorder the Dockerfiles. Move RUN pip install git+.../CLIP.git and RUN apt install curl above the ADD step.
  • Impact: Reduces the 20-40 min Docker build step to < 1 minute on most PRs.

Alternative 2: Enable Pytest Sharding / Parallel Execution

Currently, test/run_test.sh runs pytest strictly sequentially across the entire test suite.

  • Fix: We can introduce matrix sharding in GitHub Actions. By updating the workflow matrix to shard: [1, 2, 3, 4] and using a plugin like pytest-shard, we can split the test suite across multiple concurrent jobs. Alternatively, if the ApertureDB test container can handle it, we can use pytest-xdist to run tests on multiple CPU cores inside the same container (pytest -n auto).
  • Impact: Cuts the 30-45 min test execution time proportionally to the number of shards/workers.

Alternative 3: Implement GitHub Actions Cache for Docker Builds

In ci.sh, build_notebook_image does not use the --cache-from flag for docker build. Coupled with runners cycling, this often results in full from-scratch rebuilds.

  • Fix: Migrate from the bash script's docker build to docker/build-push-action inside the GitHub workflow, utilizing GitHub Actions native caching (cache-to: type=gha, cache-from: type=gha). If we keep ci.sh, we should explicitly pull the latest notebook image and use --cache-from aperturedata/aperturedb-notebook:latest.
  • Impact: Prevents cold-start build times entirely by sharing layer caches across all PR runs, ensuring stable and fast build times regardless of the runner node.

@luisremis Let me know which alternative(s) you would like me to tackle first!

Activity

  1. self-assigned this
    on May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions