Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ jobs:

- name: Run SwiftLint
run: |
# Check if there are any Swift files in the PR
SWIFT_FILES=$(find . -name "*.swift" -not -path "*/.*" | head -n 1)

if [ -z "$SWIFT_FILES" ]; then
echo "No Swift files found in repository, skipping SwiftLint"
exit 0
fi

if [ -f .swiftlint.yml ]; then
swiftlint lint --reporter github-actions-logging --config .swiftlint.yml
else
Expand Down Expand Up @@ -77,7 +85,17 @@ jobs:
fi
done

- name: Check if Swift project
id: check_swift
run: |
if [ -f "project.yml" ] && [ -n "$(find . -name "*.swift" -not -path "*/.*" | head -n 1)" ]; then
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Swift file detection logic is duplicated. Consider extracting the find command into a variable or reusing the SWIFT_FILES variable from the SwiftLint step to avoid code duplication.

Suggested change
if [ -f "project.yml" ] && [ -n "$(find . -name "*.swift" -not -path "*/.*" | head -n 1)" ]; then
if [ -f "project.yml" ] && [ -n "$SWIFT_FILES" ]; then

Copilot uses AI. Check for mistakes.
echo "is_swift=true" >> $GITHUB_OUTPUT
else
echo "is_swift=false" >> $GITHUB_OUTPUT
fi

- name: Generate Xcode project
if: steps.check_swift.outputs.is_swift == 'true'
run: |
if ! command -v xcodegen &> /dev/null; then
echo "Installing XcodeGen..."
Expand All @@ -86,12 +104,14 @@ jobs:
xcodegen generate

- name: Resolve Swift Package Dependencies
if: steps.check_swift.outputs.is_swift == 'true'
run: |
xcodebuild -resolvePackageDependencies \
-project HomeInventoryModular.xcodeproj \
-scheme HomeInventoryApp

- name: Build for iOS Simulator
if: steps.check_swift.outputs.is_swift == 'true'
run: |
set -o pipefail
xcodebuild build \
Expand All @@ -102,6 +122,7 @@ jobs:
CODE_SIGNING_ALLOWED=NO

- name: Check for compilation warnings
if: steps.check_swift.outputs.is_swift == 'true'
run: |
set -o pipefail
warnings=$(xcodebuild clean build \
Expand All @@ -126,6 +147,7 @@ jobs:
fi

- name: Check for TODO and FIXME comments
if: steps.check_swift.outputs.is_swift == 'true'
run: |
todos=$(find . -name "*.swift" -not -path "./.*" -exec grep -n "TODO\|FIXME" {} + | wc -l)
echo "Found $todos TODO/FIXME comments"
Expand All @@ -134,6 +156,7 @@ jobs:
fi

- name: Security checks
if: steps.check_swift.outputs.is_swift == 'true'
run: |
# Check for potential security issues
echo "Running basic security checks..."
Expand Down
Loading