Add image cache lookup scripts and templates
Summary
- Add generic scripts for finding pre-built Docker images without rebuilding
- Add CI templates for source change detection and upstream image lookup
- Enable downstream repos to find upstream images without maintaining submodules
New Scripts (scripts/bash/)
| Script | Purpose |
|---|---|
find-last-source-commit.sh |
Find the most recent commit that changed source file patterns |
get-cached-image.sh |
Check if a Docker image exists in a registry for a commit |
find-upstream-image.sh |
Find images from upstream repos (combines git fetch + lookup) |
New Template (templates/source_change_detection.gitlab-ci.yml)
-
.detect_source_changes- Detect docs-only/tests-only changes -
.find_upstream_image- Look up images from upstream repos -
.check_local_image- Check local registry for cached images - Skip rule templates for conditional job execution
Use Cases
- Building repo (hive): Find last source commit, check if image exists, skip rebuild
- Downstream repo (clive): Fetch upstream repo, find last source commit, use pre-built image
Example Usage
# Downstream repo finding upstream image
find-upstream-image.sh \
--repo-url=https://gitlab.syncad.com/hive/hive.git \
--registry=registry.gitlab.syncad.com/hive/hive \
--patterns="libraries/,programs/,CMakeLists.txt,Dockerfile"
Test plan
- Test scripts locally with hive repo
- Test cross-repo lookup (e.g., clive finding hive image)
- Validate CI template syntax