Improve changed app detection in CI (#37838)
This pull request improves the robustness and reliability of the script and workflows that detect changed or new maintained apps in pull requests. The main focus is on making the detection script pass validation when the test is triggered but no new FMAs are detected. **Script robustness and error handling:** * The `.github/scripts/detect-new-fmas-in-pr.sh` script is updated to always exit successfully (status 0) when no changes are detected, and only exit with error (status 1) for critical failures like missing `jq`. A new `safe_exit` function is introduced to standardize output and ensure graceful exits. [[1]](diffhunk://#diff-f9bbb0340f504713c99d610f3c64bf281fc13ed3cb8a1c06a5366272c9828a8dR7-R11) [[2]](diffhunk://#diff-f9bbb0340f504713c99d610f3c64bf281fc13ed3cb8a1c06a5366272c9828a8dL21-R39) * Improved error handling for missing files, empty variables, and failed commands throughout the script, including handling cases where `merge-base`, `git show`, or `jq` fail, and ensuring empty or missing data does not cause the script to error out. [[1]](diffhunk://#diff-f9bbb0340f504713c99d610f3c64bf281fc13ed3cb8a1c06a5366272c9828a8dL32-R66) [[2]](diffhunk://#diff-f9bbb0340f504713c99d610f3c64bf281fc13ed3cb8a1c06a5366272c9828a8dR87-R108) [[3]](diffhunk://#diff-f9bbb0340f504713c99d610f3c64bf281fc13ed3cb8a1c06a5366272c9828a8dL75-R155) **Workflow improvements:** * The `test-fma-darwin-pr-only.yml` and `test-fma-windows-pr-only.yml` workflows are updated to default to "no changes" if the detection step fails or does not set the expected output, preventing false positives or workflow failures. [[1]](diffhunk://#diff-28b30c8601cb7662d59efbfbbcf800cae91455fd3d875627659dced8c1257a24L70-R72) [[2]](diffhunk://#diff-51641fd1d2cc19348b81fd8310b62ad270ca5082ceddff2d49064e78f126a1eaL76-R78)
This commit is contained in:
@@ -67,7 +67,9 @@ jobs:
|
||||
- name: Check if there are changes
|
||||
id: check-changes
|
||||
run: |
|
||||
if [ "${{ steps.detect-changed.outputs.HAS_CHANGES }}" == "true" ]; then
|
||||
# Default to no changes if detection step failed or didn't set output
|
||||
HAS_CHANGES="${{ steps.detect-changed.outputs.HAS_CHANGES }}"
|
||||
if [ "$HAS_CHANGES" == "true" ]; then
|
||||
echo "has_changes=true" >> $GITHUB_OUTPUT
|
||||
echo "Changed apps detected: ${{ steps.detect-changed.outputs.CHANGED_APPS }}"
|
||||
else
|
||||
|
||||
@@ -73,7 +73,9 @@ jobs:
|
||||
- name: Check if there are changes
|
||||
id: check-changes
|
||||
run: |
|
||||
if ("${{ steps.detect-changed.outputs.HAS_CHANGES }}" -eq "true") {
|
||||
# Default to no changes if detection step failed or didn't set output
|
||||
$hasChanges = "${{ steps.detect-changed.outputs.HAS_CHANGES }}"
|
||||
if ($hasChanges -eq "true") {
|
||||
"has_changes=true" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
|
||||
Write-Host "Changed apps detected: ${{ steps.detect-changed.outputs.CHANGED_APPS }}"
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user