Support parallel differential tags
This commit is contained in:
parent
bfd852f02c
commit
37603418ce
|
@ -18,6 +18,7 @@ jobs:
|
|||
INCREMENTAL: "true"
|
||||
DEBUG: "true"
|
||||
QUICKLY: ""
|
||||
PARALLET: "10"
|
||||
run: |
|
||||
./scripts/check-image.sh
|
||||
- name: Update badge
|
||||
|
|
|
@ -7,6 +7,7 @@ set -o pipefail
|
|||
DEBUG="${DEBUG:-}"
|
||||
INCREMENTAL="${INCREMENTAL:-}"
|
||||
QUICKLY="${QUICKLY:-}"
|
||||
PARALLET="${PARALLET:-0}"
|
||||
|
||||
declare -A DOMAIN_MAP=()
|
||||
|
||||
|
@ -45,7 +46,7 @@ done
|
|||
LOGFILE="./check-image.log"
|
||||
echo >"${LOGFILE}"
|
||||
|
||||
for line in $(cat ./mirror.txt); do
|
||||
for line in $(cat ./mirror.txt | shuf); do
|
||||
line="${line/ /}"
|
||||
if [[ "$line" == "" ]]; then
|
||||
continue
|
||||
|
@ -62,7 +63,7 @@ for line in $(cat ./mirror.txt); do
|
|||
domain="${line%%/*}"
|
||||
new_image=$(echo "${line}" | sed "s/^${domain}/${DOMAIN_MAP["${domain}"]}/g")
|
||||
echo "Diff image ${line} ${new_image}"
|
||||
DEBUG="${DEBUG}" QUICKLY="${QUICKLY}" INCREMENTAL="${INCREMENTAL}" EXCLUDED="${exclude}" ./scripts/diff-image.sh "${line}" "${new_image}" 2>&1 | tee -a "${LOGFILE}" || {
|
||||
DEBUG="${DEBUG}" QUICKLY="${QUICKLY}" INCREMENTAL="${INCREMENTAL}" PARALLET="${PARALLET}" EXCLUDED="${exclude}" ./scripts/diff-image.sh "${line}" "${new_image}" 2>&1 | tee -a "${LOGFILE}" || {
|
||||
echo "Error: diff image ${line} ${new_image}"
|
||||
}
|
||||
done
|
||||
|
|
|
@ -19,6 +19,9 @@ QUICKLY="${QUICKLY:-}"
|
|||
# Exclude tags that do not need to be checked
|
||||
EXCLUDED="${EXCLUDED:-}"
|
||||
|
||||
# Compare the number of tags in parallel
|
||||
PARALLET="${PARALLET:-0}"
|
||||
|
||||
SELF="$(basename "${BASH_SOURCE[0]}")"
|
||||
|
||||
function check() {
|
||||
|
@ -36,6 +39,7 @@ function check() {
|
|||
echo " INCREMENTAL=true # Allow image2 to have more tags than image1"
|
||||
echo " QUICKLY=true # Compare only tags that are in both images"
|
||||
echo " EXCLUDED=<pattern> # Exclude tags that do not need to be checked"
|
||||
echo " PARALLET=<size> # Compare the number of tags in parallel"
|
||||
return 2
|
||||
fi
|
||||
|
||||
|
@ -204,6 +208,15 @@ function diff-image() {
|
|||
return 0
|
||||
}
|
||||
|
||||
function wait_jobs() {
|
||||
local job_num=${1:-3}
|
||||
local perc=$(jobs -p | wc -l)
|
||||
while [ "${perc}" -gt "${job_num}" ]; do
|
||||
sleep 1
|
||||
perc=$(jobs -p | wc -l)
|
||||
done
|
||||
}
|
||||
|
||||
function main() {
|
||||
local image1="${1:-}"
|
||||
local image2="${2:-}"
|
||||
|
@ -216,9 +229,17 @@ function main() {
|
|||
local list=$(diff-image "${image1}" "${image2}")
|
||||
|
||||
local unsync=()
|
||||
if [[ "${QUICKLY}" != "true" ]] || [[ "${PARALLET}" -eq 0 ]]; then
|
||||
for tag in ${list}; do
|
||||
diff-image-with-tag "${image1}:${tag}" "${image2}:${tag}" >/dev/null || unsync+=("${tag}")
|
||||
done
|
||||
else
|
||||
for tag in ${list}; do
|
||||
wait_jobs "${PARALLET}"
|
||||
diff-image-with-tag "${image1}:${tag}" "${image2}:${tag}" >/dev/null || unsync+=("${tag}") &
|
||||
done
|
||||
wait
|
||||
fi
|
||||
|
||||
if [[ "${#unsync[@]}" -gt 0 ]]; then
|
||||
echo "${SELF}: INFO: ${image1} and ${image2} are not in synchronized, there are unsynchronized tags ${#unsync[@]}: ${unsync[*]}" >&2
|
||||
|
|
Loading…
Reference in New Issue