Skip to content

Commit

Permalink
Fix importing multi-arch artifacts
Browse files Browse the repository at this point in the history
Convey architecture in artifact name
  • Loading branch information
rhaschke committed Feb 15, 2025
1 parent 9be8ba7 commit 08eb151
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/scheduled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
EXTRA_DEB_SOURCES: "deb [signed-by=/etc/apt/keyrings/ros-one-keyring.gpg] https://ros.packages.techfak.net ${{matrix.DEB_DISTRO}}-testing main"
# proceed from existing debs artifact if run_attempt > 1
DOWNLOAD_DEBS: ${{ github.run_attempt != '1' }}
DEBS_ARTIFACT_NAME: ${{ matrix.DEB_DISTRO }}-debs
DEBS_ARTIFACT_NAME: ${{ matrix.DEB_DISTRO }}-${{ matrix.ARCH }}-debs
SKIP_EXISTING: true
SKIP_KNOWN_FAILING: true
CONTINUE_ON_ERROR: true
Expand All @@ -46,4 +46,4 @@ jobs:
- name: Import build artifacts to reprepro server
uses: ./reprepro
with:
url: "${{ vars.DEPLOY_URL }}?run_id=${{ github.run_id }}&arch=x64"
url: "${{ vars.DEPLOY_URL }}?run_id=${{ github.run_id }}"
37 changes: 22 additions & 15 deletions reprepro/import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@ fi

# Sanity checks
[ ! -d "$INCOMING_DIR" ] && echo "Invalid incoming directory" && exit 1
[ -z "$ARCH" ] && echo "ARCH undefined" && exit 1
[ -z "$REPO" ] && echo "github repo undefined" && exit 1

# Translate ARCH x64 -> amd64
[ "$ARCH" == "x64" ] && ARCH="amd64"

function filter {
grep -vE "Exporting indices...|Deleting files no longer referenced..."
}

function import {
[ -z "$1" ] && echo "DISTRO undefined" && exit 1
[ -z "$2" ] && echo "ARCH undefined" && exit 1

local distro="$1-testing" # operate on -testing distro
local arch="$2"

# Translate arch x64 -> amd64
[ "$arch" == "x64" ] && arch="amd64"

# Import sources
if [ "$ARCH" == "amd64" ]; then
if [ "$arch" == "amd64" ]; then
printf "\nImporting source packages\n"
for f in "$INCOMING_DIR"/*.dsc; do
[ -f "$f" ] || break # Handle case of no files found
Expand All @@ -35,12 +38,12 @@ function import {
for f in "$INCOMING_DIR"/*.deb; do
[ -f "$f" ] || break # Handle case of no files found
echo "${f#"$INCOMING_DIR/"}"
reprepro -A "$ARCH" includedeb "$distro" "$f" | filter
reprepro -A "$arch" includedeb "$distro" "$f" | filter
done

# Save log files
mkdir -p "log/${distro%-testing}.$ARCH"
mv "$INCOMING_DIR"/*.log "log/${distro%-testing}.$ARCH"
mkdir -p "log/${distro%-testing}.$arch"
mv "$INCOMING_DIR"/*.log "log/${distro%-testing}.$arch"

# Cleanup files
(cd "$INCOMING_DIR" || exit 1; rm -f ./*.log ./*.deb ./*.dsc ./*.tar.gz ./*.tar.xz ./*.changes ./*.buildinfo)
Expand All @@ -53,7 +56,7 @@ function import {
# remove .ddeb suffix
f=${f%.ddeb}
mv "${f}.ddeb" "${f}.deb"
reprepro -A "$ARCH" -C main-dbg includedeb "$distro" "${f}.deb" | filter
reprepro -A "$arch" -C main-dbg includedeb "$distro" "${f}.deb" | filter
done
(cd "$INCOMING_DIR" || exit 1; rm ./*.deb)

Expand All @@ -70,9 +73,9 @@ function import {

# Download debs artifact(s)
if [ "$(ls -A "$INCOMING_DIR")" ]; then
[ -z "$DISTRO" ] && echo "Distribution undefined" && exit 1
echo "Importing existing files from incoming directory"
import "$DISTRO"
# shellcheck disable=SC2153 # DISTRO and ARCH might be unset
import "$DISTRO" "$ARCH"
else
if [ -z "$RUN_ID" ] ; then
# Retrieve RUN_ID of latest workflow run
Expand All @@ -83,11 +86,15 @@ else
for a in $artifacts; do
echo "Fetching artifact \"$a\" from https://github.com/$REPO/actions/runs/$RUN_ID"
gh --repo "$REPO" run download --name "$a" --dir "$INCOMING_DIR" "$RUN_ID" || continue
if [ "$distro" == "debs" ]; then
distro=$DISTRO

# parse distro and arch from artifact name <distro>-<arch>-debs
if [[ $a =~ ([^-]+)-([^-]+)(-debs)? ]]; then
distro=${BASH_REMATCH[1]}
arch=${BASH_REMATCH[2]}
else
distro=${a%-debs} # Remove -debs suffix from <distro>-debs artifact name
distro=$DISTRO
arch=$ARCH
fi
import "$distro"
import "$distro" "$arch"
done
fi
2 changes: 1 addition & 1 deletion reprepro/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def process(q: queue.Queue, distro: str, repo: str, arch: str, run_id: str):

@app.get("/import")
def reprepro_import(
request: Request, run_id: str, arch: str = "x64", distro: str = "jammy"
request: Request, run_id: str, arch: str = "", distro: str = "jammy"
):
kwargs = dict(
repo="ubi-agni/ros-builder-action", distro=distro, run_id=run_id, arch=arch
Expand Down

0 comments on commit 08eb151

Please sign in to comment.