Skip to content

Commit

Permalink
Merge pull request #343 from tayloraswift/searchbot-coverage
Browse files Browse the repository at this point in the history
support Swift 6.0 on Linux
  • Loading branch information
tayloraswift authored Sep 18, 2024
2 parents c71579c + b270fea commit f07ba0b
Show file tree
Hide file tree
Showing 26 changed files with 156 additions and 141 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@ jobs:
env:
UNIDOC_ENABLE_INDEXSTORE: "0"
steps:
# Important! We install an Ubuntu 22.04 Swift toolchain, and not the 24.04 one
# because the 24.04 toolchain for some reason is built with assertions enabled,
# which causes the Swift compiler to crash when building the package.
- name: Install Swift
uses: tayloraswift/swift-install-action@master
with:
swift-prefix: "swift-5.10.1-release/ubuntu2204/swift-5.10.1-RELEASE"
swift-id: "swift-5.10.1-RELEASE-ubuntu22.04"
swift-prefix: "swift-6.0-release/ubuntu2404/swift-6.0-RELEASE"
swift-id: "swift-6.0-RELEASE-ubuntu24.04"

# This installs an older version of Unidoc, not the one we are testing.
# We use `--static-swift-stdlib` so it doesn’t matter if the Unidoc binary was
# built with a different version of Swift.
- name: Install Unidoc
uses: tayloraswift/swift-unidoc-action@master
with:
unidoc-version: "master"

- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -46,13 +43,16 @@ jobs:
name: macOS
env:
UNIDOC_ENABLE_INDEXSTORE: "0"
DEVELOPER_DIR: "/Applications/Xcode_15.3.app/Contents/Developer"

steps:
- name: Install Swift 6.0
uses: tayloraswift/swift-install-action@master
with:
swift-prefix: "swift-6.0-release/xcode/swift-6.0-RELEASE"
swift-id: "swift-6.0-RELEASE"

- name: Install Unidoc
uses: tayloraswift/swift-unidoc-action@master
with:
unidoc-version: "master"

- name: Checkout repository
uses: actions/checkout@v3
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ jobs:
macos:
runs-on: macos-14
name: macOS

env:
DEVELOPER_DIR: "/Applications/Xcode_15.3.app/Contents/Developer"

steps:
- name: Install Swift 6.0
uses: tayloraswift/swift-install-action@master
with:
swift-prefix: "swift-6.0-release/xcode/swift-6.0-RELEASE"
swift-id: "swift-6.0-RELEASE"

- name: Checkout repository
uses: actions/checkout@v3

Expand Down Expand Up @@ -47,8 +49,8 @@ jobs:
- name: Install Swift
uses: tayloraswift/swift-install-action@master
with:
swift-prefix: "swift-5.10.1-release/ubuntu2404/swift-5.10.1-RELEASE"
swift-id: "swift-5.10.1-RELEASE-ubuntu24.04"
swift-prefix: "swift-6.0-release/ubuntu2404/swift-6.0-RELEASE"
swift-id: "swift-6.0-RELEASE-ubuntu24.04"

# This clobbers everything in the current directory, which is why we installed
# the Swift toolchain in the home directory.
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ on:
jobs:
server:
runs-on: ubuntu-24.04
name: Amazon Linux 2023

strategy:
matrix:
image:
- tayloraswift/5.10.0-amazonlinux2023:latest

name: Linux
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -39,17 +33,22 @@ jobs:
--user root \
-v $PWD:/swift/swift-unidoc \
-w /swift/swift-unidoc \
${{ matrix.image }} \
swift:6.0-noble \
/bin/bash .github/pipeline
macos:
runs-on: macos-14
name: macOS
env:
UNIDOC_ENABLE_INDEXSTORE: "1"
DEVELOPER_DIR: "/Applications/Xcode_15.3.app/Contents/Developer"

steps:
- name: Install Swift 6.0
uses: tayloraswift/swift-install-action@master
with:
swift-prefix: "swift-6.0-release/xcode/swift-6.0-RELEASE"
swift-id: "swift-6.0-RELEASE"

- name: Checkout repository
uses: actions/checkout@v3

