Skip to content
Merged
Show file tree
Hide file tree
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
70 changes: 57 additions & 13 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,39 @@ jobs:
echo "πŸ“± Detected generated project repository"
fi

- name: Check if project is configured
id: check_configured
run: |
if [[ ! -f "project.yml" ]]; then
# Count commits (if this is a fresh template with minimal history, skip CI)
COMMIT_COUNT=$(git rev-list --count HEAD 2>/dev/null || echo "0")
echo "Commit count: $COMMIT_COUNT"

if [[ $COMMIT_COUNT -le 2 ]]; then
echo "⏭️ Skipping CI - this appears to be an unconfigured template repository"
echo "πŸ‘‰ Run './scripts/setup.sh' to configure your project, then commit to enable CI"
echo "configured=false" >> $GITHUB_OUTPUT
echo "should_skip=true" >> $GITHUB_OUTPUT
else
echo "❌ Missing project.yml but git history exists - please run './scripts/setup.sh'"
echo "configured=false" >> $GITHUB_OUTPUT
echo "should_skip=false" >> $GITHUB_OUTPUT
exit 1
fi
else
echo "βœ… Project appears to be configured (project.yml found)"
echo "configured=true" >> $GITHUB_OUTPUT
echo "should_skip=false" >> $GITHUB_OUTPUT
fi

- name: Set up Xcode
if: steps.check_configured.outputs.should_skip != 'true'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "16.4"

- name: Cache Homebrew packages
if: steps.check_configured.outputs.should_skip != 'true'
uses: actions/cache@v4
with:
path: |
Expand All @@ -50,6 +77,7 @@ jobs:
${{ runner.os }}-homebrew-

- name: Install dependencies
if: steps.check_configured.outputs.should_skip != 'true'
run: |
# Install Homebrew dependencies
brew bundle install --file=./Brewfile
Expand All @@ -63,7 +91,7 @@ jobs:

# Template Repository: Generate test project for E2E validation
- name: Generate test project
if: steps.detect.outputs.repo_type == 'template'
if: steps.detect.outputs.repo_type == 'template' && steps.check_configured.outputs.should_skip != 'true'
run: |
echo "πŸ—οΈ Generating test project for E2E validation..."
echo "Working directory: $(pwd)"
Expand Down Expand Up @@ -105,7 +133,7 @@ jobs:

# Template Repository: Validate generated project
- name: Run E2E validation on generated project
if: steps.detect.outputs.repo_type == 'template'
if: steps.detect.outputs.repo_type == 'template' && steps.check_configured.outputs.should_skip != 'true'
run: |
echo "πŸ” Running end-to-end validation on generated project..."
cd ci-test-project
Expand All @@ -118,7 +146,7 @@ jobs:

# Generated Project: Normal validation continues below
- name: Validate project configuration
if: steps.detect.outputs.repo_type == 'generated'
if: steps.detect.outputs.repo_type == 'generated' && steps.check_configured.outputs.should_skip != 'true'
run: |
# Check if project.yml exists and is valid
if [ -f "project.yml" ]; then
Expand All @@ -139,7 +167,7 @@ jobs:
fi

- name: Generate Xcode project
if: steps.detect.outputs.repo_type == 'generated'
if: steps.detect.outputs.repo_type == 'generated' && steps.check_configured.outputs.should_skip != 'true'
run: |
echo "Generating Xcode project..."
xcodegen generate
Expand All @@ -153,7 +181,7 @@ jobs:
fi

- name: SwiftLint
if: steps.detect.outputs.repo_type == 'generated'
if: steps.detect.outputs.repo_type == 'generated' && steps.check_configured.outputs.should_skip != 'true'
run: |
echo "Running SwiftLint..."

Expand All @@ -168,7 +196,7 @@ jobs:
fi

- name: SwiftFormat check
if: steps.detect.outputs.repo_type == 'generated'
if: steps.detect.outputs.repo_type == 'generated' && steps.check_configured.outputs.should_skip != 'true'
run: |
echo "Checking SwiftFormat..."

Expand All @@ -183,7 +211,7 @@ jobs:
fi

