Files
mistralrs-package/.gitea/workflows/poll-upstream.yml
grenade 16cae9972b fix(poll): in-flight guard + 6h cycle to stop build cancellation livelock
Hourly re-dispatch with cancel-in-progress cancelled healthy same-SHA
builds every cycle; prereleases could never publish. Skip dispatch when
a build run for the target workflow is already queued or executing, and
relax the poll to every 6 hours. Also repairs the previous commit which
stored this file base64-encoded.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 11:20:10 +00:00

187 lines
8.3 KiB
YAML

name: poll-upstream
on:
schedule:
- cron: "0 */6 * * *"
workflow_dispatch: {}
concurrency:
group: poll-upstream
cancel-in-progress: true
jobs:
check:
runs-on: fedora-43
steps:
- name: Get upstream latest tag
id: upstream
run: |
tag=$(curl -sSfL \
-H 'Accept: application/vnd.github+json' \
https://api.github.com/repos/EricLBuehler/mistral.rs/releases/latest \
| jq -r .tag_name)
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
echo "Upstream latest: ${tag}"
- name: Check if all packages are published
id: published
run: |
version="${UPSTREAM_TAG#v}"
needs_build=false
for target in "43:ampere" "43:ada" "43:blackwell"; do
fedora_version="${target%%:*}"
flavour="${target##*:}"
base_url="https://rpm.lair.cafe/fedora/${fedora_version}/x86_64"
rpm_name="mistralrs-${flavour}-${version}-1.fc${fedora_version}.x86_64.rpm"
# check that the rpm file exists
http_code=$(curl \
--silent \
--write-out "%{http_code}" \
--output /dev/null \
--head \
--url "${base_url}/${rpm_name}")
if [ "${http_code}" = "404" ]; then
echo "missing: ${base_url}/${rpm_name}"
needs_build=true
continue
elif [ "${http_code}" != "200" ]; then
echo "unexpected HTTP ${http_code} for ${base_url}/${rpm_name}"
exit 1
fi
echo "found: ${base_url}/${rpm_name}"
# check that the repo index references this package
if ! curl --silent --fail "${base_url}/repodata/repomd.xml" \
| grep --quiet 'primary'; then
echo "missing or invalid repomd.xml at ${base_url}/repodata/"
needs_build=true
continue
fi
if ! dnf repoquery \
--repofrompath=check,"${base_url}" \
--repo=check \
--quiet \
"mistralrs-${flavour}-${version}" 2>&1 \
| grep --quiet "mistralrs-${flavour}"; then
echo "repo index missing: mistralrs-${flavour}-${version} not in ${base_url}/repodata/"
needs_build=true
continue
fi
echo "indexed: mistralrs-${flavour}-${version} in ${base_url}/repodata/"
done
echo "already_built=$( [ "${needs_build}" = "true" ] && echo false || echo true )" >> "$GITHUB_OUTPUT"
env:
UPSTREAM_TAG: ${{ steps.upstream.outputs.tag }}
# In-flight guard: a dispatch while a build-release run is queued or
# executing would cancel it (concurrency cancel-in-progress) and restart
# identical work — builds longer than the poll interval could never
# finish. Skip dispatching and let the running build complete; the next
# poll re-checks the published RPMs.
- name: Check for in-flight release build
id: inflight
run: |
count=$(curl --fail --silent --show-error --location \
--header "Authorization: token ${{ secrets.DISPATCH_TOKEN }}" \
--url "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/runs?limit=50" \
| jq '[.workflow_runs[]
| select(.path | endswith("build-release.yml"))
| select(.status != "completed")] | length')
echo "count=${count}" >> "$GITHUB_OUTPUT"
echo "in-flight build-release runs: ${count}"
- name: Trigger build workflow
if: steps.published.outputs.already_built == 'false' && steps.inflight.outputs.count == '0'
run: |
curl --fail --silent --show-error --location \
--request POST \
--header "Authorization: token ${{ secrets.DISPATCH_TOKEN }}" \
--header 'Content-Type: application/json' \
--url "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/workflows/build-release.yml/dispatches" \
--data "{\"ref\":\"refs/heads/main\",\"inputs\":{\"tag\":\"${{ steps.upstream.outputs.tag }}\"}}"
check-prerelease:
runs-on: fedora-43
steps:
- name: Get upstream main branch HEAD
id: upstream
run: |
response=$(curl --silent --show-error --fail --location \
--header 'Accept: application/vnd.github+json' \
--url 'https://api.github.com/repos/EricLBuehler/mistral.rs/commits/master')
sha=$(echo "${response}" | jq -r .sha)
short_sha=$(echo "${sha}" | head --bytes=7)
date=$(echo "${response}" | jq -r '.commit.committer.date[:10]' | tr -d '-')
echo "sha=${sha}" >> "$GITHUB_OUTPUT"
echo "short_sha=${short_sha}" >> "$GITHUB_OUTPUT"
echo "date=${date}" >> "$GITHUB_OUTPUT"
echo "Upstream main HEAD: ${sha} (${date})"
- name: Get version from upstream Cargo.toml
id: version
run: |
version=$(curl --silent --show-error --fail --location \
--header 'Accept: application/vnd.github.raw+json' \
--url "https://api.github.com/repos/EricLBuehler/mistral.rs/contents/Cargo.toml?ref=${{ steps.upstream.outputs.sha }}" \
| grep '^version' | head --lines=1 | sed 's/.*"\(.*\)".*/\1/')
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "Upstream Cargo.toml version: ${version}"
- name: Check if prerelease is already published
id: published
run: |
prerelease="0.1.${UPSTREAM_DATE}git${UPSTREAM_SHORT_SHA}"
needs_build=false
for target in "43:ampere" "43:ada" "43:blackwell"; do
fedora_version="${target%%:*}"
flavour="${target##*:}"
base_url="https://rpm.lair.cafe/fedora/${fedora_version}/x86_64/unstable"
rpm_name="mistralrs-${flavour}-${UPSTREAM_VERSION}-${prerelease}.fc${fedora_version}.x86_64.rpm"
http_code=$(curl \
--silent \
--write-out "%{http_code}" \
--output /dev/null \
--head \
--url "${base_url}/${rpm_name}")
if [ "${http_code}" = "404" ]; then
echo "missing: ${base_url}/${rpm_name}"
needs_build=true
continue
elif [ "${http_code}" != "200" ]; then
echo "unexpected HTTP ${http_code} for ${base_url}/${rpm_name}"
exit 1
fi
echo "found: ${base_url}/${rpm_name}"
done
echo "already_built=$( [ "${needs_build}" = "true" ] && echo false || echo true )" >> "$GITHUB_OUTPUT"
env:
UPSTREAM_VERSION: ${{ steps.version.outputs.version }}
UPSTREAM_DATE: ${{ steps.upstream.outputs.date }}
UPSTREAM_SHORT_SHA: ${{ steps.upstream.outputs.short_sha }}
# Same in-flight guard as the release job: never cancel a healthy
# same-SHA build by re-dispatching over it.
- name: Check for in-flight prerelease build
id: inflight
run: |
count=$(curl --fail --silent --show-error --location \
--header "Authorization: token ${{ secrets.DISPATCH_TOKEN }}" \
--url "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/runs?limit=50" \
| jq '[.workflow_runs[]
| select(.path | endswith("build-prerelease.yml"))
| select(.status != "completed")] | length')
echo "count=${count}" >> "$GITHUB_OUTPUT"
echo "in-flight build-prerelease runs: ${count}"
- name: Trigger prerelease build workflow
if: steps.published.outputs.already_built == 'false' && steps.inflight.outputs.count == '0'
run: |
curl --fail --silent --show-error --location \
--request POST \
--header "Authorization: token ${{ secrets.DISPATCH_TOKEN }}" \
--header 'Content-Type: application/json' \
--url "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/workflows/build-prerelease.yml/dispatches" \
--data "{\"ref\":\"refs/heads/main\",\"inputs\":{\"commit\":\"${{ steps.upstream.outputs.sha }}\",\"version\":\"${{ steps.version.outputs.version }}\",\"date\":\"${{ steps.upstream.outputs.date }}\",\"short_sha\":\"${{ steps.upstream.outputs.short_sha }}\"}}"