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
5 changes: 4 additions & 1 deletion .azuredevops/hipblas-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ trigger:

pr: none

jobs:
stages:
- stage: hipblas-common
jobs:
- template: ${{ variables.CI_COMPONENT_PATH }}/hipBLAS-common.yml@pipelines_repo
parameters:
sparseCheckoutDir: projects/hipblas-common
triggerDownstreamJobs: ${{ parameters.triggerDownstreamJobs }}
- template: templates/report-summary-check-wrapper.yml
5 changes: 4 additions & 1 deletion .azuredevops/hipblaslt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ trigger:

pr: none

jobs:
stages:
- stage: hipblaslt
jobs:
- template: ${{ variables.CI_COMPONENT_PATH }}/hipBLASLt.yml@pipelines_repo
parameters:
sparseCheckoutDir: projects/hipblaslt
triggerDownstreamJobs: ${{ parameters.triggerDownstreamJobs }}
- template: templates/report-summary-check-wrapper.yml
5 changes: 4 additions & 1 deletion .azuredevops/hipcub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ trigger:

pr: none

jobs:
stages:
- stage: hipcub
jobs:
- template: ${{ variables.CI_COMPONENT_PATH }}/hipCUB.yml@pipelines_repo
parameters:
sparseCheckoutDir: projects/hipcub
triggerDownstreamJobs: ${{ parameters.triggerDownstreamJobs }}
- template: templates/report-summary-check-wrapper.yml
5 changes: 4 additions & 1 deletion .azuredevops/hipfft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ trigger:

pr: none

jobs:
stages:
- stage: hipfft
jobs:
- template: ${{ variables.CI_COMPONENT_PATH }}/hipFFT.yml@pipelines_repo
parameters:
sparseCheckoutDir: projects/hipfft
triggerDownstreamJobs: ${{ parameters.triggerDownstreamJobs }}
- template: templates/report-summary-check-wrapper.yml
5 changes: 4 additions & 1 deletion .azuredevops/hiprand.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ trigger:

pr: none

jobs:
stages:
- stage: hiprand
jobs:
- template: ${{ variables.CI_COMPONENT_PATH }}/hipRAND.yml@pipelines_repo
parameters:
sparseCheckoutDir: projects/hiprand
triggerDownstreamJobs: ${{ parameters.triggerDownstreamJobs }}
- template: templates/report-summary-check-wrapper.yml
5 changes: 4 additions & 1 deletion .azuredevops/rocblas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ trigger:

pr: none

jobs:
stages:
- stage: rocblas
jobs:
- template: ${{ variables.CI_COMPONENT_PATH }}/rocBLAS.yml@pipelines_repo
parameters:
sparseCheckoutDir: projects/rocblas
triggerDownstreamJobs: ${{ parameters.triggerDownstreamJobs }}
- template: templates/report-summary-check-wrapper.yml
5 changes: 4 additions & 1 deletion .azuredevops/rocfft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ trigger:

pr: none

jobs:
stages:
- stage: rocfft
jobs:
- template: ${{ variables.CI_COMPONENT_PATH }}/rocFFT.yml@pipelines_repo
parameters:
sparseCheckoutDir: projects/rocfft
triggerDownstreamJobs: ${{ parameters.triggerDownstreamJobs }}
- template: templates/report-summary-check-wrapper.yml
5 changes: 4 additions & 1 deletion .azuredevops/rocprim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ trigger:

pr: none

jobs:
stages:
- stage: rocprim
jobs:
- template: ${{ variables.CI_COMPONENT_PATH }}/rocPRIM.yml@pipelines_repo
parameters:
sparseCheckoutDir: projects/rocprim
triggerDownstreamJobs: ${{ parameters.triggerDownstreamJobs }}
- template: templates/report-summary-check-wrapper.yml
5 changes: 4 additions & 1 deletion .azuredevops/rocrand.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ trigger:

pr: none

jobs:
stages:
- stage: rocrand
jobs:
- template: ${{ variables.CI_COMPONENT_PATH }}/rocRAND.yml@pipelines_repo
parameters:
sparseCheckoutDir: projects/rocrand
triggerDownstreamJobs: ${{ parameters.triggerDownstreamJobs }}
- template: templates/report-summary-check-wrapper.yml
5 changes: 4 additions & 1 deletion .azuredevops/rocsolver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ trigger:

pr: none

