Reset state of repo with updated README

This commit is contained in:
amd-jmacaran committed 2025-07-15 12:29:35 -04:00
commit c3f8f57c80
43 files changed
+4718

No files matched your search

+32
Vedi File
@@ -0,0 +1,32 @@
name: Apply Labels
on:
workflow_dispatch:
inputs:
labelFile:
description: 'Path to YAML file with labels'
required: true
default: '.github/labels.yml'
jobs:
apply-labels:
runs-on: ubuntu-latest
steps:
- name: Checkout monorepo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: pip install PyYAML requests
- name: Apply labels to monorepo
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
run: |
python .github/scripts/apply-labels.py "${{ github.event.inputs.labelFile }}"
@@ -0,0 +1,330 @@
# Azure CI Dispatcher
# ------------------
# This workflow allows Azure CI to be centralized in a single PR check.
# It detects which subtrees (from a monorepo structure) were changed in a
# pull request, and automatically requests Azure CI runs for the corresponding
# subtrees.
#
# For any given subtree, if an upstream subtree is also included in the PR,
# it will not run CI for the downstream subtree.
# Eg. A PR that touches rocprim and rocthrust will only trigger rocprim CI.
#
# Requires an Azure Personal Access Token with permissions to manage builds.
# The token should be stored in the repository secrets as `AZ_PAT`.
name: Trigger Azure CI
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
- ready_for_review
branches:
- develop
- staging
- main
- release-staging/rocm-rel-7.*
concurrency:
group: azure-ci-dispatcher-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
dispatch-azure-ci:
name: Trigger Azure CI
if: github.repository == 'ROCm/rocm-libraries'
runs-on: ubuntu-latest
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: |
rocm-libraries
- name: Wait until refs/pull/${{ github.event.pull_request.number }}/merge exists
run: |
merge_ref="refs/pull/${{ github.event.pull_request.number }}/merge"
check_merge_ref() {
git ls-remote "https://github.com/ROCm/rocm-libraries" "$merge_ref" | grep -q "$merge_ref"
}
max_attempts=10
attempt=0
while [ $attempt -lt $max_attempts ]; do
if check_merge_ref; then
echo "$merge_ref found."
break
else
retry_delay=60
echo "$merge_ref not found. Retrying in $retry_delay seconds..."
sleep $retry_delay
fi
attempt=$((attempt + 1))
done
if [ $attempt -ge $max_attempts ]; then
echo "$merge_ref not found. Maximum attempts reached."
exit 1
fi
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
sparse-checkout: .github
sparse-checkout-cone-mode: true
token: ${{ steps.generate-token.outputs.token }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r .github/requirements.txt
- name: Detect changed subtrees
id: detect
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
python .github/scripts/pr_detect_changed_subtrees.py \
--repo "${{ github.repository }}" \
--pr "${{ github.event.pull_request.number }}" \
--config ".github/repos-config.json" \
--require-auto-push
- name: Cancel in-progress/not-started runs for current PR
id: cancel-in-progress
if: steps.detect.outputs.subtrees
run: |
pr_number=${{ github.event.pull_request.number }}
pr_filter_query="branchName=refs/pull/$pr_number/merge&repositoryType=GitHub&repositoryId=ROCm/rocm-libraries&api-version=7.1"
res=$(curl -sSX GET "https://dev.azure.com/ROCm-CI/ROCm-CI/_apis/build/builds?$pr_filter_query" \
-H "Content-Type: application/json")
runs=$(echo "$res" | jq -r ".value[] | select(.status == \"inProgress\" or .status == \"notStarted\") | .id")
if [ -z "$runs" ]; then
echo "No in-progress/not-started runs found for ROCm/rocm-libraries PR #$pr_number"
echo "status=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "Found in-progress/not-started runs for ROCm/rocm-libraries PR #$pr_number: $runs"
echo "status=true" >> $GITHUB_OUTPUT
for run_id in $runs; do
echo "Cancelling run ID: $run_id"
echo "Run URL: https://dev.azure.com/ROCm-CI/ROCm-CI/_build/results?buildId=$run_id"
response=$(curl -sSX PATCH "https://dev.azure.com/ROCm-CI/ROCm-CI/_apis/build/builds/$run_id?api-version=7.1" \
-u ":${{ secrets.AZ_PAT }}" \
-H "Content-Type: application/json" \
-d '{"status": "cancelling"}')
if [ $? -ne 0 ]; then
echo "Failed to cancel run ID: $run_id"
else
echo "Cancelled run ID: $run_id"
fi
done
- name: Rerun previous failed/cancelled runs for current PR merge commit
id: rerun-failed
if: steps.detect.outputs.subtrees && steps.cancel-in-progress.outputs.status == 'false'
run: |
pr_number=${{ github.event.pull_request.number }}
pr_merge_sha=$(curl -sSX GET "https://api.github.com/repos/ROCm/rocm-libraries/git/ref/pull/${pr_number}/merge" | jq -r '.object.sha')
pr_filter_query="branchName=refs/pull/$pr_number/merge&repositoryType=GitHub&repositoryId=ROCm/rocm-libraries&api-version=7.1"
res=$(curl -sSX GET "https://dev.azure.com/ROCm-CI/ROCm-CI/_apis/build/builds?$pr_filter_query" \
-H "Content-Type: application/json")
failed_runs_info=$(echo "$res" | jq -r ".value[] |
select((.result == \"failed\" or .result == \"canceled\")
and (.sourceVersion | contains(\"$pr_merge_sha\")))
| {id: .id, name: .definition.name}")
success_runs_info=$(echo "$res" | jq -r ".value[] |
select((.result == \"succeeded\")
and (.sourceVersion | contains(\"$pr_merge_sha\")))
| {id: .id, name: .definition.name}")
failed_run_ids=$(echo "$failed_runs_info" | jq -r '.id')
failed_project_names=$(echo "$failed_runs_info" | jq -r '.name')
success_run_ids=$(echo "$success_runs_info" | jq -r '.id')
success_project_names=$(echo "$success_runs_info" | jq -r '.name')
if [ -z "$failed_run_ids" ]; then
echo "No failed/cancelled runs found for ROCm/rocm-libraries PR #$pr_number at merge commit $pr_merge_sha"
echo "status=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "Found failed/cancelled runs for ROCm/rocm-libraries PR #$pr_number at merge commit $pr_merge_sha: ${failed_run_ids[*]}"
echo "Found successful runs for ROCm/rocm-libraries PR #$pr_number at merge commit $pr_merge_sha: ${success_run_ids[*]}"
echo "status=true" >> $GITHUB_OUTPUT
new_run_ids=()
for run_id in $failed_run_ids; do
echo "Rerunning failed run ID: $run_id"
echo "Run URL: https://dev.azure.com/ROCm-CI/ROCm-CI/_build/results?buildId=$run_id"
response=$(curl -sSX PATCH "https://dev.azure.com/ROCm-CI/ROCm-CI/_apis/build/builds/$run_id?retry=true&api-version=7.1" \
-u ":${{ secrets.AZ_PAT }}" \
-H "Content-Type: application/json")
if [ $? -ne 0 ]; then
echo "Failed to rerun run ID: $run_id"
else
echo "Rerun requested for run ID: $run_id"
new_run_ids+=("$run_id")
fi
done
echo "run_ids=${new_run_ids[*]}" >> $GITHUB_OUTPUT
echo "project_names=${failed_project_names[*]}" >> $GITHUB_OUTPUT
echo "success_run_ids=${success_run_ids[*]}" >> $GITHUB_OUTPUT
echo "success_project_names=${success_project_names[*]}" >> $GITHUB_OUTPUT
- name: Start new Azure CI runs
id: dispatch
if: steps.detect.outputs.subtrees && (steps.cancel-in-progress.outputs.status == 'true' || steps.rerun-failed.outputs.status == 'false')
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
echo "${{ steps.detect.outputs.subtrees }}" > changed_subtrees.txt
python .github/scripts/azure_resolve_subtree_deps.py \
--subtree-file changed_subtrees.txt \
> resolved_subtrees.txt
run_ids=()
project_names=()
while IFS= read -r line; do
IFS='=' read -r project_name definition_id <<< "$line"
echo "Requesting run for $project_name with definition ID $definition_id"
max_attempts=3
retry_delay=5
attempt=1
success=false
while [ $attempt -le $max_attempts ]; do
response=$(curl -sSX POST https://dev.azure.com/ROCm-CI/ROCm-CI/_apis/pipelines/$definition_id/runs?api-version=7.1 \
-u ":${{ secrets.AZ_PAT }}" \
-H "Content-Type: application/json" \
-d '{
"resources": {
"repositories": {
"self": {
"refName": "refs/pull/${{ github.event.pull_request.number }}/merge"
}
}
}
}')
if [ $? -eq 0 ]; then
success=true
break
fi
echo "Attempt $attempt failed. Retrying in $retry_delay seconds..."
sleep $retry_delay
attempt=$((attempt + 1))
done
if [ "$success" = true ]; then
run_id=$(echo "$response" | jq -r '.id' || echo "null")
if [ "$run_id" != "null" ]; then
echo "Run ID for $project_name: $run_id"
echo "Run URL: https://dev.azure.com/ROCm-CI/ROCm-CI/_build/results?buildId=$run_id"
run_ids+=("$run_id")
project_names+=("$project_name")
else
echo "Failed to request run for $project_name"
fi
else
echo "Failed to request run for $project_name after $max_attempts attempts"
fi
echo ""
done < resolved_subtrees.txt
echo "run_ids=${run_ids[*]}" >> $GITHUB_OUTPUT
echo "project_names=${project_names[*]}" >> $GITHUB_OUTPUT
- name: Create summary check
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
if [[ -n "${{ steps.dispatch.outputs.run_ids }}" && -n "${{ steps.dispatch.outputs.project_names }}" ]]; then # If new runs were started
run_ids=(${{ steps.dispatch.outputs.run_ids }})
project_names=(${{ steps.dispatch.outputs.project_names }})
elif [[ -n "${{ steps.rerun-failed.outputs.run_ids }}" && -n "${{ steps.rerun-failed.outputs.project_names }}" ]]; then # If reruns were requested
run_ids=(${{ steps.rerun-failed.outputs.run_ids }})
project_names=(${{ steps.rerun-failed.outputs.project_names }})
success_run_ids=(${{ steps.rerun-failed.outputs.success_run_ids }})
success_project_names=(${{ steps.rerun-failed.outputs.success_project_names }})
else
echo "No run IDs or project names found, skipping summary check creation."
exit 0
fi
pr_number=${{ github.event.pull_request.number }}
pr_head_sha=${{ github.event.pull_request.head.sha }}
pr_merge_sha=$(curl -sSX GET "https://api.github.com/repos/ROCm/rocm-libraries/git/ref/pull/${pr_number}/merge" | jq -r '.object.sha')
newline=$'\n'
summary="PR: [${{ github.event.pull_request.title }} #$pr_number](${{ github.event.pull_request.html_url }})${newline}${newline}"
summary+="HEAD: [$pr_head_sha](https://github.com/ROCm/rocm-libraries/commit/$pr_head_sha)${newline}${newline}"
summary+="MERGE: [$pr_merge_sha](https://github.com/ROCm/rocm-libraries/commit/$pr_merge_sha)${newline}${newline}"
summary+="### Pipelines triggered for this PR${newline}${newline}"
summary+="| Project | Run ID | Status |${newline}"
summary+="|--------------|--------|--------|${newline}"
if [[ -n "${success_run_ids[*]}" ]]; then
for i in "${!success_project_names[@]}"; do
summary+="| ${success_project_names[i]} | [${success_run_ids[i]}](https://dev.azure.com/ROCm-CI/ROCm-CI/_build/results?buildId=${success_run_ids[i]}) | success |${newline}"
done
fi
for i in "${!project_names[@]}"; do
summary+="| ${project_names[i]} | [${run_ids[i]}](https://dev.azure.com/ROCm-CI/ROCm-CI/_build/results?buildId=${run_ids[i]}) | pending |${newline}"
done
summary+="${newline}${newline}"
summary+="### Rerun instructions${newline}${newline}"
summary+="To request Azure to rerun jobs, click the \`Re-run all jobs\` button on the [corresponding \`Trigger Azure CI\` run](https://github.com/ROCm/rocm-libraries/actions/runs/${{ github.run_id }}).${newline}${newline}"
summary+="If there are any pending runs for this PR, they will be cancelled, and new runs will be started.${newline}${newline}"
summary+="If there are no pending runs, but there are existing failed or cancelled runs for this PR and merge SHA, the existing runs will be rerun.${newline}${newline}"
summary+="Otherwise, new runs will be started.${newline}${newline}"
text=""
if [[ -n "${success_run_ids[*]}" ]]; then
for i in "${!success_run_ids[@]}"; do
text+="${success_run_ids[i]}=success;"
done
fi
for i in "${!project_names[@]}"; do
text+="${run_ids[i]}=pending;"
done
gh_output=$(gh api repos/ROCm/rocm-libraries/check-runs \
-f "name=Azure CI Summary" \
-f "head_sha=$pr_head_sha" \
-f "status=in_progress" \
-f "output[title]=Azure CI Summary" \
-f "output[summary]=$summary" \
-f "output[text]=$text")
echo "Created summary check with ID: $(echo "$gh_output" | jq -r '.id')"
echo "Summary check URL: https://github.com/ROCm/rocm-libraries/pull/561/checks?check_run_id=$(echo "$gh_output" | jq -r '.id')"
+36
Vedi File
@@ -0,0 +1,36 @@
name: Collect Labels
on:
workflow_dispatch:
inputs:
repoListFile:
description: 'Path to JSON file with repo list'
required: true
default: '.github/repos-config.json'
jobs:
collect-labels:
runs-on: ubuntu-latest
steps:
- name: Checkout monorepo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: pip install PyYAML requests
- name: Collect labels from source repos
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python .github/scripts/collect-labels.py "${{ github.event.inputs.repoListFile }}"
- name: Print generated labels.yml
run: |
echo "Contents of labels.yml:"
cat .github/labels.yml
+44
Vedi File
@@ -0,0 +1,44 @@
name: Setup Monorepo
on:
workflow_dispatch:
env:
MONOREPO_URL: github.com/ROCm/rocm-libraries.git
MONOREPO_BRANCH: develop
jobs:
setup-monorepo:
runs-on: ubuntu-24.04
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout the Monorepo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{ steps.generate-token.outputs.token }}
- name: Set up Git user and Git LFS
run: |
git config user.name "assistant-librarian[bot]"
git config user.email "assistant-librarian[bot]@users.noreply.github.com"
- name: Add Repositories to the Monorepo
run: |
for repo in $(cat .github/repos-config.json | jq -r '.repositories[].name'); do
repo_name=$(cat .github/repos-config.json | jq -r ".repositories[] | select(.name == \"$repo\") | .reponame")
url=$(cat .github/repos-config.json | jq -r ".repositories[] | select(.name == \"$repo\") | .url")
branch=$(cat .github/repos-config.json | jq -r ".repositories[] | select(.name == \"$repo\") | .branch")
category=$(cat .github/repos-config.json | jq -r ".repositories[] | select(.name == \"$repo\") | .category")
git subtree add --prefix "${category}/${repo}" https://github.com/${url}.git "$branch"
done
- name: Push changes to Monorepo
run: git push https://${{ env.MONOREPO_URL }} ${{ env.MONOREPO_BRANCH }}
+135
Vedi File
@@ -0,0 +1,135 @@
# Import Issue Workflow
# ---------------------
# This workflow imports a single issue from a source repository into this monorepo repository,
# as part of a migration. It preserves key metadata including title, body, labels, and comment
# history with timestamps and authorship.
#
# Trigger: Manually via `workflow_dispatch` with the following inputs:
# - source_repo: Full source repository name (e.g., "ROCm/rocBLAS")
# - issue_number: Issue number in the source repository to import
#
# Steps:
# 1. Validate that the caller has 'admin' or 'maintain' permission on the monorepo
# 2. Fetch the issue body, title, labels, and comments using the GitHub CLI (`gh api`)
# 3. Create a new issue in the target repo, preserving:
# - Original title
# - Original body
# - All labels
# - A reference link back to the source issue
# 4. Recreate each comment from the original issue with:
# - Original comment body
# - Original author and timestamp
# 5. Post a comment on the original issue linking to the new one
#
# Notes:
# - This workflow requires GitHub App credentials (APP_ID and APP_PRIVATE_KEY)
# - Only issue metadata is migrated; cross-linked issues, reactions, assignees, and milestones are not yet handled
name: Import Subrepo Issue
on:
workflow_dispatch:
inputs:
source_repo:
description: 'Full name of subrepo repo (e.g., ROCm/rocBLAS)'
required: true
issue_number:
description: 'Issue number to import'
required: true
jobs:
import:
runs-on: ubuntu-24.04
permissions:
issues: write
contents: read
steps:
- name: Validate maintainer permissions
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Actor is: ${{ github.actor }}"
PERMISSION=$(gh api \
repos/${{ github.repository }}/collaborators/${{ github.actor }}/permission \
--jq .permission)
if [[ "$PERMISSION" != "admin" && "$PERMISSION" != "maintain" ]]; then
echo "❌ User ${{ github.actor }} is not authorized to run this workflow"
exit 1
fi
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Fetch issue and comments from source repo
id: fetch
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
gh api "repos/${{ github.event.inputs.source_repo }}/issues/${{ github.event.inputs.issue_number }}" > issue.json
gh api "repos/${{ github.event.inputs.source_repo }}/issues/${{ github.event.inputs.issue_number }}/comments" > comments.json
- name: Create issue in target repo
id: create
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
TITLE=$(jq -r .title issue.json)
AUTHOR=$(jq -r .user.login issue.json)
BODY=$(jq -r .body issue.json)
LINK_TO_OLD="**[Migrated from original issue] ${{ github.event.inputs.source_repo }}#${{ github.event.inputs.issue_number }}**"
AUTHOR_LINE="*Original issue author: @$AUTHOR*"
FULL_BODY=$(printf "%b\n\n%b\n\n%s" "$LINK_TO_OLD" "$AUTHOR_LINE" "$BODY")
# Read labels into array
mapfile -t LABELS < <(jq -r '.labels[].name' issue.json)
# Prepare gh api args for labels
LABEL_ARGS=()
for label in "${LABELS[@]}"; do
LABEL_ARGS+=( -f "labels[]=$label" )
done
if [ ${#LABEL_ARGS[@]} -gt 0 ]; then
NEW_ISSUE_JSON=$(gh api repos/${{ github.repository }}/issues \
-f title="$TITLE" \
-f body="$FULL_BODY" \
"${LABEL_ARGS[@]}")
else
NEW_ISSUE_JSON=$(gh api repos/${{ github.repository }}/issues \
-f title="$TITLE" \
-f body="$FULL_BODY")
fi
echo "$NEW_ISSUE_JSON" > new_issue.json
echo "new_issue_number=$(jq -r .number new_issue.json)" >> "$GITHUB_OUTPUT"
- name: Recreate comments on new issue
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
jq -c '.[]' comments.json | while read -r comment; do
AUTHOR=$(echo "$comment" | jq -r .user.login)
CREATED_AT=$(echo "$comment" | jq -r .created_at)
BODY=$(echo "$comment" | jq -r .body | sed 's/"/\\"/g')
ORIG_AUTHOR="**Comment by @$AUTHOR on $CREATED_AT**"
FORMATTED_BODY=$(printf "%b\n\n%s" "$ORIG_AUTHOR" "$BODY")
gh api "repos/${{ github.repository }}/issues/${{ steps.create.outputs.new_issue_number }}/comments" \
-f body="$FORMATTED_BODY"
done
- name: Optionally comment back on original issue
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
COMMENT="This issue has been migrated to: https://github.com/${{ github.repository }}/issues/${{ steps.create.outputs.new_issue_number }}"
gh api "repos/${{ github.event.inputs.source_repo }}/issues/${{ github.event.inputs.issue_number }}/comments" \
-f body="$COMMENT"
+40
Vedi File
@@ -0,0 +1,40 @@
name: Merge CODEOWNERS Files
on:
workflow_dispatch:
jobs:
merge-codeowners:
runs-on: ubuntu-latest
permissions:
contents: write # Required to commit and push changes
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: pip install pyyaml
- name: Run merge script
run: python .github/scripts/merge-codeowners.py
- name: Commit and push if changed
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .github/CODEOWNERS
if git diff --cached --quiet; then
echo "No changes to commit"
else
git commit -m "chore: merge CODEOWNERS files"
git push
fi
+27
Vedi File
@@ -0,0 +1,27 @@
name: Merge .gitmodules
on:
workflow_dispatch:
jobs:
combine-gitmodules:
runs-on: ubuntu-latest
steps:
- name: Checkout Monorepo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Run Merge Script
run: python .github/scripts/merge-submodules.py
- name: Commit Merged .gitmodules
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .gitmodules
git commit -m "Combine subrepo .gitmodules files into root" || echo "No changes"
git push
+130
Vedi File
@@ -0,0 +1,130 @@
# Auto Label PR
# -------------
# This GitHub Actions workflow automatically adds or removes labels on a pull request
# based on a custom Python script that analyzes the PR content and paths.
#
# Steps:
# - Run pr_category_label.py to determine which category labels to add/remove
# - Update labels on the PR using GitHub CLI (gh)
# - Check if the PR creator is a member of the specified organization and add/remove labels accordingly
name: Auto Label PR
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
- ready_for_review
branches:
- 'develop'
- 'staging'
- 'main'
- 'release-staging/rocm-rel-7.*'
# Ignore changes to top-level files and directories
# that are not part of the subtree structure
paths-ignore:
- '.github/**'
- 'docs/**'
- '*.md'
# ensure that the workflow is not running for the same PR multiple times at once
concurrency:
group: pr-auto-label-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: false
env:
ORG_TO_CHECK: ROCm
ORG_LABEL: "organization: ROCm"
EXTERNAL_LABEL: "external contribution"
jobs:
auto-label-pr:
runs-on: ubuntu-24.04
steps:
- name: Generate GitHub App token (only for branch PRs)
id: generate-token
if: ${{ !github.event.pull_request.head.repo.fork }}
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout workflows
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
sparse-checkout: '.github'
token: ${{ github.event.pull_request.head.repo.fork && secrets.GITHUB_TOKEN || steps.generate-token.outputs.token }}
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.12'
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install pydantic requests
- name: Set up Git user
run: |
git config user.name "assistant-librarian[bot]"
git config user.email "assistant-librarian[bot]@users.noreply.github.com"
- name: Compute Category Labels for PR
id: compute_labels
env:
# this env clause gets repeated, but it is safer than echo'ing secrets in the workflow
GH_TOKEN: ${{ github.event.pull_request.head.repo.fork && secrets.GITHUB_TOKEN || steps.generate-token.outputs.token }}
run: |
python .github/scripts/pr_category_label.py \
--repo ${{ github.repository }} \
--pr ${{ github.event.pull_request.number }}
- name: Update labels
env:
# this env clause gets repeated, but it is safer than echo'ing secrets in the workflow
GH_TOKEN: ${{ github.event.pull_request.head.repo.fork && secrets.GITHUB_TOKEN || steps.generate-token.outputs.token }}
run: |
if [ -n "${{ steps.compute_labels.outputs.label_remove }}" ]; then
gh pr edit "${{ github.event.pull_request.number }}" --remove-label "${{ steps.compute_labels.outputs.label_remove }}"
fi
if [ -n "${{ steps.compute_labels.outputs.label_add }}" ]; then
gh pr edit "${{ github.event.pull_request.number }}" --add-label "${{ steps.compute_labels.outputs.label_add }}"
fi
- name: Check if PR creator is in org or collaborator and label accordingly
env:
# this env clause gets repeated, but it is safer than echo'ing secrets in the workflow
GH_TOKEN: ${{ github.event.pull_request.head.repo.fork && secrets.GITHUB_TOKEN || steps.generate-token.outputs.token }}
run: |
if gh pr view "${{ github.event.pull_request.number }}" --json labels -q '.labels[].name' | grep -qFx "imported pr"; then
echo "Skipping org membership labeling for imported pull request."
exit 0
fi
PR_USER=$(gh pr view "${{ github.event.pull_request.number }}" --json author -q .author.login)
if [ "${{ github.event.pull_request.head.repo.fork }}" = true ]; then
# For fork PRs: check if user has any collaborator permission on the repo
PERMISSION=$(gh api repos/${{ github.repository }}/collaborators/$PR_USER/permission --jq '.permission' --silent)
if [ "$PERMISSION" = "admin" ] || [ "$PERMISSION" = "write" ] || [ "$PERMISSION" = "maintain" ]; then
gh pr edit "${{ github.event.pull_request.number }}" --add-label "${{ env.ORG_LABEL }}"
gh pr edit "${{ github.event.pull_request.number }}" --remove-label "${{ env.EXTERNAL_LABEL }}"
else
gh pr edit "${{ github.event.pull_request.number }}" --add-label "${{ env.EXTERNAL_LABEL }}"
gh pr edit "${{ github.event.pull_request.number }}" --remove-label "${{ env.ORG_LABEL }}"
fi
else
# For branch PRs (non-forks): check org membership via GitHub App token
if gh api orgs/${{ env.ORG_TO_CHECK }}/members/$PR_USER --silent; then
gh pr edit "${{ github.event.pull_request.number }}" --add-label "${{ env.ORG_LABEL }}"
gh pr edit "${{ github.event.pull_request.number }}" --remove-label "${{ env.EXTERNAL_LABEL }}"
else
gh pr edit "${{ github.event.pull_request.number }}" --add-label "${{ env.EXTERNAL_LABEL }}"
gh pr edit "${{ github.event.pull_request.number }}" --remove-label "${{ env.ORG_LABEL }}"
fi
fi
+161
Vedi File
@@ -0,0 +1,161 @@
# Import Subrepo PR Workflow
# --------------------------
# This workflow imports an open PR from a sub-repository into the monorepo.
# It is intended for maintainers to migrate pending pull requests from
# the subrepos, to help developers onboard to the monorepo sooner.
#
# Trigger: Manually via `workflow_dispatch` with the following inputs:
# - subrepo-prefix: Path within the monorepo where the subrepo lives (e.g., "projects/rocblas")
# - subrepo-pr-number: PR number in the subrepo to import
# - subrepo-repo: Full subrepo or fork name (e.g., "ROCm/rocBLAS" or "user/rocBLAS-fork")
# - subrepo-upstream: Canonical subrepo repo name (e.g., "ROCm/rocBLAS")
#
# Steps:
# 1. Validate that the caller has 'admin' or 'maintain' permission on the monorepo
# 2. Generate a GitHub App token for authenticated API access
# 3. Checkout only the necessary parts of the monorepo (sparse checkout)
# 4. Fetch PR metadata from the subrepo using GitHub CLI
# 5. Create a new branch and import the PR using `git subtree pull`
# 6. Create a corresponding draft PR in the monorepo with metadata preserved
#
# Notes:
# - This workflow requires GitHub App credentials (APP_ID and APP_PRIVATE_KEY)
# - The resulting monorepo PR is a draft and includes attribution to the original author
name: Import Subrepo PR
on:
workflow_dispatch:
inputs:
subrepo-prefix:
description: "Monorepo path prefix (e.g., projects/rocblas)"
required: true
subrepo-pr-number:
description: "Subrepo PR number to import"
required: true
subrepo-repo:
description: "Full name of subrepo repo or fork (e.g., ROCm/rocBLAS or user/rocBLAS-fork)"
required: true
subrepo-upstream:
description: "Canonical subrepo repo (e.g., ROCm/rocBLAS)"
required: true
monorepo-target-branch:
description: "Target branch in the monorepo (default: develop)"
required: false
default: "develop"
jobs:
import:
runs-on: ubuntu-24.04
steps:
- name: Validate maintainer permissions
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Actor is: ${{ github.actor }}"
PERMISSION=$(gh api \
repos/${{ github.repository }}/collaborators/${{ github.actor }}/permission \
--jq .permission)
if [[ "$PERMISSION" != "admin" && "$PERMISSION" != "maintain" ]]; then
echo "❌ User ${{ github.actor }} is not authorized to run this workflow"
exit 1
fi
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: |
.github
${{ github.event.inputs.subrepo-prefix }}
sparse-checkout-cone-mode: true
token: ${{ steps.generate-token.outputs.token }}
fetch-depth: 0 #for subtree operations
- name: Set up Git user
run: |
git config user.name "assistant-librarian[bot]"
git config user.email "assistant-librarian[bot]@users.noreply.github.com"
- name: Fetch subrepo PR info using gh
id: prdata
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
PR_JSON=$(gh pr view ${{ github.event.inputs.subrepo-pr-number }} \
--repo ${{ github.event.inputs.subrepo-upstream }} \
--json title,body,headRefName,headRepository,isDraft \
--jq '{title: .title, body: .body, head_ref: .headRefName, head_repo: .headRepository.cloneUrl, is_draft: .isDraft}')
echo "$PR_JSON" > pr.json
# properly escape backticks in title
TITLE=$(jq -r .title pr.json | sed 's/`/\\`/g')
echo "title=$TITLE" >> $GITHUB_OUTPUT
{
echo 'body<<EOF'
jq -r .body pr.json
echo 'EOF'
} >> $GITHUB_OUTPUT
echo "head_ref=$(jq -r .head_ref pr.json)" >> $GITHUB_OUTPUT
echo "head_repo=$(jq -r .head_repo pr.json)" >> $GITHUB_OUTPUT
echo "is_draft=$(jq -r .is_draft pr.json)" >> $GITHUB_OUTPUT
- name: Create new branch for import
id: import-branch
run: |
git fetch origin ${{ github.event.inputs.monorepo-target-branch }}
git checkout ${{ github.event.inputs.monorepo-target-branch }}
SANITIZED_BASE=$(echo "${{ github.event.inputs.monorepo-target-branch }}" | sed 's|/|_|g')
SANITIZED_REPO=$(echo "${{ github.event.inputs.subrepo-repo }}" | sed 's|/|_|g')
SANITIZED_REF=$(echo "${{ steps.prdata.outputs.head_ref }}" | sed 's|/|_|g')
IMPORT_BRANCH="import/${SANITIZED_BASE}/${SANITIZED_REPO}/${SANITIZED_REF}"
echo "import_branch=$IMPORT_BRANCH" >> $GITHUB_OUTPUT
git checkout -b "$IMPORT_BRANCH"
- name: Split subrepo prefix from main branch
run: |
git subtree pull --prefix=${{ github.event.inputs.subrepo-prefix }} https://github.com/${{ github.event.inputs.subrepo-repo }} ${{ steps.prdata.outputs.head_ref }}
git push origin ${{ steps.import-branch.outputs.import_branch }}
- name: Create monorepo PR
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
IMPORT_BRANCH="import/${{ github.event.inputs.subrepo-prefix }}/pr-${{ github.event.inputs.subrepo-pr-number }}"
PR_TITLE="${{ steps.prdata.outputs.title }}"
UPSTREAM_REPO="${{ github.event.inputs.subrepo-upstream }}"
SUBREPO_REPO="${{ github.event.inputs.subrepo-repo }}"
SUBREPO_PR_NUMBER="${{ github.event.inputs.subrepo-pr-number }}"
SUBREPO_URL="https://github.com/$UPSTREAM_REPO/pull/$SUBREPO_PR_NUMBER"
AUTHOR=$(gh pr view "$SUBREPO_PR_NUMBER" --repo "$UPSTREAM_REPO" --json author --jq .author.login)
echo "${{ steps.prdata.outputs.body }}" > pr_body.txt
{
echo ""
echo "---"
echo "🔁 Imported from [$UPSTREAM_REPO#$SUBREPO_PR_NUMBER]($SUBREPO_URL)"
echo "🧑‍💻 Originally authored by @$AUTHOR"
} >> pr_body.txt
DRAFT_FLAG=""
if [[ "${{ steps.prdata.outputs.is_draft }}" == "true" ]]; then
DRAFT_FLAG="--draft"
fi
gh pr create \
--base "${{ github.event.inputs.monorepo-target-branch }}" \
--head "${{ steps.import-branch.outputs.import_branch }}" \
--title "$PR_TITLE" \
--label "imported pr" \
$DRAFT_FLAG \
--body-file pr_body.txt
@@ -0,0 +1,109 @@
# Apply Patch to Subrepos After Merge (Manual Run)
# --------------------------------------------------
# This GitHub Actions workflow lets you manually run the patching logic for
# previously merged pull requests in the monorepo.
#
# It is useful for cases where the automatic patch workflow failed (e.g., due
# to fork PRs lacking secrets), or if configuration or credentials have changed.
#
# Key Steps:
# 1. Validate that the caller has 'admin' or 'maintain' permission on the monorepo.
# 2. Accept PR number as input.
# 3. Generate a GitHub App token for authentication.
# 4. Use a Python script to detect which subtrees were modified.
# 5. For each changed subtree:
# - Generate a patch from the merge commit for that subtree.
# - Determine the appropriate author (based on PR metadata or fallback).
# - Clone the target sub-repo and apply the patch.
# - Amend the commit message to include links to the monorepo PR and commit.
# - Push the commit directly to the sub-repo.
#
# This ensures downstream sub-repositories are updated to reflect changes
# made in the monorepo, even if the original automated job failed.
name: Manual Patch Rerun
on:
workflow_dispatch:
inputs:
pr:
description: 'Pull request number to rerun patch logic for'
required: true
jobs:
rerun-patch:
runs-on: ubuntu-24.04
steps:
- name: Validate maintainer permissions
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Actor is: ${{ github.actor }}"
PERMISSION=$(gh api \
repos/${{ github.repository }}/collaborators/${{ github.actor }}/permission \
--jq .permission)
if [[ "$PERMISSION" != "admin" && "$PERMISSION" != "maintain" ]]; then
echo "❌ User ${{ github.actor }} is not authorized to run this workflow"
exit 1
fi
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: .github
sparse-checkout-cone-mode: true
token: ${{ steps.generate-token.outputs.token }}
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.12'
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install pydantic requests
- name: Set up Git user
run: |
git config user.name "assistant-librarian[bot]"
git config user.email "assistant-librarian[bot]@users.noreply.github.com"
- name: Detect changed subtrees from merged PR
id: detect
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
python .github/scripts/pr_detect_changed_subtrees.py \
--repo "${{ github.repository }}" \
--pr "${{ github.event.inputs.pr }}" \
--config ".github/repos-config.json" \
--require-auto-push
- name: Checkout full repo with changed subtrees
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: |
.github
${{ steps.detect.outputs.subtrees }}
token: ${{ steps.generate-token.outputs.token }}
fetch-depth: 0
- name: Generate and apply patches
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
python .github/scripts/pr_merge_sync_patches.py \
--repo "${{ github.repository }}" \
--pr "${{ github.event.inputs.pr }}" \
--subtrees "${{ steps.detect.outputs.subtrees }}" \
--config ".github/repos-config.json" \
--debug
@@ -0,0 +1,127 @@
# Apply Patch to Subrepos After Merge
# -----------------------------------
# This GitHub Actions workflow runs on push commits. If it detects the push is from
# a pull request merged into the monorepo, then it continues to run the workflow.
# It identifies which subtrees (defined in .github/repos-config.json) were affected,
# generates a patch from the merge commit, and applies that patch to the corresponding
# sub-repositories by cloning them and committing the patch directly.
#
# Key Steps:
# 1. Generate a GitHub App token for authentication.
# 2. Checkout the monorepo at the merge commit.
# 3. Use a Python script to detect which subtrees were modified.
# 4. For each changed subtree:
# - Generate a patch from the merge commit for that subtree.
# - Determine the appropriate author (based on PR metadata or fallback).
# - Clone the target sub-repo and apply the patch.
# - Amend the commit message to include links to the monorepo PR and commit.
# - Push the commit directly to the sub-repo.
#
# This ensures downstream sub-repositories are updated to reflect changes
# made in the monorepo immediately after merge.
name: Merged PR to Patch Subrepos
on:
push:
branches:
- 'develop'
concurrency:
group: pr-merge-sync-patch-${{ github.sha }}
cancel-in-progress: false
jobs:
patch:
runs-on: ubuntu-24.04
outputs:
pr_number: ${{ steps.pr-check.outputs.pr }}
steps:
- name: Check if commit is a merged PR
id: pr-check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "🔍 Checking if commit is a merged PR..."
PR_NUMBER=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls --jq '.[0].number')
if [ -z "$PR_NUMBER" ]; then
echo "❌ No PR found for commit ${{ github.sha }}. Skipping."
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "✅ Found PR #$PR_NUMBER"
echo "skip=false" >> "$GITHUB_OUTPUT"
echo "pr=$PR_NUMBER" >> "$GITHUB_OUTPUT"
- name: Stop early if not a merged PR
if: steps.pr-check.outputs.skip == 'true'
run: echo "Skipping job."
- name: Generate a token
id: generate-token
if: steps.pr-check.outputs.skip != 'true'
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout config files only
if: steps.pr-check.outputs.skip != 'true'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: .github
sparse-checkout-cone-mode: true
token: ${{ steps.generate-token.outputs.token }}
- name: Set up Python
if: steps.pr-check.outputs.skip != 'true'
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.12'
- name: Install python dependencies
if: steps.pr-check.outputs.skip != 'true'
run: |
python -m pip install --upgrade pip
pip install pydantic requests
- name: Set up Git user
if: steps.pr-check.outputs.skip != 'true'
run: |
git config user.name "assistant-librarian[bot]"
git config user.email "assistant-librarian[bot]@users.noreply.github.com"
- name: Detect changed subtrees from merged PR
id: detect
if: steps.pr-check.outputs.skip != 'true'
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
python .github/scripts/pr_detect_changed_subtrees.py \
--repo "${{ github.repository }}" \
--pr "${{ steps.pr-check.outputs.pr }}" \
--config ".github/repos-config.json" \
--require-auto-push
- name: Checkout full repo with changed subtrees
if: steps.detect.outputs.subtrees
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: |
.github
${{ steps.detect.outputs.subtrees }}
token: ${{ steps.generate-token.outputs.token }}
fetch-depth: 0
- name: Generate and apply patches
if: steps.detect.outputs.subtrees
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
python .github/scripts/pr_merge_sync_patches.py \
--repo "${{ github.repository }}" \
--pr "${{ steps.pr-check.outputs.pr }}" \
--subtrees "${{ steps.detect.outputs.subtrees }}" \
--config ".github/repos-config.json" \
--debug
+103
Vedi File
@@ -0,0 +1,103 @@
name: "Pre-commit Format & Lint"
on:
pull_request:
branches:
- testbranch
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
# - name: Generate a token
# id: generate-token
# uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e
# with:
# app-id: ${{ secrets.APP_ID }}
# private-key: ${{ secrets.APP_PRIVATE_KEY }}
# owner: ${{ github.repository_owner }}
- name: Checkout code (initial)
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
sparse-checkout: .github
sparse-checkout-cone-mode: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pydantic requests pre-commit
sudo apt-get update
sudo apt-get install -y clang-format
- name: Configure Git
run: |
git config user.name "assistant-librarian[bot]"
git config user.email "assistant-librarian[bot]@users.noreply.github.com"
- name: Detect changed subtrees
id: detect
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python .github/scripts/pr_detect_changed_subtrees.py \
--repo "${{ github.repository }}" \
--pr "${{ github.event.pull_request.number }}" \
--config ".github/repos-config.json"
- name: Checkout full repo with changed subtrees
if: steps.detect.outputs.subtrees
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
sparse-checkout: |
.github
${{ steps.detect.outputs.subtrees }}
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
submodules: false
- name: Get list of changed files
id: changed-files
shell: bash
run: |
git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1
changed=$(git diff --name-only FETCH_HEAD HEAD)
files=$(echo "$changed" | tr '\n' ' ' | sed 's/ *$//')
echo "all_modified_files=$files" >> $GITHUB_OUTPUT
- name: Show changed-files output
run: |
echo "Changed files are: ${{ steps.changed-files.outputs.all_modified_files }}"
- name: Disable submodule recursion
run: git config submodule.recurse false
- name: Run and auto-commit pre-commit fixes
env:
GIT_AUTHOR_NAME: "assistant-librarian[bot]"
GIT_AUTHOR_EMAIL: "assistant-librarian[bot]@users.noreply.github.com"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
var="${{ steps.changed-files.outputs.all_modified_files }}"
read -r -a files <<<"$var"
if [ ${#files[@]} -eq 0 ]; then
echo "No files changed, skipping pre-commit."
exit 0
fi
echo "Running pre-commit on these files:"
printf " %s\n" "${files[@]}"
set +e
pre-commit run --files "${files[@]}" --show-diff-on-failure
set -e
git add "${files[@]}"
git fetch origin "${{github.head_ref}}"
if ! git diff --cached --quiet; then
git commit -m "ci: apply pre-commit fixes"
git push --force-with-lease origin HEAD:${{ github.head_ref }}
fi
+155
Vedi File
@@ -0,0 +1,155 @@
name: TheRock CI Linux
on:
workflow_call:
inputs:
cmake_options:
type: string
project_to_test:
type: string
subtree_checkout:
type: string
permissions:
contents: read
jobs:
therock-build-linux:
name: Build Linux Packages
runs-on: azure-linux-scale-rocm
permissions:
id-token: write
container:
image: ghcr.io/rocm/therock_build_manylinux_x86_64@sha256:044b113562629f4bd2ec5d2e64b32eee11562d48fb1a75d7493daec9dd8d8292
strategy:
fail-fast: true
env:
CACHE_DIR: ${{ github.workspace }}/.container-cache
CCACHE_DIR: "${{ github.workspace }}/.container-cache/ccache"
CCACHE_MAXSIZE: "700M"
AMDGPU_FAMILIES: "gfx94X-dcgpu"
TEATIME_FORCE_INTERACTIVE: 0
steps:
- name: Generate a token for rocm-libraries
id: generate-token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: "Checking out repository for rocm-libraries"
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: |
.github
${{ inputs.subtree_checkout }}
token: ${{ steps.generate-token.outputs.token }}
- name: Checkout TheRock repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: "ROCm/TheRock"
path: "TheRock"
- name: Runner Health Settings
run: |
echo "CCACHE_DIR=${CCACHE_DIR}"
df -h
ccache -z
mkdir -p $CCACHE_DIR
cmake --version
echo "Installed Python versions:"
ls -d /opt/python
echo "python: $(which python), python3: $(which python3)"
echo "Git version: $(git --version)"
git config --global --add safe.directory $PWD
git config fetch.parallel 10
- name: Fetch sources
run: |
./TheRock/build_tools/fetch_sources.py --jobs 12 --no-include-math-libs
- name: Install python deps
run: |
pip install -r TheRock/requirements.txt
pip freeze
- name: Configure Projects
env:
amdgpu_families: ${{ env.AMDGPU_FAMILIES }}
package_version: ADHOCBUILD
extra_cmake_options: "-DTHEROCK_USE_EXTERNAL_ROCM_LIBRARIES=ON -DTHEROCK_ROCM_LIBRARIES_SOURCE_DIR=../ ${{ inputs.cmake_options }}"
BUILD_DIR: build
run: |
python3 TheRock/build_tools/github_actions/build_configure.py
- name: Build therock-dist
run: cmake --build TheRock/build --target therock-dist
- name: Build therock-archives
run: cmake --build TheRock/build --target therock-archives
- name: Report
if: ${{ !cancelled() }}
run: |
echo "Full SDK du:"
echo "------------"
du -h -d 1 TheRock/build/dist/rocm
echo "Artifact Archives:"
echo "------------------"
ls -lh TheRock/build/artifacts/*.tar.xz
echo "Artifacts:"
echo "----------"
du -h -d 1 TheRock/build/artifacts
echo "CCache Stats:"
echo "-------------"
ccache -s
- name: Configure AWS Credentials
if: always()
uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::692859939525:role/therock-artifacts-external
- name: Create Logs index Files
if: always()
run: |
python3 TheRock/build_tools/github_actions/create_log_index.py \
--build-dir=TheRock/build \
--amdgpu-family=${{ env.AMDGPU_FAMILIES }}
- name: Upload artifacts
run: |
python TheRock/build_tools/github_actions/upload_build_artifacts.py \
--run-id ${{ github.run_id }} \
--amdgpu-family ${{ env.AMDGPU_FAMILIES }} \
--build-dir TheRock/build
- name: Upload Logs
if: always()
run: |
python3 TheRock/build_tools/github_actions/upload_build_logs_to_s3.py \
--build-dir=TheRock/build \
--run-id ${{ github.run_id }} \
--amdgpu-family ${{ env.AMDGPU_FAMILIES }}
- name: Add Links to Job Summary
if: always()
run: |
python TheRock/build_tools/github_actions/upload_build_summary.py \
--run-id ${{ github.run_id }} \
--amdgpu-family ${{ env.AMDGPU_FAMILIES }} \
--build-dir TheRock/build
therock-test-linux:
name: "Test"
needs: [therock-build-linux]
uses: ./.github/workflows/therock-test-packages.yml
with:
project_to_test: ${{ inputs.project_to_test }}
amdgpu_families: "gfx94X-dcgpu"
test_runs_on: "linux-mi300-1gpu-ossci-rocm"
platform: "linux"
+178
Vedi File
@@ -0,0 +1,178 @@
name: TheRock CI Windows
on:
workflow_call:
inputs:
cmake_options:
type: string
project_to_test:
type: string
subtree_checkout:
type: string
permissions:
contents: read
jobs:
therock-build-windows:
name: Build Windows Packages
runs-on: azure-windows-scale-rocm
outputs:
AMDGPU_FAMILIES: ${{ env.AMDGPU_FAMILIES }}
permissions:
contents: read
id-token: write
defaults:
run:
shell: bash
env:
BUILD_DIR: B:\build
CCACHE_DIR: "${{ github.workspace }}/.container-cache/ccache"
CCACHE_MAXSIZE: "700M"
# TODO(geomin12): Add matrix of families
# To get a fast signal of windows building for TheRock, adding gfx110X
AMDGPU_FAMILIES: "gfx110X-dgpu"
steps:
- name: Generate a token for rocm-libraries
id: generate-token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: "Checking out repository for rocm-libraries"
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: |
.github
${{ inputs.subtree_checkout }}
token: ${{ steps.generate-token.outputs.token }}
- name: Checkout TheRock repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: "ROCm/TheRock"
path: "TheRock"
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.12'
- name: Install python deps
run: |
pip install -r TheRock/requirements.txt
- name: Install requirements
run: |
choco install --no-progress -y ccache
choco install --no-progress -y ninja
choco install --no-progress -y strawberryperl
echo "$PATH;C:\Strawberry\c\bin" >> $GITHUB_PATH
choco install --no-progress -y awscli
echo "$PATH;C:\Program Files\Amazon\AWSCLIV2" >> $GITHUB_PATH
# After other installs, so MSVC get priority in the PATH.
- name: Configure MSVC
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
- name: Fetch sources
run: |
git config --global core.longpaths true
python ./TheRock/build_tools/fetch_sources.py --jobs 96 --no-include-math-libs
- name: Checkout closed source AMDGPU/ROCm interop library folder
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: nod-ai/amdgpu-windows-interop
path: amdgpu-windows-interop
lfs: true
- name: Configure Projects
env:
amdgpu_families: ${{ env.AMDGPU_FAMILIES }}
package_version: "ADHOCBUILD"
extra_cmake_options: "-DBUILD_TESTING=OFF -DTHEROCK_USE_EXTERNAL_ROCM_LIBRARIES=ON -DTHEROCK_ROCM_LIBRARIES_SOURCE_DIR=${{ github.workspace }} ${{ inputs.cmake_options }}"
run: |
# clear cache before build and after download
ccache -z
python3 TheRock/build_tools/github_actions/build_configure.py
- name: Build therock-dist
run: cmake --build "${{ env.BUILD_DIR }}" --target therock-dist
- name: Build therock-archives
run: cmake --build "${{ env.BUILD_DIR }}" --target therock-archives
- name: Report
if: ${{ !cancelled() }}
run: |
echo "Build dir:"
echo "------------"
ls -lh "${{ env.BUILD_DIR }}"
echo "Artifact Archives:"
echo "------------------"
ls -lh "${{ env.BUILD_DIR }}"/artifacts/*.tar.xz
echo "Artifacts:"
echo "----------"
du -h -d 1 "${{ env.BUILD_DIR }}"/artifacts
echo "CCache Stats:"
echo "-------------"
ccache -s
- name: "Build size report"
if: always()
shell: powershell
run: |
$fs = Get-PSDrive -PSProvider "FileSystem"
$fsout = $fs | Select-Object -Property Name,Used,Free,Root
$fsout | % {$_.Used/=1GB;$_.Free/=1GB;$_} | Write-Host
get-disk | Select-object @{Name="Size(GB)";Expression={$_.Size/1GB}} | Write-Host
- name: Configure AWS Credentials
if: always()
uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::692859939525:role/therock-artifacts-external
- name: Create Logs index Files
if: always()
run: |
python3 TheRock/build_tools/github_actions/create_log_index.py \
--build-dir=${{ env.BUILD_DIR }} \
--amdgpu-family=${{ env.AMDGPU_FAMILIES }}
- name: Upload artifacts
run: |
python TheRock/build_tools/github_actions/upload_build_artifacts.py \
--run-id ${{ github.run_id }} \
--amdgpu-family ${{ env.AMDGPU_FAMILIES }} \
--build-dir ${{ env.BUILD_DIR }}
- name: Upload Logs
if: always()
run: |
python3 TheRock/build_tools/github_actions/upload_build_logs_to_s3.py \
--build-dir=${{ env.BUILD_DIR }} \
--run-id ${{ github.run_id }} \
--amdgpu-family ${{ env.AMDGPU_FAMILIES }}
- name: Add Links to Job Summary
if: always()
run: |
python TheRock/build_tools/github_actions/upload_build_summary.py \
--run-id ${{ github.run_id }} \
--amdgpu-family ${{ env.AMDGPU_FAMILIES }} \
--build-dir ${{ env.BUILD_DIR }}
therock-test-windows:
name: "Test"
needs: [therock-build-windows]
uses: ./.github/workflows/therock-test-packages.yml
with:
project_to_test: ${{ inputs.project_to_test }}
amdgpu_families: ${{ needs.therock-build-windows.outputs.AMDGPU_FAMILIES }}
test_runs_on: ""
platform: "windows"
+122
Vedi File
@@ -0,0 +1,122 @@
name: TheRock CI
on:
push:
branches:
- develop
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
workflow_dispatch:
inputs:
projects:
type: string
description: "Insert space-separated list of projects to test or 'all' to test all projects. ex: 'projects/rocprim projects/hipcub'"
permissions:
contents: read
concurrency:
# A PR number if a pull request and otherwise the commit hash. This cancels
# queued and in-progress runs for the same PR (presubmit) or commit
# (postsubmit). The workflow name is prepended to avoid conflicts between
# different workflows.
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true
jobs:
setup:
name: "Setup"
runs-on: ubuntu-24.04
outputs:
projects: ${{ steps.projects.outputs.projects }}
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: .github
sparse-checkout-cone-mode: true
# # will be needed for `patch_monorepo.py` but necessary now
# - name: Checkout TheRock Repository
# uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
# with:
# repository: "ROCm/TheRock"
# path: "TheRock"
# ref: 0730cccf8b98e012d64750f26032bd760360fa45
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.12"
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install pydantic requests
# # For our "rocPRIM" MVP, there are no patches to apply. This will be un-commented and used later!
# - name: Patch monorepo
# run: |
# python TheRock/build_tools/github_actions/patch_monorepo.py \
# --repo rocm-libraries
- name: Detect changed subtrees
id: detect
if: github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python .github/scripts/pr_detect_changed_subtrees.py \
--repo "${{ github.repository }}" \
--pr "${{ github.event.pull_request.number }}" \
--config ".github/repos-config.json"
- name: Determine projects to run
id: projects
env:
SUBTREES: ${{ steps.detect.outputs.subtrees }}
PROJECTS: ${{ inputs.projects }}
# TODO(geomin12): #590 Enable TheRock CI for forked PRs
IS_FORKED_PR: ${{ github.event.pull_request.head.repo.fork == true }}
run: |
python .github/scripts/therock_configure_ci.py
therock-ci-linux:
name: TheRock CI Linux
permissions:
contents: read
id-token: write
needs: setup
if: ${{ needs.setup.outputs.projects != '[]' }}
strategy:
fail-fast: false
matrix:
projects: ${{ fromJSON(needs.setup.outputs.projects) }}
uses: ./.github/workflows/therock-ci-linux.yml
secrets: inherit
with:
cmake_options: ${{ matrix.projects.cmake_options }}
project_to_test: ${{ matrix.projects.project_to_test }}
subtree_checkout: ${{ matrix.projects.subtree_checkout }}
therock-ci-windows:
name: TheRock CI Windows
permissions:
contents: read
id-token: write
needs: setup
if: ${{ needs.setup.outputs.projects != '[]' }}
strategy:
fail-fast: false
matrix:
projects: ${{ fromJSON(needs.setup.outputs.projects) }}
uses: ./.github/workflows/therock-ci-windows.yml
secrets: inherit
with:
cmake_options: ${{ matrix.projects.cmake_options }}
project_to_test: ${{ matrix.projects.project_to_test }}
subtree_checkout: ${{ matrix.projects.subtree_checkout }}
@@ -0,0 +1,80 @@
name: TheRock Test Packages
on:
workflow_call:
inputs:
project_to_test:
type: string
amdgpu_families:
type: string
test_runs_on:
type: string
platform:
type: string
permissions:
contents: read
jobs:
configure_test_matrix:
name: "Configure test matrix"
runs-on: ubuntu-24.04
if: ${{ inputs.test_runs_on != '' }}
outputs:
components: ${{ steps.configure.outputs.components }}
steps:
- name: "Checking out repository"
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: "ROCm/TheRock"
- name: "Configuring CI options"
env:
PLATFORM: ${{ inputs.platform }}
project_to_test: ${{ inputs.project_to_test }}
id: configure
run: python ./build_tools/github_actions/fetch_test_configurations.py
test_components:
name: 'Test ${{ matrix.components.job_name }}'
runs-on: ${{ inputs.test_runs_on }}
needs: configure_test_matrix
# skip tests if no test matrix to run
if: ${{ needs.configure_test_matrix.outputs.components != '[]' }}
strategy:
fail-fast: false
matrix:
components: ${{ fromJSON(needs.configure_test_matrix.outputs.components) }}
defaults:
run:
shell: bash
env:
VENV_DIR: ${{ github.workspace }}/.venv
ARTIFACT_RUN_ID: "${{ github.run_id }}"
OUTPUT_ARTIFACTS_DIR: ${{ github.workspace }}/build
THEROCK_BIN_DIR: "./build/bin"
steps:
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: "ROCm/TheRock"
- name: Run setup test environment workflow
uses: './.github/actions/setup_test_environment'
with:
ARTIFACT_RUN_ID: ${{ env.ARTIFACT_RUN_ID }}
AMDGPU_FAMILIES: ${{ inputs.amdgpu_families }}
OUTPUT_ARTIFACTS_DIR: ${{ env.OUTPUT_ARTIFACTS_DIR }}
VENV_DIR: ${{ env.VENV_DIR }}
FETCH_ARTIFACT_ARGS: ${{ matrix.components.fetch_artifact_args }}
PLATFORM: ${{ inputs.platform }}
- name: Install additional packages
if: ${{ inputs.platform == 'linux' && (matrix.components.job_name == 'rocblas' || matrix.components.job_name == 'hipblaslt') }}
run: sudo apt install libgfortran5 -y
- name: Test
timeout-minutes: ${{ matrix.components.timeout_minutes }}
run: |
if [ "${{ inputs.PLATFORM }}" == "linux" ]; then source ${VENV_DIR}/bin/activate ; else . ${VENV_DIR}/Scripts/activate ; fi
${{ matrix.components.test_script }}
@@ -0,0 +1,75 @@
name: Synchronize Release Staging Subtrees
on:
workflow_dispatch:
schedule:
- cron: '0 * * * *'
env:
MONOREPO_URL: github.com/ROCm/rocm-libraries.git
MONOREPO_BRANCH: release-staging/rocm-rel-7.0
concurrency:
group: pr-update-subtrees-develop
cancel-in-progress: false
jobs:
synchronize-subtrees:
runs-on: ubuntu-24.04
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout the Monorepo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0 # needed for git subtree pull/push
token: ${{ steps.generate-token.outputs.token }}
ref: ${{ env.MONOREPO_BRANCH }}
- name: Set up Git user
run: |
git config user.name "assistant-librarian[bot]"
git config user.email "assistant-librarian[bot]@users.noreply.github.com"
- name: Switch to the Monorepo branch
run: |
git checkout -B "${{ env.MONOREPO_BRANCH }}" "origin/${{ env.MONOREPO_BRANCH }}"
- name: Update Repositories in the Monorepo
run: |
has_errors=false
for repo in $(cat .github/repos-config.json | jq -r '.repositories[].name'); do
url=$(cat .github/repos-config.json | jq -r ".repositories[] | select(.name == \"$repo\") | .url")
branch=$(cat .github/repos-config.json | jq -r ".repositories[] | select(.name == \"$repo\") | .branch")
category=$(cat .github/repos-config.json | jq -r ".repositories[] | select(.name == \"$repo\") | .category")
enable_pull=$(cat .github/repos-config.json | jq -r ".repositories[] | select(.name == \"$repo\") | .auto_subtree_pull")
enable_push=$(cat .github/repos-config.json | jq -r ".repositories[] | select(.name == \"$repo\") | .auto_subtree_push")
if [ "$enable_pull" = true ]; then
git subtree pull --prefix "${category}/${repo}" https://github.com/${url}.git $branch || {
has_errors=true
}
fi
# if [ "$enable_push" = true ]; then
# git fetch origin subtrees/${repo}/${branch}
# git branch -f subtrees/${repo}/${branch} origin/subtrees/${repo}/${branch}
# git subtree split --prefix="${category}/${repo}" -b subtrees/${repo}/${branch} --quiet --rejoin || {
# has_errors=true
# }
# git push origin subtrees/${repo}/${branch}
# git push https://github.com/${url}.git subtrees/${repo}/${branch}:${branch}
# fi
done
if [ "$has_errors" = true ]; then
echo "One or more errors occurred during the repository update."
exit 1
else
git push https://${{ env.MONOREPO_URL }} ${{ env.MONOREPO_BRANCH }}
echo "All repositories updated successfully!"
fi
+74
Vedi File
@@ -0,0 +1,74 @@
name: Synchronize Subtrees
on:
workflow_dispatch:
schedule:
- cron: '0 * * * *'
env:
MONOREPO_URL: github.com/ROCm/rocm-libraries.git
MONOREPO_BRANCH: develop
concurrency:
group: pr-update-subtrees-develop
cancel-in-progress: false
jobs:
synchronize-subtrees:
runs-on: ubuntu-24.04
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout the Monorepo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0 # needed for git subtree pull/push
token: ${{ steps.generate-token.outputs.token }}
- name: Set up Git user
run: |
git config user.name "assistant-librarian[bot]"
git config user.email "assistant-librarian[bot]@users.noreply.github.com"
- name: Switch to the Monorepo branch
run: |
git checkout -B "${{ env.MONOREPO_BRANCH }}" "origin/${{ env.MONOREPO_BRANCH }}"
- name: Update Repositories in the Monorepo
run: |
has_errors=false
for repo in $(cat .github/repos-config.json | jq -r '.repositories[].name'); do
url=$(cat .github/repos-config.json | jq -r ".repositories[] | select(.name == \"$repo\") | .url")
branch=$(cat .github/repos-config.json | jq -r ".repositories[] | select(.name == \"$repo\") | .branch")
category=$(cat .github/repos-config.json | jq -r ".repositories[] | select(.name == \"$repo\") | .category")
enable_pull=$(cat .github/repos-config.json | jq -r ".repositories[] | select(.name == \"$repo\") | .auto_subtree_pull")
enable_push=$(cat .github/repos-config.json | jq -r ".repositories[] | select(.name == \"$repo\") | .auto_subtree_push")
if [ "$enable_pull" = true ]; then
git subtree pull --prefix "${category}/${repo}" https://github.com/${url}.git $branch || {
has_errors=true
}
fi
# if [ "$enable_push" = true ]; then
# git fetch origin subtrees/${repo}/${branch}
# git branch -f subtrees/${repo}/${branch} origin/subtrees/${repo}/${branch}
# git subtree split --prefix="${category}/${repo}" -b subtrees/${repo}/${branch} --quiet --rejoin || {
# has_errors=true
# }
# git push origin subtrees/${repo}/${branch}
# git push https://github.com/${url}.git subtrees/${repo}/${branch}:${branch}
# fi
done
if [ "$has_errors" = true ]; then
echo "One or more errors occurred during the repository update."
exit 1
else
git push https://${{ env.MONOREPO_URL }} ${{ env.MONOREPO_BRANCH }}
echo "All repositories updated successfully!"
fi