文件

忽略 .git-blame-ignore-revs 的修订。点击 绕过 并查看正常的 Blame 视图。

178 行
5.9 KiB
YAML

trigger: none
pr:
2025-07-23 14:05:44 -04:00
branches:
include:
- develop
2025-10-07 10:43:31 -07:00
- release/rocm-rel-7.1
- release/rocm-rel-7.2
drafts: false
2025-08-28 09:50:11 -07:00
2025-07-23 14:05:44 -04:00
variables:
- group: internal
- name: REPOSITORY_NAME
value: '$(Build.Repository.Name)'
2025-07-23 14:05:44 -04:00
- name: HEAD_SHA
value: '$(system.pullRequest.sourceCommitId)'
- name: PR_NUM
value: '$(system.pullRequest.pullRequestNumber)'
2025-07-23 14:05:44 -04:00
- name: PR_URL
value: '$(system.pullRequest.sourceRepositoryUri)/pull/$(PR_NUM)'
- name: BASE_REF
value: '$(system.pullRequest.TargetBranch)'
- name: EVENT_TYPE
value: 'pull_request'
- name: GH_PAT
value: '$(svc_acc_org_secret)'
2025-08-28 09:50:11 -07:00
jobs:
2025-08-28 09:50:11 -07:00
- job: Determine_Changes
2025-08-28 10:25:27 -07:00
displayName: 'Sparse Checkout & Check Changed Files'
2025-08-28 09:50:11 -07:00
pool: rocm-ci-caller
steps:
- script: |
echo "## Detecting file changes in PR #$(PR_NUM)"
2025-08-28 10:25:27 -07:00
git init repo_name
cd repo_name
git config core.sparseCheckout true
echo "projects/" > .git/info/sparse-checkout
echo "shared/" >> .git/info/sparse-checkout
git remote add origin https://github.com/$(REPOSITORY_NAME).git
2025-09-12 09:18:02 -07:00
git fetch --depth=250 origin $(BASE_REF)
2025-08-28 10:25:27 -07:00
2025-09-12 09:18:02 -07:00
git fetch --depth=250 origin $(HEAD_SHA)
2025-08-28 10:25:27 -07:00
git checkout FETCH_HEAD
2025-08-28 10:25:27 -07:00
git diff --name-only origin/$(BASE_REF)...HEAD > ../changed_files.txt
2025-08-28 09:50:11 -07:00
echo "Changed files:"
2025-08-28 10:25:27 -07:00
cat ../changed_files.txt
2025-08-28 09:50:11 -07:00
MATCH_FOUND=false
2025-09-16 13:11:18 -04:00
WINDOWS_SKIP=true
2025-08-28 09:50:11 -07:00
while read file; do
2025-08-28 15:16:03 -07:00
if [[ "$file" == projects/* ]]; then
2025-08-28 09:50:11 -07:00
MATCH_FOUND=true
2025-09-16 13:11:18 -04:00
fi
if [[ "$file" == projects/clr/* || "$file" == projects/hip/* || "$file" == projects/hip-tests/* ]]; then
WINDOWS_SKIP=false
fi
# Exclude paths:
# docs/**
# *.md
# *.rtf
# *.rst
#
# projects/*/docs/**
# **/.markdownlint-ci2.yaml
# **/.readthedocs.yaml
# **/.spellcheck.local.yaml
# **/.wordlist.txt
if [[ "${file}" == docs/* || \
"${file}" == *.md || \
"${file}" == *.rtf || \
"${file}" == *.rst
]] || \
grep --quiet --extended-regexp '^projects/[^/.]+/docs/.*$' <<< "${file}" || \
grep --quiet --extended-regexp '^([^/.]+/)*.markdownlint-ci2.yaml$' <<< "${file}" || \
grep --quiet --extended-regexp '^([^/.]+/)*.readthedocs.yaml$' <<< "${file}" || \
grep --quiet --extended-regexp '^([^/.]+/)*.spellcheck.local.yaml$' <<< "${file}" || \
grep --quiet --extended-regexp '^([^/.]+/)*.wordlist.txt$' <<< "${file}" \
; then
2025-10-01 09:57:44 -07:00
WINDOWS_SKIP=true
2025-10-01 10:37:47 -07:00
MATCH_FOUND=false
2025-10-01 09:57:44 -07:00
fi
2025-09-16 13:11:18 -04:00
if [[ "$MATCH_FOUND" == true && "$WINDOWS_SKIP" == false ]]; then
2025-08-28 09:50:11 -07:00
break
fi
2025-08-28 10:25:27 -07:00
done < ../changed_files.txt
2025-08-28 09:50:11 -07:00
2025-08-28 09:55:52 -07:00
echo "Match found: $MATCH_FOUND"
echo "##vso[task.setvariable variable=match_found;isOutput=true]$MATCH_FOUND"
2025-09-16 13:11:18 -04:00
echo "##vso[task.setvariable variable=windows_skip;isOutput=true]$WINDOWS_SKIP"
2025-08-28 09:55:52 -07:00
name: detectChanges
2025-08-28 09:50:11 -07:00
displayName: Detect path changes
- job: Trigger_Pipeline
2025-08-28 09:50:11 -07:00
displayName: 'Trigger Pipeline or Skip'
dependsOn: Determine_Changes
condition: succeeded()
2025-07-23 14:05:44 -04:00
pool: rocm-ci-caller
2025-08-28 09:55:52 -07:00
variables:
match_found: $[ dependencies.Determine_Changes.outputs['detectChanges.match_found'] ]
2025-09-16 13:11:18 -04:00
windows_skip: $[ dependencies.Determine_Changes.outputs['detectChanges.windows_skip'] ]
2025-07-23 14:05:44 -04:00
steps:
2025-08-28 09:50:11 -07:00
- checkout: none
2025-08-28 10:44:36 -07:00
- script: |
echo "DEBUG: match_found = '$(match_found)'"
displayName: 'Debug match_found variable'
2025-08-28 09:50:11 -07:00
2025-09-16 13:11:18 -04:00
- script: |
echo "DEBUG: windows_skip = '$(windows_skip)'"
displayName: 'Debug windows_skip variable'
- script: |
echo "Changes outside monitored paths (clr, hip, hip-tests). Skipping WindowsCI - Internal."
echo "Sending success status for WindowsCI - Internal..."
export GH_TOKEN=$(GH_PAT)
gh api repos/$(REPOSITORY_NAME)/statuses/$(HEAD_SHA) \
-f state=success \
-f context="WindowsCI - Internal" \
-f description="Windows PSDB skipped"
displayName: 'Skip WindowsCI - Internal'
condition: eq(variables.windows_skip, 'true')
2025-08-28 10:55:35 -07:00
- script: |
rm -rf $(repo_name)
git clone $(gh_repo)
displayName: Checkout Code
condition: eq(variables.match_found, 'true')
- script: |
set -e
2025-08-28 10:55:35 -07:00
echo "Calling jenkins_api.py for PR #$(PR_NUM)"
cd $(repo_name)
docker run \
-v "$PWD:/src" \
-w /src \
-e GH_TOKEN="$(svc_acc_org_secret)" \
-e svc_acc_org_secret="$(svc_acc_org_secret)" \
$(base_image) \
bash -c "echo 'Fetching PR title from GitHub API...' && \
echo 'repos/$(REPOSITORY_NAME)/pulls/$(PR_NUM)' && \
export TITLE=\$(gh api repos/$(REPOSITORY_NAME)/pulls/$(PR_NUM) | jq -r .title) && \
python3 jenkins_api.py \
-ghr '$(REPOSITORY_NAME)' \
-ghsha '$(HEAD_SHA)' \
-ghprn '$(PR_NUM)' \
-ghpru '$(PR_URL)' \
-ghprt \"\$TITLE\" \
-ghpat '$(GH_PAT)' \
-br '$(BASE_REF)' \
-et '$(EVENT_TYPE)'" > /dev/null 2>&1
displayName: Invoke jenkins_api.py in Docker
env:
2025-08-28 10:55:35 -07:00
svc_acc_org_secret: $(svc_acc_org_secret)
condition: eq(variables.match_found, 'true')
2025-08-28 09:50:11 -07:00
2025-08-28 10:55:35 -07:00
- script: |
echo "Changes outside monitored paths. Skipping Jenkins trigger."
echo "Sending success status for PSDB..."
export GH_TOKEN=$(GH_PAT)
gh api repos/$(REPOSITORY_NAME)/statuses/$(HEAD_SHA) \
-f state=success \
-f context="PSDB" \
-f description="PSDB skipped"
gh api repos/$(REPOSITORY_NAME)/statuses/$(HEAD_SHA) \
-f state=success \
-f context="psdb-test" \
-f description="psdb-test skipped"
displayName: Send Skipped Status
condition: ne(variables.match_found, 'true')