5f988a8270
- Enhanced CI workflows and GitHub actions to support native artifact caching and parallel builds. - Added composite actions and scripts for computing sources, finding artifacts, and managing caches. - Updated infrastructure documentation and runner deployment scripts with revised resource limits.
100 lines
4.0 KiB
YAML
100 lines
4.0 KiB
YAML
name: Find reusable native artifacts
|
|
description: Find complete trusted native artifact sets for one source hash, including canceled main runs.
|
|
|
|
inputs:
|
|
hash:
|
|
description: Native source hash embedded in artifact names
|
|
required: true
|
|
|
|
outputs:
|
|
linux-x64-run-id:
|
|
description: Run containing both Linux x64 variants
|
|
value: ${{ steps.find.outputs.linux-x64-run-id }}
|
|
cross-platform-run-id:
|
|
description: Run containing every cross-platform artifact
|
|
value: ${{ steps.find.outputs.cross-platform-run-id }}
|
|
validation-run-id:
|
|
description: Run containing the successful Rust validation marker
|
|
value: ${{ steps.find.outputs.validation-run-id }}
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Find complete artifact sets
|
|
id: find
|
|
shell: bash
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
REPOSITORY: ${{ github.repository }}
|
|
REPOSITORY_ID: ${{ github.repository_id }}
|
|
SOURCE_HASH: ${{ inputs.hash }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
artifact_run_ids() {
|
|
local artifact_name="$1"
|
|
gh api --paginate "/repos/${REPOSITORY}/actions/artifacts?name=${artifact_name}&per_page=100" \
|
|
--jq ".artifacts[] | select(.expired == false and .workflow_run.head_branch == \"main\" and .workflow_run.head_repository_id == ${REPOSITORY_ID}) | .workflow_run.id" \
|
|
| sort -rn | uniq
|
|
}
|
|
|
|
find_complete_run() {
|
|
local canary="$1"
|
|
shift
|
|
local candidate names required complete
|
|
while read -r candidate; do
|
|
[ -n "$candidate" ] || continue
|
|
names="$(gh api "/repos/${REPOSITORY}/actions/runs/${candidate}/artifacts?per_page=100" \
|
|
--jq '.artifacts[] | select(.expired == false) | .name')"
|
|
complete=true
|
|
for required in "$@"; do
|
|
if ! grep -qFx "$required" <<<"$names"; then
|
|
complete=false
|
|
break
|
|
fi
|
|
done
|
|
if $complete; then
|
|
echo "$candidate"
|
|
return 0
|
|
fi
|
|
done < <(artifact_run_ids "$canary")
|
|
}
|
|
|
|
linux_baseline="pi-natives-linux-x64-baseline-h${SOURCE_HASH}"
|
|
linux_modern="pi-natives-linux-x64-modern-h${SOURCE_HASH}"
|
|
cross_required=(
|
|
"pi-natives-linux-arm64-h${SOURCE_HASH}"
|
|
"pi-natives-linux-musl-x64-baseline-h${SOURCE_HASH}"
|
|
"pi-natives-linux-musl-arm64-h${SOURCE_HASH}"
|
|
"pi-natives-darwin-x64-baseline-h${SOURCE_HASH}"
|
|
"pi-natives-darwin-arm64-h${SOURCE_HASH}"
|
|
"pi-natives-win32-x64-baseline-h${SOURCE_HASH}"
|
|
)
|
|
validation_marker="pi-natives-rust-validation-h${SOURCE_HASH}"
|
|
|
|
linux_x64_run_id="$(find_complete_run "$linux_modern" "$linux_baseline" "$linux_modern")"
|
|
cross_platform_run_id="$(find_complete_run "${cross_required[3]}" "${cross_required[@]}")"
|
|
validation_run_id="$(find_complete_run "$validation_marker" "$validation_marker")"
|
|
|
|
if [ -n "$linux_x64_run_id" ]; then
|
|
echo "Reusing Linux x64 native artifacts from run $linux_x64_run_id"
|
|
else
|
|
echo "No complete Linux x64 artifact set for hash $SOURCE_HASH"
|
|
fi
|
|
if [ -n "$cross_platform_run_id" ]; then
|
|
echo "Reusing cross-platform native artifacts from run $cross_platform_run_id"
|
|
else
|
|
echo "No complete cross-platform artifact set for hash $SOURCE_HASH"
|
|
fi
|
|
if [ -n "$validation_run_id" ]; then
|
|
echo "Reusing Rust validation from run $validation_run_id"
|
|
else
|
|
echo "No Rust validation marker for hash $SOURCE_HASH"
|
|
fi
|
|
|
|
{
|
|
echo "linux-x64-run-id=$linux_x64_run_id"
|
|
echo "cross-platform-run-id=$cross_platform_run_id"
|
|
echo "validation-run-id=$validation_run_id"
|
|
} >> "$GITHUB_OUTPUT"
|