Skip to content

Commit 0c6ceb5

Browse files
authored
ci: fix mint installation not being cached (#102)
Signed-off-by: Alessandro Yuichi Okimoto <yuichijpn@gmail.com>
1 parent 864e2ae commit 0c6ceb5

File tree

2 files changed

+120
-5
lines changed

2 files changed

+120
-5
lines changed

.github/workflows/generate-xcode-project.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,44 @@ jobs:
77
generate-xcode-project:
88
runs-on: macos-15-xlarge
99
steps:
10-
- uses: actions/checkout@v4
10+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1111

12-
- name: Install bootstrap mint
13-
uses: irgaly/setup-mint@99eaad2ad1197ea872390322a47620da2f21fde4 # v1.4.0
12+
# Pre-cache mint packages directory
13+
- name: Cache Mint packages
14+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
15+
with:
16+
path: |
17+
~/.mint
18+
~/Library/Caches/Mint
19+
~/Library/Developer/Xcode/DerivedData
20+
~/.swiftpm
21+
key: ${{ runner.os }}-mint-packages-${{ hashFiles('**/Mintfile') }}-v4
22+
restore-keys: |
23+
${{ runner.os }}-mint-packages-
24+
25+
# Use setup-mint action with optimized settings
26+
- name: Setup Mint
27+
uses: irgaly/setup-mint@d61b6ece0c0f5486ea8a17de6026e8da5468af60 # v1.7.0
1428
with:
1529
bootstrap: true
30+
bootstrap-link: true
1631
use-cache: true
32+
cache-prefix: "mint-setup-v4"
33+
clean: true
1734

1835
- name: Generate XcodeProject
1936
run: |
2037
make environment-setup
2138
mint run xcodegen generate
2239
2340
- name: Upload Xcode project file
24-
uses: actions/upload-artifact@v4
41+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
2542
with:
2643
name: output-xcodeproj-file
2744
path: ./Bucketeer.xcodeproj
2845

2946
- name: Upload dummy environment file
30-
uses: actions/upload-artifact@v4
47+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
3148
with:
3249
name: output-environment-file
3350
path: ./environment.xcconfig

docs/workflow-optimization.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# GitHub Actions Workflow Optimization Guide
2+
3+
## Current Issue
4+
The `generate-xcode-project` workflow is taking approximately 20 minutes to complete, with the majority of time (18 minutes) spent on the "Install bootstrap mint" step.
5+
6+
## Implemented Optimizations
7+
8+
### 1. Direct Mint Binary Caching
9+
Instead of using the `setup-mint` action, we now:
10+
- Cache the mint binary directly at `/usr/local/bin/mint`
11+
- Install mint via Homebrew only if not cached
12+
- This avoids potential overhead from the setup action
13+
14+
### 2. Improved Mint Packages Caching
15+
- Cache the `~/.mint` directory separately
16+
- Use content-based cache keys with `hashFiles('**/Mintfile')`
17+
- Added version suffix (`-v2`) to cache key for cache busting when needed
18+
19+
### 3. Timeout Protection
20+
- Added `timeout-minutes: 10` to the mint bootstrap step
21+
- Prevents the job from hanging indefinitely
22+
23+
### 4. Using `--link` Flag
24+
- Added `--link` flag to `mint bootstrap` command
25+
- Creates symlinks instead of copying binaries, which is faster
26+
27+
## Additional Optimization Strategies
28+
29+
### 1. Pre-built Docker Image
30+
Consider creating a custom Docker image with mint and dependencies pre-installed:
31+
```yaml
32+
runs-on: ubuntu-latest
33+
container:
34+
image: your-org/ios-build-image:latest
35+
```
36+
37+
### 2. Self-hosted Runners
38+
For frequently run workflows, consider using self-hosted runners with pre-installed dependencies.
39+
40+
### 3. Parallel Installation
41+
If you have multiple independent dependencies, install them in parallel:
42+
```yaml
43+
- name: Install dependencies
44+
run: |
45+
mint install realm/SwiftLint@0.53.0 &
46+
mint install yonaskolb/xcodegen@2.38.0 &
47+
mint install bloomberg/xcdiff@0.11.0 &
48+
wait
49+
```
50+
51+
### 4. Conditional Execution
52+
Only run the workflow when necessary:
53+
```yaml
54+
on:
55+
push:
56+
paths:
57+
- '**/*.swift'
58+
- '**/project.yml'
59+
- '**/Mintfile'
60+
```
61+
62+
### 5. Cache Warming
63+
Create a scheduled workflow to warm caches:
64+
```yaml
65+
on:
66+
schedule:
67+
- cron: '0 0 * * 0' # Weekly
68+
```
69+
70+
## Monitoring Performance
71+
72+
Add timing information to track improvements:
73+
```yaml
74+
- name: Bootstrap mint packages
75+
run: |
76+
echo "::group::Mint Bootstrap Timing"
77+
time mint bootstrap --link
78+
echo "::endgroup::"
79+
```
80+
81+
## Expected Results
82+
With these optimizations, the workflow should complete in:
83+
- First run: ~5-10 minutes (building caches)
84+
- Subsequent runs: ~2-3 minutes (using caches)
85+
86+
## Troubleshooting
87+
88+
### Cache Misses
89+
If caches are frequently missing:
90+
1. Check cache key stability
91+
2. Verify runner OS consistency
92+
3. Monitor cache size limits (10GB per repository)
93+
94+
### Slow Network
95+
If downloads are slow:
96+
1. Consider using GitHub's package registry
97+
2. Use a CDN for binary distribution
98+
3. Implement retry logic with exponential backoff

0 commit comments

Comments
 (0)