Skip to content

pkg(uwsm): update to 0.26.5 #3

pkg(uwsm): update to 0.26.5

pkg(uwsm): update to 0.26.5 #3

Workflow file for this run

# Triggers a Copr build of changed packages on every PR that touches
# packages/**, so we get build feedback (especially on the auto-version
# update PRs from check-package-versions.yml).
#
# Uses `copr-cli buildscm` instead of `build-package` so we can override
# the source committish to the PR head, not the project-configured branch.
name: Build COPR Packages (PR)
on:
pull_request:
branches:
- main
paths:
- 'packages/**'
concurrency:
group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number }}
cancel-in-progress: true
env:
COPR_PROJECT: binarypie/hypercube
permissions:
contents: read
pull-requests: write
jobs:
detect-changes:
# PRs from forks can't access secrets needed for copr-cli. The auto-update
# PRs from check-package-versions.yml come from the same repo, so this is
# what we want.
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.detect.outputs.packages }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq rpm
- name: Detect changed packages
id: detect
run: |
source ./scripts/packages/config.sh
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
CHANGED=""
for dir in packages/*/; do
pkg=$(basename "$dir")
[[ -v "PACKAGE_DEPS[$pkg]" ]] || continue
if git diff --name-only "$BASE_SHA" "$HEAD_SHA" | grep -q "^packages/$pkg/"; then
CHANGED="$CHANGED $pkg"
fi
done
CHANGED=$(echo "$CHANGED" | tr -s ' ' '\n' | grep -v '^$' | sort -u | tr '\n' ' ' | xargs)
echo "Changed packages: $CHANGED"
if [[ -z "$CHANGED" ]]; then
echo "packages=[]" >> $GITHUB_OUTPUT
else
JSON=$(echo "$CHANGED" | tr ' ' '\n' | jq -R . | jq -sc .)
echo "packages=$JSON" >> $GITHUB_OUTPUT
fi
build:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.packages != '[]' && needs.detect-changes.outputs.packages != '' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install COPR CLI
run: |
sudo apt-get update
sudo apt-get install -y python3-pip jq rpm
pip3 install copr-cli
- name: Configure COPR CLI
run: |
mkdir -p ~/.config
cat > ~/.config/copr << EOF
[copr-cli]
login = ${{ secrets.COPR_API_LOGIN }}
username = binarypie
token = ${{ secrets.COPR_API_TOKEN }}
copr_url = https://copr.fedorainfracloud.org
EOF
# Submit one buildscm per changed package, pinned to the PR head commit
# via --commit. Chains by layer using --after-build-id/--with-build-id
# the same way build-copr-packages.yml does for main-branch builds.
- name: Submit PR builds
id: submit
env:
CLONE_URL: ${{ github.event.pull_request.head.repo.clone_url }}
COMMITTISH: ${{ github.event.pull_request.head.sha }}
run: |
source ./scripts/packages/config.sh
PACKAGES_JSON='${{ needs.detect-changes.outputs.packages }}'
ALL_BUILD_IDS=""
PREV_LAYER_FIRST_ID=""
for layer_id in $(echo "${!BUILD_BATCHES[@]}" | tr ' ' '\n' | sort -n); do
LAYER_FIRST_ID=""
for pkg in ${BUILD_BATCHES[$layer_id]}; do
if ! echo "$PACKAGES_JSON" | jq -e --arg p "$pkg" 'index($p) != null' >/dev/null; then
continue
fi
ARGS=(--nowait
--clone-url "$CLONE_URL"
--commit "$COMMITTISH"
--subdir "packages/$pkg"
--spec "$pkg.spec")
if [[ -z "$LAYER_FIRST_ID" ]]; then
[[ -n "$PREV_LAYER_FIRST_ID" ]] && ARGS+=(--after-build-id "$PREV_LAYER_FIRST_ID")
else
ARGS+=(--with-build-id "$LAYER_FIRST_ID")
fi
echo "Submitting $pkg @ ${COMMITTISH:0:8}"
BUILD_OUTPUT=$(copr-cli buildscm "${ARGS[@]}" "${{ env.COPR_PROJECT }}" 2>&1) || {
echo "::error::Failed to submit $pkg"
echo "$BUILD_OUTPUT"
exit 1
}
echo "$BUILD_OUTPUT"
BUILD_ID=$(echo "$BUILD_OUTPUT" | grep -oP '^Created builds?:\s*\K\d+' | head -1)
if [[ -z "$BUILD_ID" ]]; then
echo "::error::Could not extract build ID for $pkg"
exit 1
fi
# pkg:build_id, space-separated
ALL_BUILD_IDS="$ALL_BUILD_IDS $pkg:$BUILD_ID"
[[ -z "$LAYER_FIRST_ID" ]] && LAYER_FIRST_ID="$BUILD_ID"
done
[[ -n "$LAYER_FIRST_ID" ]] && PREV_LAYER_FIRST_ID="$LAYER_FIRST_ID"
done
ALL_BUILD_IDS=$(echo "$ALL_BUILD_IDS" | xargs)
echo "build_pairs=$ALL_BUILD_IDS" >> $GITHUB_OUTPUT
- name: Comment on PR with build links
uses: actions/github-script@v9
with:
script: |
const pairs = '${{ steps.submit.outputs.build_pairs }}'.trim().split(/\s+/).filter(Boolean);
const marker = '<!-- copr-pr-build -->';
let body = `${marker}\n## COPR Build\n\nBuilds queued for commit \`${context.payload.pull_request.head.sha.slice(0,8)}\`:\n\n| Package | Build |\n|---|---|\n`;
for (const entry of pairs) {
const [pkg, id] = entry.split(':');
body += `| ${pkg} | [#${id}](https://copr.fedorainfracloud.org/coprs/binarypie/hypercube/build/${id}/) |\n`;
}
// Update existing comment if present, else create
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(c => c.body && c.body.startsWith(marker));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
- name: Watch all builds
id: watch
run: |
FAILED=""
for entry in ${{ steps.submit.outputs.build_pairs }}; do
pkg="${entry%%:*}"
build_id="${entry##*:}"
echo "Watching $pkg (#$build_id)..."
copr-cli watch-build "$build_id" || FAILED="$FAILED $pkg(#$build_id)"
done
if [[ -n "$FAILED" ]]; then
echo "::error::Failed builds:$FAILED"
echo "failed=$FAILED" >> $GITHUB_OUTPUT
exit 1
fi
- name: Cancel COPR builds on workflow cancellation
if: cancelled()
run: |
for entry in ${{ steps.submit.outputs.build_pairs }}; do
build_id="${entry##*:}"
copr-cli cancel "$build_id" || echo "Could not cancel $build_id"
done