mirror of
https://github.com/pgsty/minio.git
synced 2026-10-18 23:46:11 +03:00
build: remove ripgrep from rebrand verification
Use the existing Git tool to scan source files, including untracked files and exported source trees. Preserve hidden-file exclusions and worktree ignore rules, and reject scanner diagnostics before filtering matches. Remove the CI installation step. Signed-off-by: Feng Ruohang <rh@vonng.com>
This commit is contained in:
@@ -51,11 +51,6 @@ jobs:
|
|||||||
- name: Vet
|
- name: Vet
|
||||||
run: go vet ./...
|
run: go vet ./...
|
||||||
|
|
||||||
- name: Install rebrand verification dependency
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install --yes --no-install-recommends ripgrep
|
|
||||||
|
|
||||||
- name: Verify rebrand compatibility contracts
|
- name: Verify rebrand compatibility contracts
|
||||||
run: |
|
run: |
|
||||||
go run ./buildscripts/rebrand-guard
|
go run ./buildscripts/rebrand-guard
|
||||||
|
|||||||
@@ -11,7 +11,32 @@ fail() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
command -v rg >/dev/null 2>&1 || fail "ripgrep (rg) is required for rebrand verification"
|
# Git is already a build prerequisite. --no-index also scans untracked files
|
||||||
|
# and exported source trees. As before, honor .gitignore only in a worktree.
|
||||||
|
search_ignore=--no-exclude-standard
|
||||||
|
if git rev-parse --show-toplevel >/dev/null 2>&1; then
|
||||||
|
search_ignore=--exclude-standard
|
||||||
|
fi
|
||||||
|
search_errors="$(mktemp)"
|
||||||
|
trap 'rm -f "${search_errors}"' EXIT
|
||||||
|
|
||||||
|
search_text() {
|
||||||
|
local status=0
|
||||||
|
git --no-pager grep --no-index "${search_ignore}" --no-color -nIHE "$@" 2>"${search_errors}" || status=$?
|
||||||
|
# Git can return 1 for both no matches and a file read error. Check stderr
|
||||||
|
# as well, before callers filter matches through their allowlists.
|
||||||
|
if [ "${status}" -gt 1 ] || [ -s "${search_errors}" ]; then
|
||||||
|
cat "${search_errors}" >&2
|
||||||
|
fail "could not scan source files"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Keep hidden files and build output out of the repository-wide scans.
|
||||||
|
source_excludes=(
|
||||||
|
':(exclude,glob)**/.*'
|
||||||
|
':(exclude,glob)**/.*/**'
|
||||||
|
':(exclude)dist/**'
|
||||||
|
)
|
||||||
|
|
||||||
require_file() {
|
require_file() {
|
||||||
[ -f "$1" ] || fail "missing required file: $1"
|
[ -f "$1" ] || fail "missing required file: $1"
|
||||||
@@ -154,7 +179,11 @@ if grep -Ev '^[[:space:]]*(#|$)' silo.env | grep -q '='; then
|
|||||||
fail "silo.env must not contain active assignments that shadow /etc/default/minio"
|
fail "silo.env must not contain active assignments that shadow /etc/default/minio"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if rg -n 'pgsty/minio:' .github/workflows Dockerfile.goreleaser helm/silo; then
|
delivery_hits="$(search_text 'pgsty/minio:' -- .github/workflows Dockerfile.goreleaser helm/silo \
|
||||||
|
':(exclude,glob).github/workflows/**/.*' ':(exclude,glob).github/workflows/**/.*/**' \
|
||||||
|
':(exclude,glob)helm/silo/**/.*' ':(exclude,glob)helm/silo/**/.*/**')"
|
||||||
|
if [ -n "${delivery_hits}" ]; then
|
||||||
|
printf '%s\n' "${delivery_hits}" >&2
|
||||||
fail "an active delivery surface still publishes the frozen pgsty/minio image"
|
fail "an active delivery surface still publishes the frozen pgsty/minio image"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -167,10 +196,10 @@ fi
|
|||||||
# So two rules. First, no live URL may resolve to the old repository anywhere,
|
# So two rules. First, no live URL may resolve to the old repository anywhere,
|
||||||
# READMEs and CONTRIBUTORS.md included.
|
# READMEs and CONTRIBUTORS.md included.
|
||||||
old_repo_pattern='pgsty/minio(\.git)?([^[:alnum:]_.-]|$)'
|
old_repo_pattern='pgsty/minio(\.git)?([^[:alnum:]_.-]|$)'
|
||||||
stale_repo_url="$(rg -n -e "github\.com/${old_repo_pattern}" -e "hub\.docker\.com/r/${old_repo_pattern}" \
|
stale_repo_url="$(search_text -e "github\.com/${old_repo_pattern}" -e "hub\.docker\.com/r/${old_repo_pattern}" -- . \
|
||||||
--glob '!.git/**' --glob '!dist/**' \
|
"${source_excludes[@]}" ':(exclude)SILO_REBRANDING_MIGRATION.md' \
|
||||||
--glob '!SILO_REBRANDING_MIGRATION.md' \
|
':(exclude)buildscripts/rebrand-guard/compat-baseline.json')"
|
||||||
--glob '!buildscripts/rebrand-guard/compat-baseline.json' . |
|
stale_repo_url="$(printf '%s\n' "${stale_repo_url}" |
|
||||||
sed 's#^\./##' | grep -v '^buildscripts/verify-rebrand\.sh:' || true)"
|
sed 's#^\./##' | grep -v '^buildscripts/verify-rebrand\.sh:' || true)"
|
||||||
if [ -n "${stale_repo_url}" ]; then
|
if [ -n "${stale_repo_url}" ]; then
|
||||||
printf '%s\n' "${stale_repo_url}" >&2
|
printf '%s\n' "${stale_repo_url}" >&2
|
||||||
@@ -182,32 +211,32 @@ fi
|
|||||||
# legacy image, the two READMEs that document the rename and the archived
|
# legacy image, the two READMEs that document the rename and the archived
|
||||||
# minio branch, and historical issue titles in CONTRIBUTORS.md.
|
# minio branch, and historical issue titles in CONTRIBUTORS.md.
|
||||||
repo_guard_allowlist='^(buildscripts/minio-upgrade\.sh|buildscripts/verify-rebrand\.sh|buildscripts/helm-migration-guard/main\.go|README\.md|README_ZH\.md|CONTRIBUTORS\.md):'
|
repo_guard_allowlist='^(buildscripts/minio-upgrade\.sh|buildscripts/verify-rebrand\.sh|buildscripts/helm-migration-guard/main\.go|README\.md|README_ZH\.md|CONTRIBUTORS\.md):'
|
||||||
stale_repo="$(rg -n "${old_repo_pattern}" --glob '!.git/**' --glob '!dist/**' \
|
stale_repo="$(search_text "${old_repo_pattern}" -- . "${source_excludes[@]}" \
|
||||||
--glob '!SILO_REBRANDING_MIGRATION.md' \
|
':(exclude)SILO_REBRANDING_MIGRATION.md' ':(exclude)buildscripts/rebrand-guard/compat-baseline.json')"
|
||||||
--glob '!buildscripts/rebrand-guard/compat-baseline.json' . |
|
stale_repo="$(printf '%s\n' "${stale_repo}" |
|
||||||
sed 's#^\./##' | grep -Ev "${repo_guard_allowlist}" || true)"
|
sed 's#^\./##' | grep -Ev "${repo_guard_allowlist}" || true)"
|
||||||
if [ -n "${stale_repo}" ]; then
|
if [ -n "${stale_repo}" ]; then
|
||||||
printf '%s\n' "${stale_repo}" >&2
|
printf '%s\n' "${stale_repo}" >&2
|
||||||
fail "a source reference still names the pre-rename pgsty/minio repository"
|
fail "a source reference still names the pre-rename pgsty/minio repository"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
stale_branch="$(rg -n 'pgsty/silo/(blob/|tree/|raw/)?master' \
|
stale_branch="$(search_text 'pgsty/silo/(blob/|tree/|raw/)?master' -- . "${source_excludes[@]}")"
|
||||||
--glob '!.git/**' --glob '!dist/**' . || true)"
|
|
||||||
if [ -n "${stale_branch}" ]; then
|
if [ -n "${stale_branch}" ]; then
|
||||||
printf '%s\n' "${stale_branch}" >&2
|
printf '%s\n' "${stale_branch}" >&2
|
||||||
fail "a link still targets the retired master branch; raw and Actions URLs do not follow a branch rename"
|
fail "a link still targets the retired master branch; raw and Actions URLs do not follow a branch rename"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for workflow in .github/workflows/go.yml .github/workflows/vulncheck.yml; do
|
for workflow in .github/workflows/go.yml .github/workflows/vulncheck.yml; do
|
||||||
if rg -q '^\s+- master$' "${workflow}"; then
|
stale_filter="$(search_text '^[[:space:]]+- master$' -- "${workflow}")"
|
||||||
|
if [ -n "${stale_filter}" ]; then
|
||||||
fail "${workflow} still filters on master and would go silently dormant on main"
|
fail "${workflow} still filters on master and would go silently dormant on main"
|
||||||
fi
|
fi
|
||||||
require_text "${workflow}" " - main"
|
require_text "${workflow}" " - main"
|
||||||
done
|
done
|
||||||
|
|
||||||
network_hits="$(rg -n --glob '*.go' --glob '!**/*_test.go' \
|
network_hits="$(search_text \
|
||||||
'https?://[^"`[:space:]]*(dl\.min\.io|subnet\.min\.io|api\.min\.io|slack\.min\.io|play\.min\.io)' \
|
'https?://[^"`[:space:]]*(dl\.min\.io|subnet\.min\.io|api\.min\.io|slack\.min\.io|play\.min\.io)' -- \
|
||||||
cmd internal || true)"
|
':(glob)cmd/**/*.go' ':(glob)internal/**/*.go' ':(exclude,glob)**/*_test.go' "${source_excludes[@]}")"
|
||||||
network_hits="$(printf '%s\n' "${network_hits}" | grep -Ev '^[^:]+:[0-9]+:[[:space:]]*//' || true)"
|
network_hits="$(printf '%s\n' "${network_hits}" | grep -Ev '^[^:]+:[0-9]+:[[:space:]]*//' || true)"
|
||||||
if [ -n "${network_hits}" ]; then
|
if [ -n "${network_hits}" ]; then
|
||||||
printf '%s\n' "${network_hits}" >&2
|
printf '%s\n' "${network_hits}" >&2
|
||||||
|
|||||||
Reference in New Issue
Block a user