Skip to content

Commit 77a408d

Browse files
committed
Apply CI standard: optimize workflows
1 parent 6a4471d commit 77a408d

File tree

2 files changed

+58
-89
lines changed

2 files changed

+58
-89
lines changed

.github/workflows/ci.yml

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

1616
jobs:
17-
# Note: Swift Testing framework requires Swift 6.0+
18-
# macOS Swift 5.10 has backported Testing framework via Xcode 26.0
19-
# Linux Swift 5.10 does NOT have Testing framework - use 6.2 only
20-
macos-swift510:
21-
name: macOS (Swift 5.10)
17+
# Primary development workflow: Latest Swift on macOS with debug build
18+
macos-latest:
19+
name: macOS (Swift 6.2, debug)
2220
runs-on: macos-26
23-
strategy:
24-
matrix:
25-
xcode: ['26.0']
26-
config: ['debug', 'release']
2721
steps:
2822
- uses: actions/checkout@v5
2923

30-
- name: Select Xcode ${{ matrix.xcode }}
31-
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
3226

3327
- name: Print Swift version
3428
run: swift --version
@@ -37,48 +31,29 @@ jobs:
3731
uses: actions/cache@v4
3832
with:
3933
path: .build
40-
key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}
34+
key: ${{ runner.os }}-spm-${{ hashFiles('Package.swift') }}
4135
restore-keys: |
4236
${{ runner.os }}-spm-
4337
44-
- name: Build
45-
run: swift build -c ${{ matrix.config }}
46-
47-
- name: Run tests
48-
run: swift test -c ${{ matrix.config }}
49-
50-
macos-swift62:
51-
name: macOS (Swift 6.2)
52-
runs-on: macos-26
53-
strategy:
54-
matrix:
55-
xcode: ['26.0']
56-
config: ['debug', 'release']
57-
steps:
58-
- uses: actions/checkout@v5
59-
60-
- name: Select Xcode ${{ matrix.xcode }}
61-
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
62-
63-
- name: Print Swift version
64-
run: swift --version
38+
# Note: swift test builds automatically, no separate build step needed
39+
- name: Test
40+
run: swift test -c debug
6541

66-
- name: Cache Swift packages
67-
uses: actions/cache@v4
68-
with:
69-
path: .build
70-
key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}
71-
restore-keys: |
72-
${{ runner.os }}-spm-
42+
- name: Validate Package.swift
43+
run: swift package dump-package
7344

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

77-
- name: Run tests
78-
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
7953

80-
linux-swift62:
81-
name: Ubuntu (Swift 6.2)
54+
# Production validation: Latest Swift on Linux with release build
55+
linux-latest:
56+
name: Ubuntu (Swift 6.2, release)
8257
runs-on: ubuntu-latest
8358
container: swift:6.2
8459
steps:
@@ -88,47 +63,29 @@ jobs:
8863
uses: actions/cache@v4
8964
with:
9065
path: .build
91-
key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}
66+
key: ${{ runner.os }}-spm-${{ hashFiles('Package.swift') }}
9267
restore-keys: ${{ runner.os }}-spm-
9368

94-
- name: Build
95-
run: swift build
96-
97-
- name: Run tests
98-
run: swift test
69+
# Note: swift test builds automatically in release mode
70+
- name: Test (release)
71+
run: swift test -c release
9972

100-
readme:
101-
name: README Code Examples
102-
runs-on: macos-26
103-
steps:
104-
- uses: actions/checkout@v5
105-
106-
- name: Select Xcode
107-
run: sudo xcode-select -s /Applications/Xcode_26.0.app
108-
109-
- name: Run README verification tests
110-
run: swift test --filter ReadmeVerificationTests
111-
112-
- name: Validate README examples compile
113-
run: |
114-
echo "✅ All README code examples are verified to compile and work"
115-
116-
documentation:
117-
name: Documentation
118-
runs-on: macos-26
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)
77+
runs-on: ubuntu-latest
78+
container: swift:6.0
11979
steps:
12080
- uses: actions/checkout@v5
12181

122-
- name: Select Xcode
123-
run: sudo xcode-select -s /Applications/Xcode_26.0.app
82+
- name: Cache Swift packages
83+
uses: actions/cache@v4
84+
with:
85+
path: .build
86+
key: ${{ runner.os }}-swift60-spm-${{ hashFiles('Package.swift') }}
87+
restore-keys: ${{ runner.os }}-swift60-spm-
12488

125-
- name: Build documentation
126-
run: |
127-
swift package \
128-
--allow-writing-to-directory ./docs \
129-
generate-documentation \
130-
--target CSSTypes \
131-
--output-path ./docs \
132-
--transform-for-static-hosting \
133-
--hosting-base-path swift-css-types
134-
continue-on-error: true
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-css-types/swift-css-types
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)