Skip to content

Commit 392ed86

Browse files
authored
Sanitize CLI (#409)
* reduce the amount of hidden directories Unidoc requires, split the CompileCommand into two subcommands * make PackageBuild use the shared cache again, when running in slave mode * i can’t seem to stop self-sabotaging * update macOS package build script
1 parent 67a3fcd commit 392ed86

21 files changed

+602
-282
lines changed

.github/workflows/docs.yml renamed to .github/workflows/Docs.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
- name: Install Swift
2020
uses: tayloraswift/swift-install-action@master
2121
with:
22-
swift-prefix: "swift-6.0.1-release/ubuntu2404/swift-6.0.1-RELEASE"
23-
swift-id: "swift-6.0.1-RELEASE-ubuntu24.04"
22+
swift-prefix: "swift-6.0.3-release/ubuntu2404/swift-6.0.3-RELEASE"
23+
swift-id: "swift-6.0.3-RELEASE-ubuntu24.04"
2424

2525
# This installs an older version of Unidoc, not the one we are testing.
2626
# We use `--static-swift-stdlib` so it doesn’t matter if the Unidoc binary was
@@ -34,9 +34,9 @@ jobs:
3434
- name: Build documentation
3535
run: |
3636
unidoc compile -I .. \
37-
--swift-toolchain $SWIFT_INSTALLATION \
38-
--ci fail-on-errors \
39-
--package-name swift-unidoc
37+
--ci fail-on-errors \
38+
--package-name swift-unidoc \
39+
--swift-toolchain $SWIFT_INSTALLATION
4040
4141
macos:
4242
runs-on: macos-15
@@ -54,5 +54,5 @@ jobs:
5454
- name: Build documentation
5555
run: |
5656
unidoc compile -I .. \
57-
--ci fail-on-errors \
58-
--package-name swift-unidoc
57+
--ci fail-on-errors \
58+
--package-name swift-unidoc

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/Assets/secrets/
1717
/Assets/icons/*.jpg
1818

19+
/TestModules/Determinism/*.json
1920
/TestModules/SymbolGraphs/*.json
2021
/TestModules/*.json
2122
/TestPackages/*.bson

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<strong><em><code>unidoc</code></em></strong>
44

55
[![ci build status](https://github.com/tayloraswift/swift-unidoc/actions/workflows/Test.yml/badge.svg)](https://github.com/tayloraswift/swift-unidoc/actions/workflows/Test.yml)
6-
[![ci build status](https://github.com/tayloraswift/swift-unidoc/actions/workflows/docs.yml/badge.svg)](https://github.com/tayloraswift/swift-unidoc/actions/workflows/docs.yml)
6+
[![ci build status](https://github.com/tayloraswift/swift-unidoc/actions/workflows/Docs.yml/badge.svg)](https://github.com/tayloraswift/swift-unidoc/actions/workflows/Docs.yml)
77
[![ci build status](https://github.com/tayloraswift/swift-unidoc/actions/workflows/Deploy.yml/badge.svg)](https://github.com/tayloraswift/swift-unidoc/actions/workflows/Deploy.yml)
88

99
</div>

Scripts/Linux/GeneratePackageSymbolGraphs

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,37 @@ set -e
33

44
swift --version
55

6-
ssgc -u $SWIFT_INSTALLATION \
7-
-r https://github.com/apple/swift-atomics.git \
8-
-t 1.2.0 \
9-
-n swift-atomics \
6+
ssgc slave https://github.com/apple/swift-atomics.git 1.2.0 \
7+
-u $SWIFT_INSTALLATION \
108
-o TestPackages/swift-atomics.bson
119

12-
ssgc -u $SWIFT_INSTALLATION \
13-
-r https://github.com/apple/swift-nio.git \
14-
-t 2.75.0 \
15-
-n swift-nio \
10+
ssgc slave https://github.com/apple/swift-nio.git 2.75.0 \
11+
-u $SWIFT_INSTALLATION \
1612
-o TestPackages/swift-nio.bson
1713

18-
ssgc -u $SWIFT_INSTALLATION \
19-
-r https://github.com/apple/swift-nio-ssl.git \
20-
-t 2.29.0 \
21-
-n swift-nio-ssl \
14+
ssgc slave https://github.com/apple/swift-nio-ssl.git 2.29.0 \
15+
-u $SWIFT_INSTALLATION \
2216
-o TestPackages/swift-nio-ssl.bson
2317

24-
ssgc -u $SWIFT_INSTALLATION \
25-
-r https://github.com/apple/swift-async-dns-resolver.git \
26-
-t 0.1.2 \
27-
-n swift-async-dns-resolver \
18+
ssgc slave https://github.com/apple/swift-async-dns-resolver.git 0.1.2 \
19+
-u $SWIFT_INSTALLATION \
2820
-o TestPackages/swift-async-dns-resolver.bson
2921

30-
ssgc -u $SWIFT_INSTALLATION \
31-
-r https://github.com/swiftlang/swift-syntax.git \
32-
-t 600.0.1 \
33-
-n swift-syntax \
22+
ssgc slave https://github.com/swiftlang/swift-syntax.git 600.0.1 \
23+
-u $SWIFT_INSTALLATION \
3424
-o TestPackages/swift-syntax.bson
3525

36-
ssgc -u $SWIFT_INSTALLATION \
37-
-r https://github.com/pointfreeco/swift-snapshot-testing.git \
38-
-t 1.17.5 \
39-
-n swift-snapshot-testing \
26+
ssgc slave https://github.com/pointfreeco/swift-snapshot-testing.git 1.17.5 \
27+
-u $SWIFT_INSTALLATION \
4028
-o TestPackages/swift-snapshot-testing.bson
4129

42-
ssgc -u $SWIFT_INSTALLATION \
43-
-r https://github.com/swiftlang/indexstore-db.git \
44-
-t swift-6.0-RELEASE \
45-
-n indexstore-db \
30+
ssgc slave https://github.com/swiftlang/indexstore-db.git swift-6.0-RELEASE \
31+
-u $SWIFT_INSTALLATION \
4632
-o TestPackages/indexstore-db.bson \
4733
--Xcxx -I$SWIFT_INSTALLATION/lib/swift \
4834
--Xcxx -I$SWIFT_INSTALLATION/lib/swift/Block
4935

50-
ssgc -u $SWIFT_INSTALLATION \
51-
-r https://github.com/swiftlang/swift-book.git \
52-
-t swift-5.10-fcs \
36+
ssgc slave https://github.com/swiftlang/swift-book.git swift-5.10-fcs \
37+
-u $SWIFT_INSTALLATION \
5338
-b book \
54-
-n swift-book \
5539
-o TestPackages/swift-book.bson

Scripts/Linux/GenerateTestSymbolGraphs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ do
4141
done
4242
done
4343

44-
.build/release/ssgc -u $SWIFT_INSTALLATION \
44+
.build/release/ssgc build -u $SWIFT_INSTALLATION \
4545
-n swift \
4646
-o TestPackages/swift.bson
4747

4848
for PACKAGE in swift-test swift-malibu swift-snippets swift-exportation cross-module-articles
4949
do
50-
.build/release/ssgc -u $SWIFT_INSTALLATION \
50+
.build/release/ssgc build -u $SWIFT_INSTALLATION \
5151
-p TestPackages/$PACKAGE \
5252
-o TestPackages/$PACKAGE.bson
5353
done

Scripts/macOS/GeneratePackageSymbolGraphs

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,27 @@ set -e
33

44
swift --version
55

6-
ssgc \
7-
-r https://github.com/apple/swift-atomics.git \
8-
-t 1.2.0 \
9-
-n swift-atomics \
6+
ssgc slave https://github.com/apple/swift-atomics.git 1.2.0 \
107
-o TestPackages/swift-atomics.bson
118

12-
ssgc \
13-
-r https://github.com/apple/swift-nio.git \
14-
-t 2.75.0 \
15-
-n swift-nio \
9+
ssgc slave https://github.com/apple/swift-nio.git 2.75.0 \
1610
-o TestPackages/swift-nio.bson
1711

18-
ssgc \
19-
-r https://github.com/apple/swift-nio-ssl.git \
20-
-t 2.29.0 \
21-
-n swift-nio-ssl \
12+
ssgc slave https://github.com/apple/swift-nio-ssl.git 2.29.0 \
2213
-o TestPackages/swift-nio-ssl.bson
2314

24-
ssgc \
25-
-r https://github.com/apple/swift-async-dns-resolver.git \
26-
-t 0.1.2 \
27-
-n swift-async-dns-resolver \
15+
ssgc slave https://github.com/apple/swift-async-dns-resolver.git 0.1.2 \
2816
-o TestPackages/swift-async-dns-resolver.bson
2917

30-
ssgc \
31-
-r https://github.com/swiftlang/swift-syntax.git \
32-
-t 600.0.1 \
33-
-n swift-syntax \
18+
ssgc slave https://github.com/swiftlang/swift-syntax.git 600.0.1 \
3419
-o TestPackages/swift-syntax.bson
3520

36-
ssgc \
37-
-r https://github.com/pointfreeco/swift-snapshot-testing.git \
38-
-t 1.17.5 \
39-
-n swift-snapshot-testing \
21+
ssgc slave https://github.com/pointfreeco/swift-snapshot-testing.git 1.17.5 \
4022
-o TestPackages/swift-snapshot-testing.bson
4123

42-
ssgc \
43-
-r https://github.com/swiftlang/indexstore-db.git \
44-
-t swift-6.0-RELEASE \
45-
-n indexstore-db \
24+
ssgc slave https://github.com/swiftlang/indexstore-db.git swift-6.0-RELEASE \
4625
-o TestPackages/indexstore-db.bson
4726

48-
ssgc \
49-
-r https://github.com/swiftlang/swift-book.git \
50-
-t swift-5.10-fcs \
27+
ssgc slave https://github.com/swiftlang/swift-book.git swift-5.10-fcs \
5128
-b book \
52-
-n swift-book \
5329
-o TestPackages/swift-book.bson

Sources/SymbolGraphBuilder/Builds/SSGC.DocumentationBuild.swift

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,33 @@ extension SSGC
55
{
66
protocol DocumentationBuild
77
{
8-
mutating
98
func compile(updating status:SSGC.StatusStream?,
10-
cache:FilePath.Directory,
119
with swift:Toolchain,
1210
clean:Bool) throws -> (SymbolGraphMetadata, any DocumentationSources)
1311
}
1412
}
13+
extension SSGC.DocumentationBuild
14+
{
15+
func build(
16+
toolchain swift:SSGC.Toolchain,
17+
define defines:[String] = [],
18+
status:SSGC.StatusStream? = nil,
19+
logger:SSGC.Logger = .default(),
20+
clean:Bool) throws -> SymbolGraphObject<Void>
21+
{
22+
/// TODO: support values?
23+
let definitions:[String: Void] = defines.reduce(into: [:]) { $0[$1] = () }
24+
25+
let metadata:SymbolGraphMetadata
26+
let package:any SSGC.DocumentationSources
27+
28+
(metadata, package) = try self.compile(updating: status, with: swift, clean: clean)
29+
30+
let documentation:SymbolGraph = try package.link(
31+
definitions: definitions,
32+
logger: logger,
33+
with: swift)
34+
35+
return .init(metadata: metadata, graph: documentation)
36+
}
37+
}

Sources/SymbolGraphBuilder/Builds/SSGC.PackageBuild.swift

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ extension SSGC
1515
let id:ID
1616

1717
let scratch:PackageBuildDirectory
18+
let cache:FilePath.Directory?
1819

1920
/// Additional flags to pass to the Swift compiler.
2021
var flags:Flags
@@ -26,12 +27,14 @@ extension SSGC
2627
private
2728
init(id:ID,
2829
scratch:PackageBuildDirectory,
30+
cache:FilePath.Directory?,
2931
flags:Flags,
3032
root:FilePath.Directory,
3133
type:ProjectType)
3234
{
3335
self.id = id
3436
self.scratch = scratch
37+
self.cache = cache
3538
self.flags = flags
3639
self.root = root
3740
self.type = type
@@ -81,8 +84,8 @@ extension SSGC.PackageBuild
8184
/// The type of project to build.
8285
/// - flags:
8386
/// Additional flags to pass to the Swift compiler.
84-
public static
85-
func local(project location:FilePath.Directory,
87+
public
88+
static func local(project location:FilePath.Directory,
8689
using scratchName:FilePath.Component = ".build.ssgc",
8790
as type:SSGC.ProjectType = .package,
8891
flags:Flags = .init()) -> Self
@@ -103,6 +106,7 @@ extension SSGC.PackageBuild
103106

104107
return .init(id: .unversioned(.init(last.string)),
105108
scratch: scratch,
109+
cache: nil,
106110
flags: flags,
107111
root: location,
108112
type: type)
@@ -124,8 +128,8 @@ extension SSGC.PackageBuild
124128
/// The type of project to build.
125129
/// - workspace:
126130
/// The directory in which this function will create folders.
127-
public static
128-
func remote(project projectName:Symbol.Package,
131+
public
132+
static func remote(project projectName:Symbol.Package,
129133
from repository:String,
130134
at refName:String,
131135
as type:SSGC.ProjectType = .package,
@@ -153,6 +157,7 @@ extension SSGC.PackageBuild
153157

154158
return .init(id: .versioned(pin, ref: refName, date: checkout.date),
155159
scratch: scratch,
160+
cache: workspace.cache,
156161
flags: flags,
157162
root: checkout.location,
158163
type: type)
@@ -162,22 +167,16 @@ extension SSGC.PackageBuild
162167
extension SSGC.PackageBuild:SSGC.DocumentationBuild
163168
{
164169
func compile(updating status:SSGC.StatusStream?,
165-
cache:FilePath.Directory,
166170
with toolchain:SSGC.Toolchain,
167171
clean:Bool = true) throws -> (SymbolGraphMetadata, any SSGC.DocumentationSources)
168172
{
169173
switch self.type
170174
{
171175
case .package:
172-
try self.compileSwiftPM(updating: status,
173-
cache: cache,
174-
with: toolchain,
175-
clean: clean)
176+
try self.compileSwiftPM(updating: status, with: toolchain, clean: clean)
176177

177178
case .book:
178-
try self.compileBook(updating: status,
179-
cache: cache,
180-
with: toolchain)
179+
try self.compileBook(updating: status, with: toolchain)
181180
}
182181
}
183182
}
@@ -186,7 +185,6 @@ extension SSGC.PackageBuild
186185
{
187186
@_spi(testable) public
188187
func compileBook(updating status:SSGC.StatusStream? = nil,
189-
cache _:FilePath.Directory,
190188
with toolchain:SSGC.Toolchain) throws -> (SymbolGraphMetadata, SSGC.BookSources)
191189
{
192190
switch self.id
@@ -232,7 +230,6 @@ extension SSGC.PackageBuild
232230

233231
@_spi(testable) public
234232
func compileSwiftPM(updating status:SSGC.StatusStream? = nil,
235-
cache _:FilePath.Directory,
236233
with toolchain:SSGC.Toolchain,
237234
clean:Bool = true) throws -> (SymbolGraphMetadata, SSGC.PackageSources)
238235
{
@@ -324,7 +321,7 @@ extension SSGC.PackageBuild
324321

325322
// Dump the standard library’s symbols, unless they’re already cached.
326323
let symbolsCached:FilePath.Directory = try toolchain.dump(stdlib: stdlib,
327-
cache: artifacts)
324+
cache: self.cache ?? artifacts)
328325

329326
let symbols:FilePath.Directory = artifacts / "symbols"
330327
try symbols.create(clean: false)

0 commit comments

Comments
 (0)