-
Notifications
You must be signed in to change notification settings - Fork 0
fix(ci): Only run Swift checks on PRs with Swift changes #250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "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 | ||
|
|
||
| - 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." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -88,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 | ||
|
|
@@ -147,7 +159,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 +168,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..." | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition references
steps.check_swift_changesbut the step with idcheck_swift_changesis defined in a different job. The TODO/FIXME check job needs to either have its own Swift file detection step or reference the correct step id from the current job context.