[CI] Fix CI kernel compare (#1931)

With this PR, we find the latest merged PR that successfully passed
"Integration Tests".
This commit is contained in:
Keren Zhou
2023-07-12 13:06:34 -04:00
committed by GitHub
parent c615ce944c
commit 571c92f2a8
2 changed files with 41 additions and 29 deletions

View File

@@ -225,40 +225,52 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
OWNER_REPO="${{ github.repository }}"
PR_NUMBER=$(gh api --method GET repos/$OWNER_REPO/pulls -f state=closed | jq ".[] | select(.merged_at != null) | .number" | head -1)
echo "Last merged PR number: $PR_NUMBER"
echo "OWNER_REPO: $OWNER_REPO"
PR_NUMBERS=($(gh api --method GET repos/$OWNER_REPO/pulls -f state=closed | jq -r ".[] | select(.merged_at != null) | .number"))
BRANCH_NAME=$(gh api repos/$OWNER_REPO/pulls/$PR_NUMBER --jq '.head.ref')
echo "BRANCH_NAME: $BRANCH_NAME"
# Not all PRs go through integration tests
success=0
for PR_NUMBER in "${PR_NUMBERS[@]}"
do
echo "Last merged PR number: $PR_NUMBER"
BRANCH_NAME=$(gh api repos/$OWNER_REPO/pulls/$PR_NUMBER --jq '.head.ref')
echo "BRANCH_NAME: $BRANCH_NAME"
USER_ID=$(gh api repos/$OWNER_REPO/pulls/$PR_NUMBER --jq '.user.id')
echo "USER_ID: $USER_ID"
page=1
while true; do
run_id=$(gh api --method GET "repos/$OWNER_REPO/actions/runs?page=$page&per_page=100" | jq --arg branch_name "$BRANCH_NAME" '.workflow_runs[] | select(.head_branch == $branch_name)' | jq '.id' | head -1)
if [ "$run_id" != "" ]; then
echo "First run ID on branch $BRANCH_NAME is: $run_id"
WORKFLOW_RUN_ID=$run_id
page=1
while true; do
run_id=$(gh api --method GET "repos/$OWNER_REPO/actions/runs?page=$page&per_page=100" | jq --arg branch_name "$BRANCH_NAME" --arg run_name "Integration Tests" --arg user_id "$USER_ID" '.workflow_runs[] | select(.head_branch == $branch_name and .name == $run_name and .actor.id == ($user_id | tonumber))' | jq '.id' | head -1)
if [ "$run_id" != "" ]; then
echo "First run ID on branch $BRANCH_NAME is: $run_id"
WORKFLOW_RUN_ID=$run_id
break
fi
((page++))
done
echo "WORKFLOW_RUN_ID: $WORKFLOW_RUN_ID"
ARTIFACT_URL=$(gh api repos/$OWNER_REPO/actions/runs/$WORKFLOW_RUN_ID/artifacts | jq --arg artifact_name "$ARTIFACT_NAME" '.artifacts[] | select(.name == $artifact_name).archive_download_url' --raw-output)
echo "ARTIFACT_URL: $ARTIFACT_URL"
if [ -n "$ARTIFACT_URL" ]; then
echo "Downloading artifact: $ARTIFACT_URL"
curl --location --remote-header-name -H "Authorization: token $GH_TOKEN" -o reference.zip "$ARTIFACT_URL"
# Print the size of the downloaded artifact
echo "Artifact size (stat): $(stat --printf="%s bytes" reference.zip)"
echo "Artifact size (du): $(du -sh reference.zip)"
unzip reference.zip
tar -xzf artifacts.tar.gz
rm reference.zip
rm artifacts.tar.gz
mv cache reference
success=1
break
fi
((page++))
done
echo "WORKFLOW_RUN_ID: $WORKFLOW_RUN_ID"
ARTIFACT_URL=$(gh api repos/$OWNER_REPO/actions/runs/$WORKFLOW_RUN_ID/artifacts | jq --arg artifact_name "$ARTIFACT_NAME" '.artifacts[] | select(.name == $artifact_name).archive_download_url' --raw-output)
echo "ARTIFACT_URL: $ARTIFACT_URL"
if [ -n "$ARTIFACT_URL" ]; then
echo "Downloading artifact: $ARTIFACT_URL"
curl --location --remote-header-name -H "Authorization: token $GH_TOKEN" -o reference.zip "$ARTIFACT_URL"
# Print the size of the downloaded artifact
echo "Artifact size (stat): $(stat --printf="%s bytes" reference.zip)"
echo "Artifact size (du): $(du -sh reference.zip)"
unzip reference.zip
tar -xzf artifacts.tar.gz
rm reference.zip
rm artifacts.tar.gz
mv cache reference
else
if [ $success -eq 0 ]; then
echo "No artifact found with the name: $ARTIFACT_NAME"
exit 1
fi

View File

@@ -23,7 +23,7 @@ name_and_extension:
extension: ptx
- name: _kernel_0d1d2d345d6d7c89c1011c
extension: ptx
- name: _bwd_kernel_0d1d2d34d5d6d7d8d9d10d11d12d13d14d15c16d17d18d19c20d21d22d23c2425d26d27
- name: _bwd_kernel_0d1d2d34d5d6d7d8d9d10d11d12d13d14d15d16c17d18d19d20c21d22d23d24c2526d27d
extension: ptx
- name: _fwd_kernel_0d1d2d34d5d6d7d8d9d10c11d12d13d14c15d16d17d18c19d20d21d22c2324d25d
extension: ptx