Files
rocm-systems/.azuredevops/rocm_ci_caller.yml
T
dsclear-amd 2482bff0b7 Excludes (more) docs-only changes from .azuredevops/rocm_ci_caller.yml. (#2615)
Motivation

We wish to avoid triggering full Jenkins runs for docs-only PRs, as this takes up testing resources and slows development time. rocm_ci_caller.yml already excludes some docs-only changes, but this can be improved to exclude them along more paths.
Technical Details

The checks that rocm_ci_caller.yml uses to determine if a changed file in a PR is worth a Jenkins run has been increased to exclude more paths and more file suffixes.
JIRA ID

AIROCDOC-78, AIROCDOC-424
Test Plan

    Created a test branch users/dsclear/shorten_workflows_test_root with the changes in this PR, branched from develop.
    Branched users/dsclear/shorten_workflows_test_bin_3 and users/dsclear/shorten_workflows_test_text_3 from users/dsclear/shorten_workflows_test_root.
    Modified users/dsclear/shorten_workflows_test_bin_3 to add two .h files, and submitted a PR into users/dsclear/shorten_workflows_test_root (Test PR, do not merge. Test PR to test Jenkins CI/CD modifications. #2613).
    Modified users/dsclear/shorten_workflows_test_text_3 to add a new .txt file, and submitted a PR into users/dsclear/shorten_workflows_test_root (Test PR, do not merge. Test PR to test Jenkins CI/CD modifications (docs only). #2614).

Test Result

The test PR in step 3 caused rocm_ci_caller.yml to attempt to trigger Jenkins, as this is a 'non-docs' change.
The test PR in step 4 had the attempt to trigger Jenkins skipped, as this is a 'docs-only' change.
2026-01-15 14:54:20 -05:00

178 line
5.9 KiB
YAML

trigger: none
pr:
branches:
include:
- develop
- release/rocm-rel-7.1
- release/rocm-rel-7.2
drafts: false
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)'
jobs:
- job: Determine_Changes
displayName: 'Sparse Checkout & Check Changed Files'
pool: rocm-ci-caller
steps:
- script: |
echo "## Detecting file changes in PR #$(PR_NUM)"
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
git fetch --depth=250 origin $(BASE_REF)
git fetch --depth=250 origin $(HEAD_SHA)
git checkout FETCH_HEAD
git diff --name-only origin/$(BASE_REF)...HEAD > ../changed_files.txt
echo "Changed files:"
cat ../changed_files.txt
MATCH_FOUND=false
WINDOWS_SKIP=true
while read file; do
if [[ "$file" == projects/* ]]; then
MATCH_FOUND=true
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
WINDOWS_SKIP=true
MATCH_FOUND=false
fi
if [[ "$MATCH_FOUND" == true && "$WINDOWS_SKIP" == false ]]; then
break
fi
done < ../changed_files.txt
echo "Match found: $MATCH_FOUND"
echo "##vso[task.setvariable variable=match_found;isOutput=true]$MATCH_FOUND"
echo "##vso[task.setvariable variable=windows_skip;isOutput=true]$WINDOWS_SKIP"
name: detectChanges
displayName: Detect path changes
- job: Trigger_Pipeline
displayName: 'Trigger Pipeline or Skip'
dependsOn: Determine_Changes
condition: succeeded()
pool: rocm-ci-caller
variables:
match_found: $[ dependencies.Determine_Changes.outputs['detectChanges.match_found'] ]
windows_skip: $[ dependencies.Determine_Changes.outputs['detectChanges.windows_skip'] ]
steps:
- checkout: none
- script: |
echo "DEBUG: match_found = '$(match_found)'"
displayName: 'Debug match_found variable'
- 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')
- 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')
- 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')