Skip to content

Commit 7f6b313

Browse files
committed
chore: apply CI standard to match 3-job baseline pattern
Updates CI workflows to follow organizational standard: - Reduced from 6 jobs to 3 (1 macOS + 2 Linux) - Fixed cache keys to use Package.swift instead of Package.resolved - Removed redundant build steps (swift test builds automatically) - Consolidated validation steps into macos-latest job - Updated swift-format.yml with proper caching (separate restore/save steps) - Added git safe directory configuration - Used static cache keys for swift-format tool Benefits: - 83% reduction in macOS runner usage - No redundant builds - Faster CI execution - Proper cache invalidation strategy
1 parent 3dc7ca9 commit 7f6b313

File tree

2 files changed

+54
-100
lines changed

2 files changed

+54
-100
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,15 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17-
macos-swift60:
18-
name: macOS (Swift 6.0)
17+
# Primary development workflow: Latest Swift on macOS with debug build
18+
macos-latest:
19+
name: macOS (Swift 6.2, debug)
1920
runs-on: macos-26
20-
strategy:
21-
matrix:
22-
xcode: ['26.0']
23-
config: ['debug', 'release']
2421
steps:
2522
- uses: actions/checkout@v5
2623

27-
- name: Select Xcode ${{ matrix.xcode }}
28-
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
24+
- name: Select Xcode 26.0
25+
run: sudo xcode-select -s /Applications/Xcode_26.0.app
2926

3027
- name: Print Swift version
3128
run: swift --version
@@ -34,116 +31,61 @@ jobs:
3431
uses: actions/cache@v4
3532
with:
3633
path: .build
37-
key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}
34+
key: ${{ runner.os }}-spm-${{ hashFiles('Package.swift') }}
3835
restore-keys: |
3936
${{ runner.os }}-spm-
4037
41-
- name: Build
42-
run: swift build -c ${{ matrix.config }}
43-
44-
- name: Run tests
45-
run: swift test -c ${{ matrix.config }}
46-
47-
macos-swift62:
48-
name: macOS (Swift 6.2)
49-
runs-on: macos-26
50-
strategy:
51-
matrix:
52-
xcode: ['26.0']
53-
config: ['debug', 'release']
54-
steps:
55-
- uses: actions/checkout@v5
56-
57-
- name: Select Xcode ${{ matrix.xcode }}
58-
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
38+
# Note: swift test builds automatically, no separate build step needed
39+
- name: Test
40+
run: swift test -c debug
5941

60-
- name: Print Swift version
61-
run: swift --version
62-
63-
- name: Cache Swift packages
64-
uses: actions/cache@v4
65-
with:
66-
path: .build
67-
key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}
68-
restore-keys: |
69-
${{ runner.os }}-spm-
42+
- name: Validate Package.swift
43+
run: swift package dump-package
7044

71-
- name: Build
72-
run: swift build -c ${{ matrix.config }}
45+
- name: Run README verification tests
46+
run: swift test --filter ReadmeVerificationTests
7347

74-
- name: Run tests
75-
run: swift test -c ${{ matrix.config }}
48+
- name: Check for API breaking changes
49+
run: |
50+
swift package diagnose-api-breaking-changes \
51+
--breakage-allowlist-path .swift-api-breakage-allowlist || true
52+
continue-on-error: true
7653

77-
linux-swift60:
78-
name: Ubuntu (Swift 6.0)
54+
# Production validation: Latest Swift on Linux with release build
55+
linux-latest:
56+
name: Ubuntu (Swift 6.2, release)
7957
runs-on: ubuntu-latest
80-
container: swift:6.0
58+
container: swift:6.2
8159
steps:
8260
- uses: actions/checkout@v5
8361

8462
- name: Cache Swift packages
8563
uses: actions/cache@v4
8664
with:
8765
path: .build
88-
key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}
66+
key: ${{ runner.os }}-spm-${{ hashFiles('Package.swift') }}
8967
restore-keys: ${{ runner.os }}-spm-
9068

91-
- name: Build
92-
run: swift build
93-
94-
- name: Run tests
95-
run: swift test
69+
# Note: swift test builds automatically in release mode
70+
- name: Test (release)
71+
run: swift test -c release
9672

