8000 Refactor (and re-apply) `generate-repo-stub-readme.sh` · Issue #2502 · docker-library/docs · GitHub
[go: up one dir, main page]

Skip to content
Refactor (and re-apply) generate-repo-stub-readme.sh #2502
@yosifkit

Description

@yosifkit

The migration of the new "meta" jobs out of "work-in-progress" (docker-library/meta-scripts#94 docker-library/meta-scripts#95) has reminded me that we need to finally delete the multiarch jobs on Jenkins. And once we do that, then the badges will stop working. They are currently not providing value since the multiarch jobs are unused. We do not have a 1 for 1 replacement since the new jobs are not per-repo, but strictly per-arch only. I guess the put-shared badge will still be correct for now.

So, this issue is to make a choice with the code in generate-repo-stub-readme.sh and then apply it to all of our image-specific repos:

badges=()
n=$'\n'
t=$'\t'
branch='master'
toTest=(
# "image badge URL"
# "image badge link/href"
# "badge test URL (to determine whether badge applies)"
"https://img.shields.io/github/actions/workflow/status/$githubRepoName/ci.yml?branch=$branch&label=GitHub%20CI"
"https://github.com/$githubRepoName/actions?query=workflow%3A%22GitHub+CI%22+branch%3A$branch"
"https://github.com/$githubRepoName/blob/$branch/.github/workflows/ci.yml"
"https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/update.sh/job/$repo.svg?label=Automated%20update.sh"
"https://doi-janky.infosiftr.net/job/update.sh/job/$repo/"
"https://doi-janky.infosiftr.net/job/update.sh/job/$repo/"
)
_wget_spider() {
wget -q -o /dev/null -O /dev/null --spider "$@"
}
set -- "${toTest[@]}"
while [ "$#" -gt 0 ]; do
image="$1"; shift
url="$1"; shift
testUrl="$1"; shift
if _wget_spider "$testUrl"; then
badges+=( "-${t}[![build status badge]($image)]($url)" )
fi
done
arches="$(bashbrew cat --format '{{ range .Entries }}{{ join "\n" .Architectures }}{{ "\n" }}{{ end }}' "https://github.com/docker-library/official-images/raw/master/library/$repo" | sort -u)"
if [ -n "$arches" ]; then
archTable=
i=0
for arch in $arches put-shared; do
if [ "$arch" = 'put-shared' ]; then
jenkinsJob="job/put-shared/job/light/job/$repo"
if ! _wget_spider "https://doi-janky.infosiftr.net/$jenkinsJob/"; then
jenkinsJob='job/put-shared/job/heavy'
fi
else
jenkinsJob="job/multiarch/job/$arch/job/$repo"
fi
jenkinsLink="https://doi-janky.infosiftr.net/$jenkinsJob/"
jenkinsImage="https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/$jenkinsJob.svg?label=$arch"
if _wget_spider "$jenkinsLink"; then
archTable="${archTable:-|} [![$arch build status badge]($jenkinsImage)]($jenkinsLink) |"
(( i = (i + 1) % 4 )) || : # modulo here needs to match the number of colums used below
if [ "$i" = 0 ]; then
archTable+="${n}|"
fi
fi
done
if [ -n "$archTable" ]; then
if [ "${#badges[@]}" -gt 0 ]; then
badges+=( '' )
fi
badges+=( "| Build | Status | Badges | (per-arch) |${n}|:-:|:-:|:-:|:-:|${n}${archTable%${n}|}" )
fi
fi
if [ "${#badges[@]}" -gt 0 ]; then
IFS=$'\n'
cat <<-EOREADME
---
${badges[*]}
EOREADME
unset IFS
fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0