jobs:
stages:
- stage: rocsolver
jobs:
- template: ${{ variables.CI_COMPONENT_PATH }}/rocSOLVER.yml@pipelines_repo
parameters:
sparseCheckoutDir: projects/rocsolver
triggerDownstreamJobs: ${{ parameters.triggerDownstreamJobs }}
- template: templates/report-summary-check-wrapper.yml
5 changes: 4 additions & 1 deletion .azuredevops/rocthrust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ trigger:

pr: none

jobs:
stages:
- stage: rocthrust
jobs:
- template: ${{ variables.CI_COMPONENT_PATH }}/rocThrust.yml@pipelines_repo
parameters:
sparseCheckoutDir: projects/rocthrust
triggerDownstreamJobs: ${{ parameters.triggerDownstreamJobs }}
- template: templates/report-summary-check-wrapper.yml
19 changes: 19 additions & 0 deletions .azuredevops/templates/report-summary-check-wrapper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
stages:
- stage: report_successful
condition: succeeded()
jobs:
- template: report-summary-check.yml
parameters:
checkConclusion: success
- stage: report_failed
condition: failed()
jobs:
- template: report-summary-check.yml
parameters:
checkConclusion: failure
- stage: report_cancelled
condition: canceled() # note: only 1 L in canceled()
jobs:
- template: report-summary-check.yml
parameters:
checkConclusion: cancelled
112 changes: 112 additions & 0 deletions .azuredevops/templates/report-summary-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
parameters:
- name: checkConclusion
type: string
default: success
values:
- success
- failure
- cancelled