- name: Build project
if: steps.detect.outputs.repo_type == 'generated'
if: steps.detect.outputs.repo_type == 'generated' && steps.check_configured.outputs.should_skip != 'true'
run: |
echo "Building project..."

Expand Down Expand Up @@ -216,7 +244,7 @@ jobs:
echo "βœ“ Build completed successfully"

- name: Run unit tests
if: steps.detect.outputs.repo_type == 'generated'
if: steps.detect.outputs.repo_type == 'generated' && steps.check_configured.outputs.should_skip != 'true'
run: |
PROJECT_NAME=$(yq eval '.name' project.yml)

Expand Down Expand Up @@ -256,7 +284,7 @@ jobs:
# UI Tests (Optional - disabled by default)
# To enable UI tests in CI, set RUN_UI_TESTS: true in the env section above
- name: Run UI tests
if: steps.detect.outputs.repo_type == 'generated' && env.RUN_UI_TESTS == 'true'
if: steps.detect.outputs.repo_type == 'generated' && env.RUN_UI_TESTS == 'true' && steps.check_configured.outputs.should_skip != 'true'
run: |
PROJECT_NAME=$(yq eval '.name' project.yml)

Expand Down Expand Up @@ -298,7 +326,7 @@ jobs:
fi

- name: Validate scripts
if: steps.detect.outputs.repo_type == 'generated'
if: steps.detect.outputs.repo_type == 'generated' && steps.check_configured.outputs.should_skip != 'true'
run: |
echo "Validating helper scripts..."

Expand All @@ -325,7 +353,7 @@ jobs:
echo "βœ“ All scripts validated"

- name: Check configuration files
if: steps.detect.outputs.repo_type == 'generated'
if: steps.detect.outputs.repo_type == 'generated' && steps.check_configured.outputs.should_skip != 'true'
run: |
echo "Validating configuration files..."

Expand Down Expand Up @@ -354,7 +382,7 @@ jobs:
echo "βœ“ Configuration files validated"

- name: Summary
if: steps.detect.outputs.repo_type == 'generated'
if: steps.detect.outputs.repo_type == 'generated' && steps.check_configured.outputs.should_skip != 'true'
run: |
echo "πŸŽ‰ PR Validation Complete!"
echo ""
Expand All @@ -367,8 +395,24 @@ jobs:

# Template Repository: Cleanup
- name: Cleanup test project
if: always() && steps.detect.outputs.repo_type == 'template'
if: always() && steps.detect.outputs.repo_type == 'template' && steps.check_configured.outputs.should_skip != 'true'
run: |
echo "🧹 Cleaning up test project..."
rm -rf ci-test-project
echo "βœ“ Cleanup completed"

# Show helpful message when CI is skipped
- name: Configuration needed
if: steps.check_configured.outputs.should_skip == 'true'
run: |
echo "πŸš€ Welcome to your new iOS project!"
echo ""
echo "This appears to be a fresh project created from the SwiftProjectTemplate."
echo "To enable CI and configure your project, please run:"
echo ""
echo " ./scripts/setup.sh"
echo ""
echo "After running setup and committing your changes, CI will automatically"
echo "run on future pushes and pull requests."
echo ""
echo "πŸ“– Check the README.md for detailed setup instructions!"
4 changes: 2 additions & 2 deletions scripts/dev-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ sync_to_project() {
done

# Sync individual files
for file in Brewfile .swift-version .markdownlint.json; do
for file in Brewfile .gitignore .swift-version .markdownlint.json; do
if [[ -f "$file" ]]; then
"${rsync_cmd[@]}" "$file" "$TARGET_PROJECT/"
fi
Expand All @@ -164,7 +164,7 @@ sync_from_project() {
done

# Sync individual files (reverse direction)
for file in Brewfile .swift-version .markdownlint.json; do
for file in Brewfile .gitignore .swift-version .markdownlint.json; do
if [[ -f "$TARGET_PROJECT/$file" ]]; then
"${rsync_cmd[@]}" "$TARGET_PROJECT/$file" ./
fi
Expand Down
Loading