Skip to content

Commit c389168

Browse files
authored
add CI mode to SSGC (#323)
1 parent 3264bfd commit c389168

30 files changed

+368
-52
lines changed

.github/workflows/package.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: package
2+
3+
on:
4+
# We build semver tags, and the master branch.
5+
push:
6+
branches: [ master ]
7+
tags:
8+
- '[0-9]+.[0-9]+.[0-9]+'
9+
10+
jobs:
11+
macos:
12+
runs-on: macos-14
13+
name: macOS
14+
15+
env:
16+
DEVELOPER_DIR: "/Applications/Xcode_15.3.app/Contents/Developer"
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v3
21+
22+
- name: Build products
23+
env:
24+
UNIDOC_ENABLE_INDEXSTORE: "1"
25+
run: |
26+
swift --version
27+
swift build -c release --product unidoc-publish
28+
swift build -c release --product unidoc-tools
29+
30+
- name: Upload products
31+
env:
32+
AWS_S3_ACCESS_SECRET: ${{ secrets.AWS_S3_ACCESS_SECRET }}
33+
34+
UNIDOC_PLATFORM: "${{ runner.os }}-${{ runner.arch }}"
35+
UNIDOC_VERSION: ${{ github.head_ref || github.ref_name }}
36+
37+
run: |
38+
.build/release/unidoc-publish \
39+
unidoc-tools \
40+
/unidoc/$UNIDOC_VERSION/$UNIDOC_PLATFORM/unidoc \
41+
--secret "$AWS_S3_ACCESS_SECRET"
42+
43+
linux:
44+
runs-on: ubuntu-24.04
45+
name: Ubuntu 24.04
46+
47+
env:
48+
SWIFT_PREFIX: "swift-5.10.1-release/ubuntu2404/swift-5.10.1-RELEASE"
49+
SWIFT_ID: "swift-5.10.1-RELEASE-ubuntu24.04"
50+
51+
steps:
52+
- name: Cache Swift toolchain
53+
uses: actions/cache@v2
54+
with:
55+
path: ${{ env.SWIFT_ID }}.tar.gz
56+
key: ${{ env.SWIFT_ID }}
57+
58+
- name: Cache status
59+
id: cache_status
60+
uses: andstor/file-existence-action@v1
61+
with:
62+
files: ${{ env.SWIFT_ID }}.tar.gz
63+
64+
- name: Download Swift
65+
if: steps.cache_status.outputs.files_exists == 'false'
66+
run: |
67+
curl https://download.swift.org/$SWIFT_PREFIX/$SWIFT_ID.tar.gz \
68+
--output $SWIFT_ID.tar.gz
69+
70+
- name: Set up Swift
71+
run: |
72+
mkdir -p $HOME/$SWIFT_ID
73+
tar -xzf $SWIFT_ID.tar.gz -C $HOME/$SWIFT_ID --strip 1
74+
echo "$HOME/$SWIFT_ID/usr/bin" >> $GITHUB_PATH
75+
cat $GITHUB_PATH
76+
77+
# This clobbers everything in the current directory, which is why we installed
78+
# the Swift toolchain in the home directory.
79+
- name: Checkout repository
80+
uses: actions/checkout@v3
81+
82+
# For some reason, Swift cannot build both the products in one invocation.
83+
# We pass the same flags to both invocations to speed up the build.
84+
- name: Build products
85+
env:
86+
UNIDOC_ENABLE_INDEXSTORE: "1"
87+
run: |
88+
swift --version
89+
swift build -c release \
90+
--static-swift-stdlib \
91+
--product unidoc-publish \
92+
-Xcxx -I$HOME/$SWIFT_ID/usr/lib/swift \
93+
-Xcxx -I$HOME/$SWIFT_ID/usr/lib/swift/Block
94+
swift build -c release \
95+
--static-swift-stdlib \
96+
--product unidoc-tools \
97+
-Xcxx -I$HOME/$SWIFT_ID/usr/lib/swift \
98+
-Xcxx -I$HOME/$SWIFT_ID/usr/lib/swift/Block
99+
100+
- name: Upload products
101+
env:
102+
AWS_S3_ACCESS_SECRET: ${{ secrets.AWS_S3_ACCESS_SECRET }}
103+
104+
UNIDOC_PLATFORM: "${{ runner.os }}-${{ runner.arch }}"
105+
UNIDOC_VERSION: ${{ github.head_ref || github.ref_name }}
106+
107+
run: |
108+
.build/release/unidoc-publish \
109+
unidoc-tools \
110+
/unidoc/$UNIDOC_VERSION/$UNIDOC_PLATFORM/unidoc \
111+
--secret "$AWS_S3_ACCESS_SECRET"

Package.resolved

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ let package:Package = .init(
88
platforms: [.macOS(.v14)],
99
products: [
1010
.executable(name: "ssgc", targets: ["ssgc"]),
11-
.executable(name: "unidoc-build", targets: ["unidoc-build"]),
12-
.executable(name: "unidoc-preview", targets: ["unidoc-preview"]),
11+
.executable(name: "unidoc-tools", targets: ["unidoc-tools"]),
12+
.executable(name: "unidoc-publish", targets: ["unidoc-publish"]),
1313

1414
.library(name: "guides", targets: ["guides"]),
1515

@@ -94,7 +94,7 @@ let package:Package = .init(
9494
.package(url: "https://github.com/tayloraswift/swift-mongodb", .upToNextMinor(
9595
from: "0.23.1")),
9696
.package(url: "https://github.com/tayloraswift/swift-unixtime", .upToNextMinor(
97-
from: "0.1.0")),
97+
from: "0.1.5")),
9898

9999
.package(url: "https://github.com/tayloraswift/swift-json", .upToNextMinor(
100100
from: "1.1.0")),
@@ -126,20 +126,20 @@ let package:Package = .init(
126126
targets: [
127127
.executableTarget(name: "ssgc",
128128
dependencies: [
129-
.target(name: "ArgumentParsing"),
130129
.target(name: "SymbolGraphBuilder"),
131130
]),
132131

133-
.executableTarget(name: "unidoc-build",
132+
.executableTarget(name: "unidoc-tools",
134133
dependencies: [
135-
.product(name: "ArgumentParser", package: "swift-argument-parser"),
134+
.target(name: "System_ArgumentParser"),
136135
.target(name: "UnidocClient"),
136+
.target(name: "UnidocServer"),
137137
]),
138138

139-
.executableTarget(name: "unidoc-preview",
139+
.executableTarget(name: "unidoc-publish",
140140
dependencies: [
141141
.target(name: "System_ArgumentParser"),
142-
.target(name: "UnidocServer"),
142+
.target(name: "S3Client"),
143143
]),
144144

145145

Sources/SourceDiagnostics/Emission/DiagnosticAlert.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
struct DiagnosticAlert
55
{
66
@usableFromInline
7-
let type:DiagnosticPrefix
7+
let type:DiagnosticLevel
88
@usableFromInline
99
let text:String
1010

1111
@inlinable
12-
init(type:DiagnosticPrefix, text:String)
12+
init(type:DiagnosticLevel, text:String)
1313
{
1414
self.type = type
1515
self.text = text

Sources/SourceDiagnostics/Emission/DiagnosticPrefix.swift renamed to Sources/SourceDiagnostics/Emission/DiagnosticLevel.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
@frozen public
2-
enum DiagnosticPrefix:Equatable, Hashable, Comparable
2+
enum DiagnosticLevel:Equatable, Hashable, Comparable
33
{
44
case note
55
case warning
66
case error
77
}
8-
extension DiagnosticPrefix:CustomStringConvertible
8+
extension DiagnosticLevel:CustomStringConvertible
99
{
1010
@inlinable public
1111
var description:String
@@ -18,7 +18,7 @@ extension DiagnosticPrefix:CustomStringConvertible
1818
}
1919
}
2020
}
21-
extension DiagnosticPrefix
21+
extension DiagnosticLevel
2222
{
2323
var color:TerminalColor?
2424
{

Sources/SourceDiagnostics/Formatting/DiagnosticFragment.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Sources
44
enum DiagnosticFragment
55
{
66
case heading(SourceLocation<String>?)
7-
case message(DiagnosticPrefix, String)
7+
case message(DiagnosticLevel, String)
88
case context([DiagnosticLine])
99
}
1010
extension DiagnosticFragment:CustomStringConvertible

Sources/SourceDiagnostics/Formatting/DiagnosticOutput.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct DiagnosticOutput<Symbolicator>:~Copyable where Symbolicator:DiagnosticSym
2121
extension DiagnosticOutput
2222
{
2323
@inlinable public
24-
subscript(type:DiagnosticPrefix) -> String
24+
subscript(type:DiagnosticLevel) -> String
2525
{
2626
get
2727
{
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
public
2-
protocol DiagnosticLogger
1+
public
2+
protocol DiagnosticLogger:AnyObject
33
{
44
func emit(messages:consuming DiagnosticMessages) throws
55
}

Sources/SourceDiagnostics/Symbolication/DiagnosticMessages.swift

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,29 @@ struct DiagnosticMessages
44
private
55
var fragments:[DiagnosticFragment]
66

7-
init(fragments:[DiagnosticFragment])
7+
public
8+
let status:DiagnosticLevel
9+
10+
private
11+
init(fragments:[DiagnosticFragment], status:DiagnosticLevel)
812
{
913
self.fragments = fragments
14+
self.status = status
15+
}
16+
}
17+
extension DiagnosticMessages
18+
{
19+
init(fragments:[DiagnosticFragment])
20+
{
21+
let status:DiagnosticLevel = fragments.reduce(into: .note)
22+
{
23+
if case .message(let level, _) = $1
24+
{
25+
$0 = max($0, level)
26+
}
27+
}
28+
29+
self.init(fragments: fragments, status: status)
1030
}
1131
}
1232
extension DiagnosticMessages:CustomStringConvertible
@@ -22,7 +42,7 @@ extension DiagnosticMessages:CustomStringConvertible
2242
extension DiagnosticMessages
2343
{
2444
public mutating
25-
func demoteErrors(to level:DiagnosticPrefix)
45+
func demoteErrors(to level:DiagnosticLevel)
2646
{
2747
for i:Int in self.fragments.indices
2848
{

Sources/SymbolGraphBuilder/Builds/SSGC.Workspace.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ extension SSGC.Workspace
7272
func build<Build>(some build:consuming Build,
7373
toolchain swift:SSGC.Toolchain,
7474
status:SSGC.StatusStream?,
75-
logger:SSGC.Logger = .init(file: nil),
75+
logger:SSGC.Logger = .default(),
7676
clean:Bool) throws -> SymbolGraphObject<Void>
7777
where Build:SSGC.DocumentationBuild
7878
{

0 commit comments

Comments
 (0)