Skip to content

Commit 11afea1

Browse files
authored
packages: support paginated list of artifacts for v6 correctly (#898)
When frequently ci was kicked for v6 and v5, it can not find artifacts. Signed-off-by: Kentaro Hayashi <[email protected]>
1 parent 90ab323 commit 11afea1

File tree

1 file changed

+67
-68
lines changed

1 file changed

+67
-68
lines changed

fluent-package/manage-fluent-repositories.sh

Lines changed: 67 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -198,85 +198,84 @@ EOF
198198
https://api.github.com/repos/fluent/fluent-package-builder/pulls/$PULL_NUMBER | jq --raw-output '.head | .ref + " " + .sha')
199199
head_branch=$(echo $response | cut -d' ' -f1)
200200
head_sha=$(echo $response | cut -d' ' -f2)
201-
rm -f dl.list
202-
for d in `seq 1 5`; do
201+
rm -f dl.*.list
202+
for d in `seq 1 20`; do
203203
curl --silent --location \
204204
-H "Accept: application/vnd.github+json" \
205205
-H "Authorization: Bearer $GITHUB_ACCESS_TOKEN" \
206206
-H "X-GitHub-Api-Version: 2022-11-28" \
207207
"https://api.github.com/repos/fluent/fluent-package-builder/actions/artifacts?per_page=100&page=$d" | \
208-
jq --raw-output '.artifacts[] | select(.workflow_run.head_branch == "'$head_branch'" and .workflow_run.head_sha == "'$head_sha'") | .name + " " + (.size_in_bytes|tostring) + " " + .archive_download_url' > dl.list
209-
filesize=$(stat -c "%s" dl.list)
208+
jq --raw-output '.artifacts[] | select(.workflow_run.head_branch == "'$head_branch'" and .workflow_run.head_sha == "'$head_sha'") | .name + " " + (.size_in_bytes|tostring) + " " + .archive_download_url' > dl.$d.list
209+
filesize=$(stat -c "%s" dl.$d.list)
210210
if [ $filesize -eq 0 ]; then
211211
echo "Failed to fetch artifacts list"
212-
rm -f dl.list
212+
rm -f dl.$d.list
213213
continue
214-
else
215-
break
216214
fi
217-
done
218-
while read line
219-
do
220-
package=$(echo $line | cut -d' ' -f1)
221-
download_url=$(echo $line | cut -d' ' -f3)
222-
echo "Downloading $package.zip from $download_url"
223-
case $package in
224-
v7*)
225-
echo "Skip downloading v7 test package ($package.zip)"
226-
;;
227-
*debian*|*ubuntu*)
228-
mkdir -p apt/repositories
229-
(cd apt/repositories &&
230-
rm -f $package.zip &&
231-
curl --silent --location --output $package.zip \
232-
-H "Authorization: Bearer $GITHUB_ACCESS_TOKEN" $download_url ) &
233-
;;
234-
*centos*|*rockylinux*|*almalinux*|*amazonlinux*)
235-
mkdir -p yum/repositories
236-
(cd yum/repositories &&
237-
rm -f $package.zip &&
238-
curl --silent --location --output $package.zip \
239-
-H "Authorization: Bearer $GITHUB_ACCESS_TOKEN" $download_url ) &
240-
;;
241-
*)
242-
curl --silent --location --output $package.zip \
243-
-H "Authorization: Bearer $GITHUB_ACCESS_TOKEN" $download_url &
244-
;;
245-
esac
246-
done < dl.list
247-
wait
215+
while read line
216+
do
217+
package=$(echo $line | cut -d' ' -f1)
218+
download_url=$(echo $line | cut -d' ' -f3)
219+
echo "Downloading $package.zip from $download_url"
220+
case $package in
221+
v7*)
222+
echo "Skip downloading v7 test package ($package.zip)"
223+
;;
224+
*debian*|*ubuntu*)
225+
mkdir -p apt/repositories
226+
(cd apt/repositories &&
227+
rm -f $package.zip &&
228+
curl --silent --location --output $package.zip \
229+
-H "Authorization: Bearer $GITHUB_ACCESS_TOKEN" $download_url ) &
230+
;;
231+
*centos*|*rockylinux*|*almalinux*|*amazonlinux*)
232+
mkdir -p yum/repositories
233+
(cd yum/repositories &&
234+
rm -f $package.zip &&
235+
curl --silent --location --output $package.zip \
236+
-H "Authorization: Bearer $GITHUB_ACCESS_TOKEN" $download_url ) &
237+
;;
238+
*)
239+
curl --silent --location --output $package.zip \
240+
-H "Authorization: Bearer $GITHUB_ACCESS_TOKEN" $download_url &
241+
;;
242+
esac
243+
done < dl.$d.list
244+
wait
248245

249-
verified=1
250-
while read line
251-
do
252-
package=$(echo $line | cut -d' ' -f1)
253-
download_size=$(echo $line | cut -d' ' -f2)
254-
case $package in
255-
v7*)
256-
echo "Skip processing v7 test package ($package.zip)"
257-
continue
258-
;;
259-
*debian*|*ubuntu*)
260-
actual_size=$(stat --format="%s" apt/repositories/$package.zip)
261-
;;
262-
*rockylinux*|*almalinux*|*amazonlinux*)
263-
actual_size=$(stat --format="%s" yum/repositories/$package.zip)
264-
;;
265-
*)
266-
actual_size=$(stat --format="%s" $package.zip)
267-
;;
268-
esac
269-
if [ $download_size = "$actual_size" ]; then
270-
echo -e "[\e[32m\e[40mOK\e[0m] Verify apt/repositories/$package.zip"
271-
else
272-
echo -e "[\e[31m\e[40mNG\e[0m] Verify apt/repositories/$package.zip (expected: $download_size actual: $actual_size)"
273-
verified=0
246+
verified=1
247+
while read line
248+
do
249+
package=$(echo $line | cut -d' ' -f1)
250+
download_size=$(echo $line | cut -d' ' -f2)
251+
case $package in
252+
v7*)
253+
echo "Skip downloading v7 test package ($package.zip)"
254+
;;
255+
*debian*|*ubuntu*)
256+
actual_size=$(stat --format="%s" apt/repositories/$package.zip)
257+
;;
258+
*rockylinux*|*almalinux*|*amazonlinux*)
259+
actual_size=$(stat --format="%s" yum/repositories/$package.zip)
260+
;;
261+
*)
262+
actual_size=$(stat --format="%s" $package.zip)
263+
;;
264+
esac
265+
if [ $download_size = "$actual_size" ]; then
266+
echo -e "[\e[32m\e[40mOK\e[0m] Verify apt/repositories/$package.zip"
267+
else
268+
echo -e "[\e[31m\e[40mNG\e[0m] Verify apt/repositories/$package.zip (expected: $download_size actual: $actual_size)"
269+
verified=0
270+
fi
271+
done < dl.$d.list
272+
if [ $verified -eq 0 ]; then
273+
echo "Downloaded artifacts were corrupted! Check the downloaded artifacts."
274+
exit 1
274275
fi
275-
done < dl.list
276-
if [ $verified -eq 0 ]; then
277-
echo "Downloaded artifacts were corrupted! Check the downloaded artifacts."
278-
exit 1
279-
fi
276+
done
277+
mkdir -p apt/repositories
278+
mkdir -p yum/repositories
280279
(cd apt/repositories && find . -name '*.zip' -exec unzip -u -o {} \;)
281280
(cd yum/repositories && find . -name '*.zip' -exec unzip -u -o {} \;)
282281
;;

0 commit comments

Comments
 (0)