jobs:
- job: report_summary_check
displayName: 'Report check status: ${{ parameters.checkConclusion }}'
variables:
- group: assistant-librarian
pool:
vmImage: ubuntu-latest
steps:
- checkout: none
- task: Bash@3
displayName: Install GitHub CLI
condition: always()
inputs:
targetType: 'inline'
script: |
(type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& sudo mkdir -p -m 755 /etc/apt/sources.list.d \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh jq -y
- task: Bash@3
displayName: Report CI status to GitHub PR Summary Check
condition: always()
env:
APP_ID: $(APP_ID)
APP_INSTALLATION_ID: $(APP_INSTALLATION_ID)
APP_PRIVATE_KEY: $(APP_PRIVATE_KEY)
inputs:
targetType: 'inline'
script: |
if [[ ! "$(Build.SourceBranch)" =~ ^refs/pull/ ]]; then
echo "This is not a PR build. Exiting."
exit 0
fi

# APP_PRIVATE_KEY is generated with `base64 app_private_key.pem | tr -d '\n'`
echo "$APP_PRIVATE_KEY" | base64 -d > app_private_key.pem
Comment thread
danielsu-amd marked this conversation as resolved.
chmod 600 app_private_key.pem
create_jwt() {
local header=$(echo -n '{"alg":"RS256","typ":"JWT"}' | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n')
local payload=$(echo -n "{\"iat\":$(date +%s),\"exp\":$(($(date +%s) + 600)),\"iss\":\"$APP_ID\"}" | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n')
local unsigned_token="${header}.${payload}"
local signature=$(echo -n "$unsigned_token" | openssl dgst -sha256 -sign "app_private_key.pem" | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n')
echo "${unsigned_token}.${signature}"
}
JWT=$(create_jwt)
export GH_TOKEN=$(curl -sSX POST \
-H "Authorization: Bearer $JWT" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/app/installations/$APP_INSTALLATION_ID/access_tokens" | jq -r .token)

PR_NUMBER=$(echo "$(Build.SourceBranch)" | sed 's|refs/pull/\([0-9]*\)/.*|\1|')
PR_HEAD_SHA=$(curl -s "https://api.github.com/repos/ROCm/rocm-libraries/pulls/$PR_NUMBER" | jq -r '.head.sha')
CHECK=$(curl -s "https://api.github.com/repos/ROCm/rocm-libraries/commits/$PR_HEAD_SHA/check-runs" | jq -r '.check_runs[] | select(.name == "Azure CI Summary")')
CHECK_ID=$(echo "$CHECK" | jq -r '.id')
CHECK_SUMMARY=$(echo "$CHECK" | jq -r '.output.summary')
CHECK_TEXT=$(echo "$CHECK" | jq -r '.output.text')

if [[ -z "$CHECK_ID" ]]; then
echo "No Azure CI Summary check found for commit $PR_HEAD_SHA"
exit 0
fi
if [[ "$CHECK_SUMMARY" == *"$(Build.BuildId)"* ]]; then
CHECK_SUMMARY=$(echo "$CHECK_SUMMARY" | sed "s/buildId=$(Build.BuildId)[^|]*|[^|]*|/buildId=$(Build.BuildId)) | ${{ parameters.checkConclusion }} |/")
fi
if [[ "$CHECK_TEXT" == *"$(Build.BuildId)="* ]]; then
CHECK_TEXT=$(echo "$CHECK_TEXT" | sed "s/$(Build.BuildId)=[^;]*;/$(Build.BuildId)=${{ parameters.checkConclusion }};/")
fi

CHECK_STATUS=$(echo "$CHECK_TEXT" | grep -q "pending" && echo "in_progress" || echo "completed")
CHECK_CONCLUSION=$(echo "$CHECK_TEXT" | grep -q -e "cancelled" -e "failure" && echo "failure" || echo "success")

if [[ "$CHECK_STATUS" == "completed" ]]; then
gh_output=$(gh api repos/ROCm/rocm-libraries/check-runs/$CHECK_ID \
-X PATCH \
-f "name=Azure CI Summary" \
-f "head_sha=$PR_HEAD_SHA" \
-f "status=$CHECK_STATUS" \
-f "conclusion=$CHECK_CONCLUSION" \
-f "output[title]=Azure CI Summary" \
-f "output[summary]=$CHECK_SUMMARY" \
-f "output[text]=$CHECK_TEXT")
else
gh_output=$(gh api repos/ROCm/rocm-libraries/check-runs/$CHECK_ID \
-X PATCH \
-f "name=Azure CI Summary" \
-f "head_sha=$PR_HEAD_SHA" \
-f "output[title]=Azure CI Summary" \
-f "output[summary]=$CHECK_SUMMARY" \
-f "output[text]=$CHECK_TEXT")
fi

echo "Reported status '${{ parameters.checkConclusion }}' to summary check: $(echo "$gh_output" | jq -r '.id')"
if [[ "$CHECK_STATUS" == "completed" ]]; then
echo "All checks completed with overall conclusion: $CHECK_CONCLUSION"
else
echo "Some checks are still in progress: $CHECK_STATUS"
fi
echo "Summary check URL: $(echo "$gh_output" | jq -r '.html_url')"
5 changes: 4 additions & 1 deletion .azuredevops/tensile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ trigger:

pr: none

jobs:
stages:
- stage: tensile
jobs:
- template: ${{ variables.CI_COMPONENT_PATH }}/Tensile.yml@pipelines_repo
parameters:
sparseCheckoutDir: shared/tensile
triggerDownstreamJobs: ${{ parameters.triggerDownstreamJobs }}
- template: templates/report-summary-check-wrapper.yml
1 change: 0 additions & 1 deletion .github/scripts/pr_category_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def main(argv=None) -> None:
client = GitHubCLIClient()
changed_files = [file for file in client.get_changed_files(args.repo, int(args.pr))]


if not changed_files:
logger.warning("REST API failed or returned no changed files. Falling back to Git CLI...")
try:
Expand Down
16 changes: 16 additions & 0 deletions .github/scripts/pr_detect_changed_subtrees.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ def main(argv=None) -> None:
client = GitHubCLIClient()
config = load_repo_config(args.config)
changed_files = client.get_changed_files(args.repo, int(args.pr))

if not changed_files:
logger.warning("REST API failed or returned no changed files. Falling back to Git CLI...")
try:
# Ensure fetch is safe
os.system("git fetch origin +refs/pull/*/merge:refs/remotes/origin/pr/*")
# Get merge commit ref for this PR
base_ref = f"origin/{os.getenv('GITHUB_BASE_REF', 'main')}"
head_ref = "HEAD" # Assumes checkout to PR merge ref
result = os.popen(f"git diff --name-only {base_ref}...{head_ref}").read()
changed_files = result.strip().splitlines()
logger.info(f"Fallback changed files: {changed_files}")
except Exception as e:
logger.error(f"Git CLI fallback failed: {e}")
sys.exit(1)

valid_prefixes = get_valid_prefixes(config, args.require_auto_pull, args.require_auto_push)
matched_subtrees = find_matched_subtrees(changed_files, valid_prefixes)
output_subtrees(matched_subtrees, args.dry_run)
Expand Down
Loading