97-
linux-swift62:
98-
name: Ubuntu (Swift 6.2)
73+
# Compatibility check: Minimum supported Swift version (6.0)
74+
# Note: Swift Testing framework requires Swift 6.0+
75+
linux-compat:
76+
name: Ubuntu (Swift 6.0, compatibility)
9977
runs-on: ubuntu-latest
100-
container: swift:6.2
78+
container: swift:6.0
10179
steps:
10280
- uses: actions/checkout@v5
10381

10482
- name: Cache Swift packages
10583
uses: actions/cache@v4
10684
with:
10785
path: .build
108-
key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}
109-
restore-keys: ${{ runner.os }}-spm-
110-
111-
- name: Build
112-
run: swift build
113-
114-
- name: Run tests
115-
run: swift test
116-
117-
package-validation:
118-
name: Package Validation
119-
runs-on: macos-26
120-
steps:
121-
- uses: actions/checkout@v5
86+
key: ${{ runner.os }}-swift60-spm-${{ hashFiles('Package.swift') }}
87+
restore-keys: ${{ runner.os }}-swift60-spm-
12288

123-
- name: Select Xcode
124-
run: sudo xcode-select -s /Applications/Xcode_26.0.app
125-
126-
- name: Validate Package.swift
127-
run: swift package dump-package
128-
129-
- name: Check for API breaking changes
130-
run: |
131-
swift package diagnose-api-breaking-changes \
132-
--breakage-allowlist-path .swift-api-breakage-allowlist || true
133-
continue-on-error: true
134-
135-
readme-validation:
136-
name: README Code Examples
137-
runs-on: macos-26
138-
steps:
139-
- uses: actions/checkout@v5
140-
141-
- name: Select Xcode
142-
run: sudo xcode-select -s /Applications/Xcode_26.0.app
143-
144-
- name: Run README verification tests
145-
run: swift test --filter ReadmeVerificationTests
146-
147-
- name: Validate README examples compile
148-
run: |
149-
echo "✅ All README code examples are verified to compile and work"
89+
# Note: swift test builds automatically
90+
- name: Test (Swift 6.0)
91+
run: swift test -c release

.github/workflows/swift-format.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,21 @@ jobs:
1818
contents: write
1919
steps:
2020
- uses: actions/checkout@v5
21+
with:
22+
ref: ${{ github.head_ref || github.ref_name }}
23+
24+
- name: Configure git safe directory
25+
run: git config --global --add safe.directory /__w/swift-domain-type/swift-domain-type
2126

22-
- name: Cache swift-format
23-
id: cache-swift-format
24-
uses: actions/cache@v4
27+
- name: Restore swift-format cache
28+
id: cache-swift-format-restore
29+
uses: actions/cache/restore@v4
2530
with:
2631
path: /usr/local/bin/swift-format
27-
key: ${{ runner.os }}-swift-format-${{ hashFiles('.github/workflows/swift-format.yml') }}
32+
key: ${{ runner.os }}-swift-format-main-v1
2833

2934
- name: Install swift-format
30-
if: steps.cache-swift-format.outputs.cache-hit != 'true'
35+
if: steps.cache-swift-format-restore.outputs.cache-hit != 'true'
3136
run: |
3237
git clone --depth 1 --branch main https://github.com/apple/swift-format.git
3338
cd swift-format
@@ -37,9 +42,16 @@ jobs:
3742
rm -rf swift-format
3843
3944
- name: Format
40-
run: swift-format format --ignore-unparsable-files --recursive --in-place Sources Tests
45+
run: swift-format format --recursive --in-place --ignore-unparsable-files Sources Tests
4146

4247
- uses: stefanzweifel/git-auto-commit-action@v7
4348
with:
4449
commit_message: Run swift-format
4550
branch: 'main'
51+
52+
- name: Save swift-format cache
53+
uses: actions/cache/save@v4
54+
if: steps.cache-swift-format-restore.outputs.cache-hit != 'true'
55+
with:
56+
path: /usr/local/bin/swift-format
57+
key: ${{ runner.os }}-swift-format-main-v1

0 commit comments

Comments
 (0)