Skip to content

Commit 3efa7f2

Browse files
ci: process artifacts by chroot (#61)
1 parent 54ac150 commit 3efa7f2

1 file changed

Lines changed: 58 additions & 35 deletions

File tree

.github/workflows/copr-ci.yml

Lines changed: 58 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ jobs:
162162
needs: package-init
163163
outputs:
164164
BUILD_ID: ${{ steps.build.outputs.BUILD_ID }}
165+
BUILD_ID_ALT: ${{ steps.chroots.outputs.BUILD_ID_ALT }}
165166
BUILD_CHANNEL: ${{ steps.get-properties.outputs.BUILD_CHANNEL }}
166167
BUILD_CANCEL: ${{ steps.build.outcome == 'cancelled' }}
167168
BUILD_SUCCESS: ${{ steps.build.outcome == 'success' }}
169+
CHROOTS: ${{ steps.chroots.outputs.CHROOTS }}
168170
runs-on: ubuntu-latest
169171
permissions:
170172
contents: read
@@ -237,6 +239,32 @@ jobs:
237239
bash submit
238240
fi
239241
242+
- name: Get chroots
243+
id: chroots
244+
if: always()
245+
env:
246+
BUILD_ID: ${{ steps.build.outputs.BUILD_ID }}
247+
run: |
248+
# get chroots and prefixed build_id
249+
build_url="https://copr.fedorainfracloud.org/api_3/build/${BUILD_ID}"
250+
data=$(curl -fsS --retry 3 "${build_url}")
251+
252+
# Extract build_id from source_package.url (matches the last path segment after 'srpm-builds/')
253+
build_id_alt=$(echo "${data}" | jq -r '.source_package.url' | sed -E 's#.*/srpm-builds/([0-9]+)/.*#\1#')
254+
echo "build_id_alt: ${build_id_alt}"
255+
256+
# Extract chroots
257+
chroots=$(echo "${data}" | jq -r '.chroots[]')
258+
echo "chroots:"
259+
echo "${chroots}"
260+
261+
{
262+
echo "BUILD_ID_ALT=${build_id_alt}"
263+
echo "CHROOTS<<EOF" # use heredoc for multiline output
264+
echo "${chroots}"
265+
echo "EOF"
266+
} >> "${GITHUB_OUTPUT}"
267+
240268
- name: Cancel Copr build
241269
if: >-
242270
always() &&
@@ -259,6 +287,8 @@ jobs:
259287
env:
260288
BUILD_CHANNEL: ${{ needs.build.outputs.BUILD_CHANNEL }}
261289
BUILD_ID: ${{ needs.build.outputs.BUILD_ID }}
290+
BUILD_ID_ALT: ${{ needs.build.outputs.BUILD_ID_ALT }}
291+
CHROOTS: ${{ needs.build.outputs.CHROOTS }}
262292
needs: build
263293
runs-on: ubuntu-latest
264294
permissions:
@@ -300,29 +330,16 @@ jobs:
300330
package=${PACKAGE_NAME}
301331
base_url="https://download.copr.fedorainfracloud.org/results/${INPUTS_COPR_OWNERNAME}/${BUILD_CHANNEL}"
302332
303-
# get chroots and prefixed build_id
304-
build_url="https://copr.fedorainfracloud.org/api_3/build/${BUILD_ID}"
305-
data=$(curl -fsS --retry 3 "${build_url}")
306-
307-
# Extract build_id from source_package.url (matches the last path segment after 'srpm-builds/')
308-
build_id_alt=$(echo "${data}" | jq -r '.source_package.url' | sed -E 's#.*/srpm-builds/([0-9]+)/.*#\1#')
309-
echo "build_id_alt: ${build_id_alt}"
310-
311-
# Extract chroots
312-
chroots=$(echo "${data}" | jq -r '.chroots[]')
313-
echo "chroots:"
314-
echo "${chroots}"
315-
316333
# Array of "name|url" pairs
317334
logs=(
318-
"source_builder|${base_url}/srpm-builds/${build_id_alt}/builder-live.log.gz"
319-
"source_backend|${base_url}/srpm-builds/${build_id_alt}/backend.log.gz"
335+
"source_builder|${base_url}/srpm-builds/${BUILD_ID_ALT}/builder-live.log.gz"
336+
"source_backend|${base_url}/srpm-builds/${BUILD_ID_ALT}/backend.log.gz"
320337
"import|https://copr-dist-git.fedorainfracloud.org/per-task-logs/${BUILD_ID}.log"
321338
)
322339
323-
for chroot in $chroots; do
324-
logs+=("builder_${chroot}|${base_url}/${chroot}/${build_id_alt}-${package}/builder-live.log.gz")
325-
logs+=("backend_${chroot}|${base_url}/${chroot}/${build_id_alt}-${package}/backend.log.gz")
340+
for chroot in ${CHROOTS}; do
341+
logs+=("builder_${chroot}|${base_url}/${chroot}/${BUILD_ID_ALT}-${package}/builder-live.log.gz")
342+
logs+=("backend_${chroot}|${base_url}/${chroot}/${BUILD_ID_ALT}-${package}/backend.log.gz")
326343
done
327344
328345
error=0
@@ -349,6 +366,7 @@ jobs:
349366
container: fedora:latest
350367
env:
351368
BUILD_ID: ${{ needs.build.outputs.BUILD_ID }}
369+
CHROOTS: ${{ needs.build.outputs.CHROOTS }}
352370
needs: build
353371
runs-on: ubuntu-latest
354372
permissions:
@@ -361,26 +379,31 @@ jobs:
361379
nodejs \
362380
zip
363381
364-
- name: Download build
365-
id: download-build
366-
run: |
367-
mkdir -p artifacts
368-
copr-cli \
369-
download-build \
370-
--dest . \
371-
--rpms \
372-
"${BUILD_ID}"
373-
374382
- name: Setup gh actions artifact client
375383
id: download-build-client
376-
if: steps.download-build.outcome == 'success'
377384
uses: lhotari/gh-actions-artifact-client@ef03990878cb292d789ee6c36b5bbc8369aa30ed # v2
378385

379-
- name: Upload artifacts
380-
if: steps.download-build-client.outcome == 'success'
386+
- name: Download and upload artifacts
387+
id: download-build
381388
run: |
382-
find . -type f -name "*.rpm" ! -name "*.src.rpm" | while read -r file; do
383-
name=build-$(basename "$file")
384-
echo "Uploading $name, file: $file"
385-
zip -j - "$file" | gh-actions-artifact-client.js upload "${name}" --retentionDays=7
389+
mkdir -p artifacts
390+
cd artifacts
391+
392+
for chroot in ${CHROOTS}; do
393+
echo "Downloading artifacts for chroot: ${chroot}"
394+
copr-cli \
395+
download-build \
396+
--chroot "${chroot}" \
397+
--dest . \
398+
--rpms \
399+
"${BUILD_ID}"
400+
401+
find . -type f -name "*.rpm" ! -name "*.src.rpm" | while read -r file; do
402+
name=build-$(basename "$file")
403+
echo "Uploading $name, file: $file"
404+
zip -j - "$file" | gh-actions-artifact-client.js upload "${name}" --retentionDays=7
405+
406+
# empty artifacts directory to free up runner space
407+
rm -rf ./*
408+
done
386409
done

0 commit comments

Comments
 (0)