Skip to content

Commit 0de2156

Browse files
graycreateclaude
andcommitted
feat: add comprehensive GitHub Actions CI/CD pipelines
Add automated workflows for iOS development: - Build and test workflow for continuous integration - PR validation with SwiftLint and commit checks - Automated release pipeline for App Store deployment - Weekly dependency updates with security scanning - Code quality checks with coverage reporting These workflows will improve development efficiency and code quality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 7e30f6d commit 0de2156

File tree

6 files changed

+687
-0
lines changed

6 files changed

+687
-0
lines changed

.github/workflows/README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# GitHub Actions Workflows
2+
3+
This directory contains automated workflows for the V2er-iOS project.
4+
5+
## Workflows
6+
7+
### 🔨 iOS Build and Test (`ios-build-test.yml`)
8+
- **Trigger**: Push to main/develop, Pull requests to main
9+
- **Purpose**: Build the app and run tests
10+
- **Features**:
11+
- Builds for iOS Simulator
12+
- Runs unit and UI tests
13+
- Caches Swift Package Manager dependencies
14+
- Uploads test results on failure
15+
16+
### ✅ PR Validation (`pr-validation.yml`)
17+
- **Trigger**: Pull request events
18+
- **Purpose**: Validate pull requests before merge
19+
- **Features**:
20+
- SwiftLint analysis
21+
- PR size labeling (XS, S, M, L, XL, XXL)
22+
- Conventional commit message checking
23+
24+
### 🚀 Release (`release.yml`)
25+
- **Trigger**: Manual workflow dispatch
26+
- **Purpose**: Build and release to App Store
27+
- **Features**:
28+
- Version bumping (major/minor/patch)
29+
- Archive and export IPA
30+
- Upload to TestFlight
31+
- Create GitHub release
32+
- Option for TestFlight-only releases
33+
34+
### 📦 Dependency Updates (`dependency-update.yml`)
35+
- **Trigger**: Weekly (Mondays at 9 AM UTC) or manual
36+
- **Purpose**: Keep dependencies up to date
37+
- **Features**:
38+
- Updates Swift Package dependencies
39+
- Creates automated pull request
40+
- Security vulnerability scanning
41+
42+
### 📊 Code Quality (`code-quality.yml`)
43+
- **Trigger**: Push to main/develop, Pull requests
44+
- **Purpose**: Maintain code quality standards
45+
- **Features**:
46+
- SwiftFormat checking
47+
- Code coverage reporting
48+
- Coverage badge generation
49+
50+
## Required Secrets
51+
52+
To use these workflows, configure the following secrets in your repository:
53+
54+
### For Release Workflow:
55+
- `CERTIFICATES_P12`: Base64 encoded distribution certificate
56+
- `CERTIFICATES_PASSWORD`: Certificate password
57+
- `KEYCHAIN_PASSWORD`: Temporary keychain password
58+
- `PROVISIONING_PROFILE_BASE64`: Base64 encoded provisioning profile
59+
- `TEAM_ID`: Apple Developer Team ID
60+
- `APP_STORE_CONNECT_API_KEY_ID`: App Store Connect API key ID
61+
- `APP_STORE_CONNECT_API_KEY_ISSUER_ID`: API key issuer ID
62+
- `APP_STORE_CONNECT_API_KEY`: API key content
63+
64+
### For Coverage Badge (Optional):
65+
- `GIST_SECRET`: GitHub personal access token with gist scope
66+
67+
## Setup Instructions
68+
69+
1. Generate required certificates and provisioning profiles from Apple Developer portal
70+
2. Encode files to base64:
71+
```bash
72+
base64 -i certificate.p12 -o certificate_base64.txt
73+
base64 -i profile.mobileprovision -o profile_base64.txt
74+
```
75+
3. Add secrets to repository settings
76+
4. Update Xcode version in workflows if needed
77+
5. Customize workflow triggers as needed
78+
79+
## Manual Triggers
80+
81+
Some workflows can be triggered manually from the Actions tab:
82+
- **Release**: Choose release type (major/minor/patch) and TestFlight-only option
83+
- **Dependency Updates**: Manually check for updates
84+
85+
## Maintenance
86+
87+
- Update Xcode version when new versions are released
88+
- Review and update SwiftLint rules as needed
89+
- Adjust test simulator versions for new iOS releases
90+
- Monitor dependency update PRs for breaking changes

