ci: take product name explicitly instead of deriving it from checkout dir

Every consuming product's CI checks out into a directory literally
named `src` (see e.g. breadpad's checkout step), so basename(repo_root)
resolved to "src" for every product in real CI runs — not the actual
product name, which only looked right in local testing because that
happened to run from a directory actually named after the product.

In production this meant every product sharing the runner would have
collided on the same image tag (bread-ci:src) and the same cargo-target
cache volume, silently mixing compiled artifacts across unrelated
repos. Caught before a second product (breadmon/breadclip/breadshot)
started using this and made the collision real.
This commit is contained in:
Breadway 2026-08-05 09:03:22 +08:00
parent cd5da468b3
commit 69c24f6d04

View file

@ -5,8 +5,14 @@
# from ci/Containerfile, then runs the given cargo command inside it # from ci/Containerfile, then runs the given cargo command inside it
# against a product repo checkout. # against a product repo checkout.
# #
# Usage: ci/build.sh <product-repo-root> <cargo-command...> # Usage: ci/build.sh <product-name> <product-repo-root> <cargo-command...>
# e.g. ci/build.sh /path/to/breadpad cargo build --release --locked # e.g. ci/build.sh breadpad /path/to/breadpad cargo build --release --locked
#
# <product-name> is used verbatim as the image tag and cache-volume name —
# it must be passed explicitly rather than derived from <product-repo-root>'s
# basename, because every product's CI checks out into a directory literally
# named `src`, which would otherwise collide across every product sharing
# this runner (same image tag, same cargo-target cache volume).
# #
# If <product-repo-root>/ci/deps.txt exists (one pacman package per line, # If <product-repo-root>/ci/deps.txt exists (one pacman package per line,
# '#' comments and blank lines ignored), those packages are installed on # '#' comments and blank lines ignored), those packages are installed on
@ -17,16 +23,16 @@
# per-product. Both persist in named docker volumes across runs. # per-product. Both persist in named docker volumes across runs.
set -euo pipefail set -euo pipefail
if [ $# -lt 2 ]; then if [ $# -lt 3 ]; then
echo "usage: build.sh <product-repo-root> <cargo-command...>" >&2 echo "usage: build.sh <product-name> <product-repo-root> <cargo-command...>" >&2
exit 1 exit 1
fi fi
REPO_ROOT="$(cd "$1" && pwd)" PRODUCT="$1"
shift REPO_ROOT="$(cd "$2" && pwd)"
shift 2
CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PRODUCT="$(basename "$REPO_ROOT")"
EXTRA_PKGS="" EXTRA_PKGS=""
if [ -f "${REPO_ROOT}/ci/deps.txt" ]; then if [ -f "${REPO_ROOT}/ci/deps.txt" ]; then