From 8677efd1f17264fe17c796320fac412fe9c149f1 Mon Sep 17 00:00:00 2001 From: drunkonjava Date: Thu, 31 Jul 2025 19:00:05 -0400 Subject: [PATCH 1/2] fix(ci): Only run Swift checks on PRs with Swift changes - Check if PR contains Swift file changes before running SwiftLint - Skip Swift-specific checks (TODO/FIXME, security) for non-Swift PRs - Fixes CI failures on workflow-only PRs like #244-#248 This properly handles PRs that only modify workflows, scripts, or documentation without triggering Swift-related validations. --- .github/sync-status/local-push.json | 17 +++++++++++ .github/workflows/pr-validation.yml | 29 ++++++++++++------ .xcode-diagnostics.json | 47 +++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 9 deletions(-) create mode 100644 .github/sync-status/local-push.json create mode 100644 .xcode-diagnostics.json diff --git a/.github/sync-status/local-push.json b/.github/sync-status/local-push.json new file mode 100644 index 00000000..dc425907 --- /dev/null +++ b/.github/sync-status/local-push.json @@ -0,0 +1,17 @@ +{ + "timestamp": "2025-07-31 22:28:31 UTC", + "branch": "fix/pr-validation-for-non-swift", + "commit": "71ce733ff9e067c6314239b3d2436beeffe5e121", + "message": "fix(ci): Handle non-Swift PRs in validation workflow + +Update PR validation workflow to gracefully handle PRs that contain +no Swift files (like workflow-only or documentation PRs): +- Check for Swift files before running SwiftLint +- Skip Xcode build steps for non-Swift PRs +- Make Swift-specific checks conditional + +This fixes CI failures for PRs #244-#248 which only contain +workflow files and scripts. + +Co-authored-by: Claude " +} diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml index 83cbeb2f..e9c9b9f1 100644 --- a/.github/workflows/pr-validation.yml +++ b/.github/workflows/pr-validation.yml @@ -48,16 +48,27 @@ jobs: brew install swiftlint fi - - name: Run SwiftLint + - name: Check PR for Swift files + id: check_swift_changes run: | - # Check if there are any Swift files in the PR - SWIFT_FILES=$(find . -name "*.swift" -not -path "*/.*" | head -n 1) + # Get list of changed files in the PR + CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) - if [ -z "$SWIFT_FILES" ]; then - echo "No Swift files found in repository, skipping SwiftLint" - exit 0 - fi + # Check if any changed files are Swift files + SWIFT_CHANGES=$(echo "$CHANGED_FILES" | grep '\.swift$' || true) + if [ -z "$SWIFT_CHANGES" ]; then + echo "No Swift files changed in this PR" + echo "has_swift_changes=false" >> $GITHUB_OUTPUT + else + echo "Swift files changed in this PR:" + echo "$SWIFT_CHANGES" + echo "has_swift_changes=true" >> $GITHUB_OUTPUT + fi + + - name: Run SwiftLint + if: steps.check_swift_changes.outputs.has_swift_changes == 'true' + run: | if [ -f .swiftlint.yml ]; then swiftlint lint --reporter github-actions-logging --config .swiftlint.yml else @@ -147,7 +158,7 @@ jobs: fi - name: Check for TODO and FIXME comments - if: steps.check_swift.outputs.is_swift == 'true' + if: steps.check_swift_changes.outputs.has_swift_changes == 'true' run: | todos=$(find . -name "*.swift" -not -path "./.*" -exec grep -n "TODO\|FIXME" {} + | wc -l) echo "Found $todos TODO/FIXME comments" @@ -156,7 +167,7 @@ jobs: fi - name: Security checks - if: steps.check_swift.outputs.is_swift == 'true' + if: steps.check_swift_changes.outputs.has_swift_changes == 'true' run: | # Check for potential security issues echo "Running basic security checks..." diff --git a/.xcode-diagnostics.json b/.xcode-diagnostics.json new file mode 100644 index 00000000..51082bf6 --- /dev/null +++ b/.xcode-diagnostics.json @@ -0,0 +1,47 @@ +{ + "swift_flags": { + "debug": [ + "-Xfrontend", "-warn-long-function-bodies=150", + "-Xfrontend", "-warn-long-expression-type-checking=150", + "-Xfrontend", "-debug-time-function-bodies", + "-Xfrontend", "-debug-time-expression-type-checking", + "-Xfrontend", "-print-stats", + "-Xfrontend", "-validate-tbd-against-ir=all" + ], + "release": [ + "-Xfrontend", "-warn-long-function-bodies=200" + ] + }, + "analysis_thresholds": { + "max_function_body_time_ms": 150, + "max_expression_type_check_ms": 150, + "max_file_compile_time_s": 10 + }, + "required_tools": [ + "xcbeautify", + "xclogparser", + "swiftlint", + "swiftformat" + ], + "diagnostic_settings": { + "continue_building_after_errors": false, + "treat_warnings_as_errors_debug": true, + "treat_warnings_as_errors_release": false, + "enable_link_map": true, + "enable_build_timing": true + }, + "module_specific_thresholds": { + "FeaturesScanner": { + "max_function_body_time_ms": 200, + "max_expression_type_check_ms": 200 + }, + "ServicesSync": { + "max_function_body_time_ms": 250, + "max_expression_type_check_ms": 250 + }, + "FeaturesReceipts": { + "max_function_body_time_ms": 200, + "max_expression_type_check_ms": 200 + } + } +} \ No newline at end of file From bd4c57736de9a4ce1ffa738796bc59ce376d9c3e Mon Sep 17 00:00:00 2001 From: drunkonjava Date: Thu, 31 Jul 2025 19:02:05 -0400 Subject: [PATCH 2/2] fix(ci): Also check Swift changes for project generation step The check_swift step needs to use the has_swift_changes output to avoid trying to generate Xcode projects for non-Swift PRs. --- .github/sync-status/local-push.json | 22 +++++++++------------- .github/workflows/pr-validation.yml | 3 ++- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/.github/sync-status/local-push.json b/.github/sync-status/local-push.json index dc425907..d961c575 100644 --- a/.github/sync-status/local-push.json +++ b/.github/sync-status/local-push.json @@ -1,17 +1,13 @@ { - "timestamp": "2025-07-31 22:28:31 UTC", - "branch": "fix/pr-validation-for-non-swift", - "commit": "71ce733ff9e067c6314239b3d2436beeffe5e121", - "message": "fix(ci): Handle non-Swift PRs in validation workflow + "timestamp": "2025-07-31 23:00:07 UTC", + "branch": "fix/pr-validation-check-changed-files", + "commit": "8677efd1f17264fe17c796320fac412fe9c149f1", + "message": "fix(ci): Only run Swift checks on PRs with Swift changes -Update PR validation workflow to gracefully handle PRs that contain -no Swift files (like workflow-only or documentation PRs): -- Check for Swift files before running SwiftLint -- Skip Xcode build steps for non-Swift PRs -- Make Swift-specific checks conditional +- Check if PR contains Swift file changes before running SwiftLint +- Skip Swift-specific checks (TODO/FIXME, security) for non-Swift PRs +- Fixes CI failures on workflow-only PRs like #244-#248 -This fixes CI failures for PRs #244-#248 which only contain -workflow files and scripts. - -Co-authored-by: Claude " +This properly handles PRs that only modify workflows, scripts, or +documentation without triggering Swift-related validations." } diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml index e9c9b9f1..1c470d74 100644 --- a/.github/workflows/pr-validation.yml +++ b/.github/workflows/pr-validation.yml @@ -99,7 +99,8 @@ jobs: - name: Check if Swift project id: check_swift run: | - if [ -f "project.yml" ] && [ -n "$(find . -name "*.swift" -not -path "*/.*" | head -n 1)" ]; then + # Use the result from check_swift_changes step + if [ "${{ steps.check_swift_changes.outputs.has_swift_changes }}" == "true" ]; then echo "is_swift=true" >> $GITHUB_OUTPUT else echo "is_swift=false" >> $GITHUB_OUTPUT