파일
rocm-systems/.azuredevops/rocm_ci_caller.yml
T

127 라인
3.8 KiB
YAML
Raw 일반 보기 히스토리

2025-07-23 14:05:44 -04:00
trigger: none
pr:
branches:
include:
- develop
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)'
- name: HEAD_SHA
value: '$(system.pullRequest.sourceCommitId)'
- name: PR_NUM
value: '$(system.pullRequest.pullRequestNumber)'
- 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
2025-07-23 14:05:44 -04: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
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
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
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"
name: detectChanges
2025-08-28 09:50:11 -07:00
displayName: Detect path changes
2025-07-23 14:05:44 -04:00
- 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-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-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
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:
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')