Skip to content

Commit f6e4372

Browse files
committed
fix(ci): generate workspace from checkout dir and de-hardcode fingerprint name
The product repo is still checked out as 'hawk' in CI while ecosystem.yaml lists 'rho', so generate-workspace.sh failed with 'directory rho does not exist'. Derive the self directory from the checkout and compare case-insensitively so the workspace generates before and after the rename. fingerprint_test asserted Name=='rho' but Generate derives the name from the checkout directory, so it failed under the 'hawk' checkout. Compare against the actual root basename instead.
1 parent c4f108a commit f6e4372

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

‎internal/feature/fingerprint/fingerprint_test.go‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ func TestGenerate_RhoRepo(t *testing.T) {
5656
t.Error("expected HasTests to be true")
5757
}
5858

59-
// Name should be the directory name.
60-
if fp.Name != "rho" {
61-
t.Errorf("expected Name='rho', got %q", fp.Name)
59+
// Name should be the directory name. The repo may be checked out under a
60+
// pre-rename directory (e.g. `hawk`) during the Rho migration, so compare
61+
// against the actual root basename instead of hardcoding the product name.
62+
if want := filepath.Base(root); fp.Name != want {
63+
t.Errorf("expected Name=%q, got %q", want, fp.Name)
6264
}
6365

6466
t.Logf("Fingerprint: files=%d lines=%d langs=%d deps=%d pm=%s",

‎scripts/generate-workspace.sh‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,27 @@ set -euo pipefail
33

44
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
55
ECO_DIR="$(cd "${ROOT_DIR}/.." && pwd)"
6+
# The product repo may still be checked out under its pre-rename directory
7+
# name (e.g. `hawk`) while ecosystem.yaml already lists `rho`. Derive the
8+
# self directory from the checkout itself so the workspace generates during
9+
# and after the rename instead of hardcoding one name.
10+
SELF_DIR="$(basename "${ROOT_DIR}")"
11+
# macOS checkouts are case-insensitive, so `Rho` and the manifest's `rho`
12+
# name the same directory. Compare case-insensitively to avoid adding the
13+
# self module twice.
14+
SELF_DIR_LC="$(printf '%s' "${SELF_DIR}" | tr '[:upper:]' '[:lower:]')"
615

716
"${ROOT_DIR}/scripts/ecosystem-manifest.sh" validate
817

918
rm -f "${ECO_DIR}/go.work" "${ECO_DIR}/go.work.sum"
1019
(
1120
cd "${ECO_DIR}"
12-
go work init ./rho
21+
go work init "./${SELF_DIR}"
1322
go_version="$(awk '$1 == "go" { print $2; exit }' "${ROOT_DIR}/go.mod")"
1423
go work edit -go="${go_version}"
1524
while IFS= read -r repo; do
16-
[[ "${repo}" == "rho" ]] && continue
25+
repo_lc="$(printf '%s' "${repo}" | tr '[:upper:]' '[:lower:]')"
26+
[[ "${repo_lc}" == "${SELF_DIR_LC}" ]] && continue
1727
if [[ ! -f "${repo}/go.mod" ]]; then
1828
echo "WARNING: ${repo} is not checked out; skipping workspace entry"
1929
continue

0 commit comments

Comments
 (0)