.github/workflows/code-quality.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
swiftformat:
11+
name: SwiftFormat Check
12+
runs-on: macos-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Install SwiftFormat
19+
run: brew install swiftformat
20+
21+
- name: Check code formatting
22+
run: |
23+
swiftformat --version
24+
swiftformat . --lint --verbose
25+
continue-on-error: true
26+
27+
- name: Generate format diff
28+
if: failure()
29+
run: |
30+
swiftformat . --dryrun > format-diff.txt
31+
cat format-diff.txt
32+
33+
- name: Upload format diff
34+
if: failure()
35+
uses: actions/upload-artifact@v3
36+
with:
37+
name: format-diff
38+
path: format-diff.txt
39+
40+
code-coverage:
41+
name: Code Coverage
42+
runs-on: macos-latest
43+
44+
steps:
45+
- name: Checkout repository
46+
uses: actions/checkout@v4
47+
with:
48+
submodules: recursive
49+
50+
- name: Select Xcode version
51+
run: sudo xcode-select -s /Applications/Xcode_15.2.app/Contents/Developer
52+
53+
- name: Build and test with coverage
54+
run: |
55+
xcodebuild test \
56+
-project V2er.xcodeproj \
57+
-scheme V2er \
58+
-sdk iphonesimulator \
59+
-destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' \
60+
-enableCodeCoverage YES \
61+
-derivedDataPath build/DerivedData \
62+
CODE_SIGN_IDENTITY="" \
63+
CODE_SIGNING_REQUIRED=NO | xcpretty
64+
65+
- name: Generate coverage report
66+
run: |
67+
cd build/DerivedData
68+
xcrun xccov view --report --json Build/Logs/Test/*.xcresult > coverage.json
69+
70+
# Extract coverage percentage
71+
COVERAGE=$(cat coverage.json | jq '.lineCoverage' | awk '{printf "%.2f", $1 * 100}')
72+
echo "Code coverage: ${COVERAGE}%"
73+
echo "coverage=${COVERAGE}" >> $GITHUB_ENV
74+
75+
- name: Create coverage badge
76+
uses: schneegans/[email protected]
77+
with:
78+
auth: ${{ secrets.GIST_SECRET }}
79+
gistID: YOUR_GIST_ID
80+
filename: v2er-ios-coverage.json
81+
label: Coverage
82+
message: ${{ env.coverage }}%
83+
color: ${{ env.coverage > 80 && 'success' || env.coverage > 60 && 'yellow' || 'critical' }}
84+
85+
- name: Comment PR with coverage
86+
if: github.event_name == 'pull_request'
87+
uses: actions/github-script@v7
88+
with:
89+
script: |
90+
const coverage = '${{ env.coverage }}';
91+
const emoji = coverage > 80 ? '✅' : coverage > 60 ? '⚠️' : '❌';
92+
93+
github.rest.issues.createComment({
94+
issue_number: context.issue.number,
95+
owner: context.repo.owner,
96+
repo: context.repo.repo,
97+
body: `## Code Coverage Report ${emoji}\n\nCurrent coverage: **${coverage}%**`
98+
});
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Dependency Updates
2+
3+
on:
4+
schedule:
5+
# Run every Monday at 9 AM UTC
6+
- cron: '0 9 * * 1'
7+
workflow_dispatch:
8+
9+
jobs:
10+
update-dependencies:
11+
name: Update Swift Package Dependencies
12+
runs-on: macos-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
token: ${{ secrets.GITHUB_TOKEN }}
19+
20+
- name: Select Xcode version
21+
run: sudo xcode-select -s /Applications/Xcode_15.2.app/Contents/Developer
22+
23+
- name: Update Swift packages
24+
run: |
25+
# Update all Swift package dependencies to latest versions
26+
xcodebuild -project V2er.xcodeproj \
27+
-scheme V2er \
28+
-resolvePackageDependencies \
29+
-scmProvider system
30+
31+
- name: Check for changes
32+
id: git-check
33+
run: |
34+
git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT
35+
36+
- name: Create Pull Request
37+
if: steps.git-check.outputs.changes == 'true'
38+
uses: peter-evans/create-pull-request@v5
39+
with:
40+
token: ${{ secrets.GITHUB_TOKEN }}
41+
commit-message: 'chore: update Swift package dependencies'
42+
title: 'chore: update Swift package dependencies'
43+
body: |
44+
## Automated Dependency Update
45+
46+
This PR updates the Swift Package Manager dependencies to their latest compatible versions.
47+
48+
### Changes
49+
- Updated Package.resolved with latest dependency versions
50+
51+
### Checklist
52+
- [ ] Build passes with updated dependencies
53+
- [ ] Tests pass with updated dependencies
54+
- [ ] No breaking changes identified
55+
56+
Please review the dependency changes and ensure they don't introduce any breaking changes.
57+
58+
---
59+
*This PR was automatically created by the dependency update workflow.*
60+
branch: automated/dependency-updates
61+
delete-branch: true
62+
labels: |
63+
dependencies
64+
automated
65+
66+
check-vulnerabilities:
67+
name: Security Vulnerability Check
68+
runs-on: ubuntu-latest
69+
70+
steps:
71+
- name: Checkout repository
72+
uses: actions/checkout@v4
73+
74+
- name: Run security audit
75+
uses: actions/dependency-review-action@v3
76+
with:
77+
fail-on-severity: moderate
78+
79+
- name: Upload security report
80+
uses: actions/upload-artifact@v3
81+
if: failure()
82+
with:
83+
name: security-report
84+
path: dependency-review-report.json
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: iOS Build and Test
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
env:
11+
DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer
12+
13+
jobs:
14+
build-and-test:
15+
name: Build and Test
16+
runs-on: macos-latest
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
submodules: recursive
23+
24+
- name: Select Xcode version
25+
run: sudo xcode-select -s /Applications/Xcode_15.2.app/Contents/Developer
26+
27+
- name: Show Xcode version
28+
run: xcodebuild -version
29+
30+
- name: Cache SPM packages
31+
uses: actions/cache@v3
32+
with:
33+
path: ~/Library/Developer/Xcode/DerivedData/**/SourcePackages
34+
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
35+
restore-keys: |
36+
${{ runner.os }}-spm-
37+
38+
- name: Resolve Swift packages
39+
run: |
40+
xcodebuild -resolvePackageDependencies \
41+
-project V2er.xcodeproj \
42+
-scheme V2er
43+
44+
- name: Build for testing
45+
run: |
46+
set -o pipefail && xcodebuild build-for-testing \
47+
-project V2er.xcodeproj \
48+
-scheme V2er \
49+
-sdk iphonesimulator \
50+
-destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' \
51+
ONLY_ACTIVE_ARCH=YES \
52+
CODE_SIGN_IDENTITY="" \
53+
CODE_SIGNING_REQUIRED=NO | xcpretty --color
54+
55+
- name: Run tests
56+
run: |
57+
set -o pipefail && xcodebuild test-without-building \
58+
-project V2er.xcodeproj \
59+
-scheme V2er \
60+
-sdk iphonesimulator \
61+
-destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' \
62+
ONLY_ACTIVE_ARCH=YES \
63+
CODE_SIGN_IDENTITY="" \
64+
CODE_SIGNING_REQUIRED=NO | xcpretty --color --test
65+
66+
- name: Upload test results
67+
uses: actions/upload-artifact@v3
68+
if: failure()
69+
with:
70+
name: test-results
71+
path: |
72+
~/Library/Logs/DiagnosticReports/
73+
~/Library/Developer/Xcode/DerivedData/**/Logs/Test/

0 commit comments

Comments
 (0)