Expand Down
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "14136142efb275ae01dcfeaf5849d265cd6cab460ea3b046c55ea7ccd4d3ab76",
"originHash" : "1285241c2a78115dc45f201aef02db9d1eeda9a0221d768c13bf21ebf6524a3a",
"pins" : [
{
"identity" : "indexstore-db",
Expand Down
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ Unidoc powers the [Swiftinit](https://swiftinit.org) open source package index!

## Requirements

Unidoc’s principal deployment target is Amazon Linux 2023, but the project also builds on macOS 14 with Xcode 15.3 or newer.

Unidoc requires Swift 5.10.

> Note:
Due to a known [compiler bug](https://github.com/apple/swift/issues/71606), it is not currently possible to build Unidoc on macOS with a non-Xcode toolchain.
Unidoc supports Linux and macOS. Unidoc requires Swift 6.0.


## Features
Expand Down
6 changes: 3 additions & 3 deletions Sources/SymbolGraphBuilderTests/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ enum Main:TestMain, TestBattery
try workspace.build(package: try .remote(
project: "swift-nio-ssl",
from: "https://github.com/apple/swift-nio-ssl.git",
at: "2.24.0",
at: "2.27.2",
in: workspace),
with: toolchain)
})
Expand Down Expand Up @@ -343,7 +343,7 @@ enum Main:TestMain, TestBattery
try workspace.build(package: try .remote(
project: "swift-snapshot-testing",
from: "https://github.com/pointfreeco/swift-snapshot-testing.git",
at: "1.17.0",
at: "1.17.5",
in: workspace),
with: toolchain)
})
Expand All @@ -369,7 +369,7 @@ enum Main:TestMain, TestBattery
try workspace.build(package: try .remote(
package: "indexstore-db",
from: "https://github.com/apple/indexstore-db.git",
at: "swift-5.10-RELEASE",
at: "swift-6.0-RELEASE",
in: workspace,
flags: .init(cxx: ["-I/usr/lib/swift", "-I/usr/lib/swift/Block"])),
with: toolchain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,34 @@ import Symbols

extension SSGC
{
struct ExtensionSignatureError:Error
enum ExtensionSignatureError:Error
{
let expected:ExtensionSignature
let declared:[GenericConstraint<Symbol.Decl>]?

init(expected:ExtensionSignature,
declared:[GenericConstraint<Symbol.Decl>]? = nil)
{
self.expected = expected
self.declared = declared
}
case conformance(expected:ExtensionSignature, declared:[GenericConstraint<Symbol.Decl>])
case member (expected:ExtensionSignature, declared:[GenericConstraint<Symbol.Decl>])
}
}
extension SSGC.ExtensionSignatureError:CustomStringConvertible
{
var description:String
{
if let _:[GenericConstraint<Symbol.Decl>] = self.declared
switch self
{
case .conformance(expected: let expected, declared: let declared):
"""
Cannot declare an extension (of \(self.expected.extendee)) containing \
a symbol with different extension constraints than its extension block.
"""
}
else
{
"""
Cannot declare an extension (of \(self.expected.extendee)) containing \
Cannot declare an extension (of \(expected.extendee)) containing \
a relationship with different extension constraints than its extension \
block.
Extension block: \(expected.conditions.humanReadable)
Relationship: \(declared.humanReadable)
"""
case .member(expected: let expected, declared: let declared):
"""
Cannot declare an extension (of \(expected.extendee)) containing \
a symbol with different extension constraints than its extension block!
Extension block: \(expected.conditions.humanReadable)
Extension member: \(declared.humanReadable)
"""
}
}
Expand Down
14 changes: 14 additions & 0 deletions Sources/SymbolGraphCompiler/GenericOperator (ext).swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Signatures

extension GenericOperator
{
var token:String
{
switch self
{
case .conformer: ":"
case .subclass: ":"
case .equal: "=="
}
}
}
2 changes: 1 addition & 1 deletion Sources/SymbolGraphCompiler/SSGC.SymbolDump.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ extension SSGC.SymbolDump
}
// Trim file path prefixes.
guard
let base:Symbol.FileBase = base
let base:Symbol.FileBase = copy base
else
{
$0.location = nil
Expand Down
51 changes: 38 additions & 13 deletions Sources/SymbolGraphCompiler/SSGC.TypeChecker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ extension SSGC.TypeChecker
{
// The member’s extension constraints don’t match the extension
// object’s signature!
throw SSGC.ExtensionSignatureError.init(expected: group.signature,
throw SSGC.ExtensionSignatureError.member(
expected: group.signature,
declared: member.conditions.sorted())
}

Expand Down Expand Up @@ -379,10 +380,14 @@ extension SSGC.TypeChecker

conformer = type

guard named.conditions == conditions
// This assertion disabled due to Apple Swift bug:
// https://github.com/swiftlang/swift/issues/76559
guard named.conditions == conditions || { true }()
else
{
throw SSGC.ExtensionSignatureError.init(expected: named.signature)
throw SSGC.ExtensionSignatureError.conformance(
expected: named.signature,
declared: conformance.conditions)
}
}

Expand Down Expand Up @@ -429,19 +434,19 @@ extension SSGC.TypeChecker
(\(target)) of '\(type.value.path)' because multiple conflicting \
conformances unify to a heterogeneous set of constraints
Declared constraints: \(lists)
Simplified constraints: \(reduced)
Declared constraints: \(lists.map(\.humanReadable))
Simplified constraints: \(reduced.humanReadable)
""")
}
catch SSGC.ConstraintReductionError.redundant(let reduced, from: let lists)
{
throw AssertionError.init(message: """
Failed to simplify constraints for conditional conformance \
(\(target)) of '\(type.value.path)' because at least one of the \
constraint lists had redundancies within itself
(\(target)) of '\(type.value.path)' due to multiple conflicting conditional
conformances parsed from Swift compiler output
Declared constraints: \(lists)
Simplified constraints: \(reduced)
Declared constraints: \(lists.map(\.humanReadable))
Simplified constraints: \(reduced.humanReadable)
""")
}
}
Expand Down Expand Up @@ -470,10 +475,30 @@ extension SSGC.TypeChecker
return
}

let canonical:Set<GenericConstraint<Symbol.Decl>> = try self.computeConformance(
where: overlapping,
to: target,
of: type)
let canonical:Set<GenericConstraint<Symbol.Decl>>
do
{
canonical = try self.computeConformance(where: overlapping,
to: target,
of: type)
}
catch let error
{
switch target
{
case "ss9EscapableP": print(error)
case "ss8CopyableP": print(error)
case "s11CoreMetrics06_SwiftB16SendableProtocolP": print(error)
default: throw error
}

print("""
Note: recovering from error due to known Apple Swift bug
https://github.com/swiftlang/swift/issues/76499
""")
return
}

// Generate an implicit, internal extension for this conformance,
// if one does not already exist.
Expand Down
24 changes: 24 additions & 0 deletions Sources/SymbolGraphCompiler/Sequence (ext).swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Signatures
import Symbols

extension Sequence<GenericConstraint<Symbol.Decl>>
{
var humanReadable:String
{
var string:String = ""
for clause:GenericConstraint<Symbol.Decl> in self
{
if !string.isEmpty
{
string += ", "
}

switch clause
{
case .where(let parameter, is: let what, to: let type):
string += "\(parameter) \(what.token) \(type.spelling)"
}
}
return string
}
}
5 changes: 4 additions & 1 deletion Sources/Symbols/Identifiers/Symbol.Decl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ extension Symbol.Decl
/// mangled suffix, returning nil if the suffix contains characters
/// that are not allowed to appear in a symbol identifier.
///
/// Valid characters are `_`, `[A-Z]`, `[a-z]`, `[0-9]`, '(', ')', ':', '.', '-', and `@`.
/// Valid characters are `_`, `[A-Z]`, `[a-z]`, `[0-9]`, '(', ')', '*', ':', '.', '-', `@`,
/// `#`, and `$`.
@inlinable public
init?(_ language:Language, _ suffix:some StringProtocol)
{
Expand All @@ -55,13 +56,15 @@ extension Symbol.Decl
{
switch Unicode.Scalar.init(ascii)
{
case "#": continue
case "$": continue
case "-": continue
case ":": continue
case ".": continue
case "_": continue
case "(": continue
case ")": continue
case "*": continue
case "0" ... "9": continue
case "@": continue
case "A" ... "Z": continue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import BSON
import MongoDB
import MongoQL
import UnidocDB
import UnidocRecords
Expand All @@ -19,12 +20,9 @@ extension Unidoc
}
}
}
extension Unidoc.AliasResolutionQuery:Mongo.PipelineQuery
{
typealias Iteration = Mongo.Single<Targets.Element>
}
extension Unidoc.AliasResolutionQuery:Unidoc.AliasingQuery
{
typealias Iteration = Mongo.Single<Targets.Element>
typealias CollectionOrigin = Aliases
typealias CollectionTarget = Targets

Expand Down
Loading

0 comments on commit f07ba0b

Please sign in to comment.