Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions scripts/resolve-distro-validation-context.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,24 @@ if [[ "$GITHUB_EVENT_NAME" == "workflow_run" ]]; then
conclusion="$(jq -r '.workflow_run.conclusion' "$GITHUB_EVENT_PATH")"
head_sha="$(jq -r '.workflow_run.head_sha' "$GITHUB_EVENT_PATH")"

[[ "$head_sha" =~ ^[0-9a-f]{40}$ ]] || { echo "::error::Invalid triggering workflow head SHA: ${head_sha}" >&2; exit 1; }

# GET /commits/{sha}/pulls does not reliably resolve commits that only
# exist on a fork (reachable in this repo solely via the hidden
# refs/pull/<n>/head ref, never an actual branch). List open pull
# requests against resolute-qcom-devel directly and match on head.sha
# instead, which works the same for same-repo and fork-originated PRs.
pull_requests="$(
gh api "repos/${GITHUB_REPOSITORY}/commits/${head_sha}/pulls" \
gh api --paginate "repos/${GITHUB_REPOSITORY}/pulls" \
-H "Accept: application/vnd.github+json" \
--jq '[.[] | select(.base.ref == "resolute-qcom-devel" and .head.sha == "'"$head_sha"'")]'
-X GET \
-f state=open \
-f base=resolute-qcom-devel \
| jq -s --arg sha "$head_sha" '[.[][] | select(.head.sha == $sha)]'
)"
pr_count="$(jq 'length' <<< "$pull_requests")"
[[ "$pr_count" == "1" ]] || {
echo "::error::Expected exactly one resolute-qcom-devel pull request for ${head_sha}; found ${pr_count}." >&2
echo "::error::Expected exactly one open resolute-qcom-devel pull request for ${head_sha}; found ${pr_count}." >&2
exit 1
}
pr_number="$(jq -r '.[0].number' <<< "$pull_requests")"
Expand Down
12 changes: 10 additions & 2 deletions scripts/validate-distro-validation-callback.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,18 @@ jq -e \
exit 1
}

# GET /commits/{sha}/pulls does not reliably resolve commits that only
# exist on a fork (reachable in this repo solely via the hidden
# refs/pull/<n>/head ref, never an actual branch). List open pull
# requests against resolute-qcom-devel directly and match on head.sha
# instead, which works the same for same-repo and fork-originated PRs.
pull_requests="$(
gh api "repos/qualcomm-linux/pkg-linux-qcom-canonical/commits/${head_sha}/pulls" \
gh api --paginate "repos/qualcomm-linux/pkg-linux-qcom-canonical/pulls" \
-H "Accept: application/vnd.github+json" \
--jq '[.[] | select(.base.ref == "resolute-qcom-devel" and .head.sha == "'"$head_sha"'")]'
-X GET \
-f state=open \
-f base=resolute-qcom-devel \
| jq -s --arg sha "$head_sha" '[.[][] | select(.head.sha == $sha)]'
)"
[[ "$(jq 'length' <<< "$pull_requests")" == "1" ]] || { echo "::error::Unable to identify one matching Canonical pull request." >&2; exit 1; }
[[ "$(jq -r '.[0].number' <<< "$pull_requests")" == "$pr_number" ]] || { echo "::error::Callback pull request number does not match the kernel commit." >&2; exit 1; }
Expand Down
Loading