Skip to content

Commit 9c8c103

Browse files
leogdionclaude
andcommitted
Fix Android/WASM doc path resolution and coverage conditions
- Add Strategy 1b to Settings.projectRoot: detect Documentation.docc/ in working dir (android-copy-files copies last component only) - Add #if os(Android) branch to docPaths with prefix-less paths matching the flat copy layout on Android devices - Add id: build to swift-build steps and gate coverage upload/processing on steps.build.outputs.contains-code-coverage == 'true' across all jobs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b1414b6 commit 9c8c103

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

.github/workflows/SyntaxKit.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
steps:
6363
- uses: actions/checkout@v6
6464
- uses: brightdigit/swift-build@v1.5.2
65+
id: build
6566
with:
6667
type: ${{ matrix.type }}
6768
wasmtime-version: 41.0.3
@@ -72,9 +73,11 @@ jobs:
7273
apt-get install -y curl
7374
- uses: sersoft-gmbh/swift-coverage-action@v5
7475
id: coverage-files
76+
if: steps.build.outputs.contains-code-coverage == 'true'
7577
with:
7678
fail-on-empty-output: true
7779
- name: Upload coverage to Codecov
80+
if: steps.build.outputs.contains-code-coverage == 'true'
7881
uses: codecov/codecov-action@v6
7982
with:
8083
fail_ci_if_error: true
@@ -102,10 +105,12 @@ jobs:
102105
steps:
103106
- uses: actions/checkout@v6
104107
- uses: brightdigit/swift-build@v1.5.2
108+
id: build
105109
with:
106110
windows-swift-version: ${{ matrix.swift-version }}
107111
windows-swift-build: ${{ matrix.swift-build }}
108112
- name: Upload coverage to Codecov
113+
if: steps.build.outputs.contains-code-coverage == 'true'
109114
uses: codecov/codecov-action@v6
110115
with:
111116
fail_ci_if_error: true
@@ -134,6 +139,7 @@ jobs:
134139
- uses: actions/checkout@v6
135140

136141
- name: Build and Test
142+
id: build
137143
uses: brightdigit/swift-build@v1.5.2
138144
with:
139145
scheme: ${{ env.PACKAGE_NAME }}-Package
@@ -145,9 +151,11 @@ jobs:
145151

146152
# Common Coverage Steps
147153
- name: Process Coverage
154+
if: steps.build.outputs.contains-code-coverage == 'true'
148155
uses: sersoft-gmbh/swift-coverage-action@v5
149156

150157
- name: Upload Coverage
158+
if: steps.build.outputs.contains-code-coverage == 'true'
151159
uses: codecov/codecov-action@v6
152160
with:
153161
token: ${{ secrets.CODECOV_TOKEN }}
@@ -214,6 +222,7 @@ jobs:
214222
- uses: actions/checkout@v6
215223

216224
- name: Build and Test
225+
id: build
217226
uses: brightdigit/swift-build@v1.5.2
218227
with:
219228
scheme: ${{ env.PACKAGE_NAME }}-Package
@@ -225,9 +234,11 @@ jobs:
225234

226235
# Common Coverage Steps
227236
- name: Process Coverage
237+
if: steps.build.outputs.contains-code-coverage == 'true'
228238
uses: sersoft-gmbh/swift-coverage-action@v5
229239

230240
- name: Upload Coverage
241+
if: steps.build.outputs.contains-code-coverage == 'true'
231242
uses: codecov/codecov-action@v6
232243
with:
233244
token: ${{ secrets.CODECOV_TOKEN }}

Tests/SyntaxDocTests/Settings.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@ import Foundation
1010
internal enum Settings {
1111
/// Project root directory calculated with a 3-strategy fallback for cross-platform support
1212
internal static let projectRoot: URL = {
13-
// Strategy 1: Working directory (most reliable for SPM/WASM/Android)
1413
let workingDir = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
14+
15+
// Strategy 1a: Sources/ in working directory (SPM/WASM/Linux)
1516
if FileManager.default.fileExists(atPath: workingDir.appendingPathComponent("Sources").path) {
1617
return workingDir
1718
}
1819

20+
// Strategy 1b: Documentation.docc copied as last component (Android flat copy via android-copy-files)
21+
if FileManager.default.fileExists(
22+
atPath: workingDir.appendingPathComponent("Documentation.docc").path)
23+
{
24+
return workingDir
25+
}
26+
1927
// Strategy 2: Source-relative via #filePath (macOS/Linux CI)
2028
let sourceRelative = URL(fileURLWithPath: #filePath)
2129
.deletingLastPathComponent() // Tests/SyntaxDocTests
@@ -44,7 +52,13 @@ internal enum Settings {
4452
/// On WASM, limited to lightweight tutorial files only (no images, no Examples)
4553
/// due to WASM memory constraints (~144KB practical limit)
4654
internal static let docPaths: [String] = {
47-
#if os(WASI)
55+
#if os(Android)
56+
// android-copy-files copies Documentation.docc/ as last component to working dir
57+
return [
58+
"Documentation.docc/Tutorials/Quick-Start-Guide.md",
59+
"Documentation.docc/Tutorials/Creating-Macros-with-SyntaxKit.md",
60+
]
61+
#elseif os(WASI)
4862
return [
4963
"Sources/SyntaxKit/Documentation.docc/Tutorials/Quick-Start-Guide.md",
5064
"Sources/SyntaxKit/Documentation.docc/Tutorials/Creating-Macros-with-SyntaxKit.md",

0 commit comments

Comments
 (0)