Skip to content

Improve path management and filesystem operation ergonomics #318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Apr 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
7b686fd
Improve path management and filesystem operation ergonomics
cmcgee1024 Apr 13, 2025
33c4d33
Disable parallel testing to see if the tests stabilize
cmcgee1024 Apr 14, 2025
ca6df80
temporarily disable http client testing
cmcgee1024 Apr 14, 2025
472bdf1
Conditionally disable http client test on certain Linux platforms
cmcgee1024 Apr 14, 2025
f1d3572
Conditionally disable http client test on certain Linux platforms
cmcgee1024 Apr 14, 2025
61d86a7
Conditionally disable http client test on certain Linux platforms
cmcgee1024 Apr 14, 2025
d179502
Skip HTTPClient tests in workflows
cmcgee1024 Apr 14, 2025
5601a10
Avoid using production HTTP request executor unless needed in tests
cmcgee1024 Apr 14, 2025
d611c2b
Re-introduce the HTTPClientTests
cmcgee1024 Apr 14, 2025
22404a3
Skip HTTPClient tests on the two older Linux platforms
cmcgee1024 Apr 14, 2025
5e620be
Skip HTTPClient tests on the two older Linux platforms
cmcgee1024 Apr 14, 2025
ad705ae
Skip HTTPClient tests on the two older Linux platforms
cmcgee1024 Apr 14, 2025
bf792ff
Merge branch 'main' of https://github.com/swiftlang/swiftly into conv…
cmcgee1024 Apr 18, 2025
a1c8e28
Try running tests non-parallel for redhat ubi 9
cmcgee1024 Apr 18, 2025
80eecca
Avoid running tests on RHEL UBI9 with a github issue link
cmcgee1024 Apr 18, 2025
19393d6
Merge branch 'main' of https://github.com/swiftlang/swiftly into conv…
cmcgee1024 Apr 21, 2025
971b276
Introduce FileSystem type to encapsulate simple fs functions
cmcgee1024 Apr 21, 2025
f361722
Format code and work around Ubuntu 20.04 test crash
cmcgee1024 Apr 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ jobs:
- name: Prepare the action
run: ./scripts/prep-gh-action.sh --install-swiftly
- name: Build and Test
run: swift test
# UBI 9 and Ubuntu 20.04 - See https://github.com/swiftlang/swift/issues/80908
# UBI 9 - See https://github.com/swiftlang/swift/issues/80909
run: bash -c 'if [[ "${{ matrix.container }}" == "redhat/ubi9" ]]; then swift build --build-tests; elif [[ "${{ matrix.container }}" == "ubuntu:20.04" ]]; then swift build --build-tests; else swift test; fi'

releasebuildcheck:
name: Release Build Check
Expand Down
10 changes: 9 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ let package = Package(
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0"),
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/apple/swift-system", from: "1.4.2"),
// This dependency provides the correct version of the formatter so that you can run `swift run swiftformat Package.swift Plugins/ Sources/ Tests/`
.package(url: "https://github.com/nicklockwood/SwiftFormat", exact: "0.49.18"),
],
Expand All @@ -42,6 +43,7 @@ let package = Package(
.target(name: "LinuxPlatform", condition: .when(platforms: [.linux])),
.target(name: "MacOSPlatform", condition: .when(platforms: [.macOS])),
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
.product(name: "SystemPackage", package: "swift-system"),
],
swiftSettings: swiftSettings
),
Expand All @@ -64,6 +66,7 @@ let package = Package(
.product(name: "NIOFoundationCompat", package: "swift-nio"),
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
.product(name: "OpenAPIAsyncHTTPClient", package: "swift-openapi-async-http-client"),
.product(name: "SystemPackage", package: "swift-system"),
],
swiftSettings: swiftSettings
),
Expand Down Expand Up @@ -123,6 +126,7 @@ let package = Package(
dependencies: [
"SwiftlyCore",
"CLibArchive",
.product(name: "SystemPackage", package: "swift-system"),
],
swiftSettings: swiftSettings,
linkerSettings: [
Expand All @@ -133,6 +137,7 @@ let package = Package(
name: "MacOSPlatform",
dependencies: [
"SwiftlyCore",
.product(name: "SystemPackage", package: "swift-system"),
],
swiftSettings: swiftSettings
),
Expand All @@ -145,7 +150,10 @@ let package = Package(
),
.testTarget(
name: "SwiftlyTests",
dependencies: ["Swiftly"],
dependencies: [
"Swiftly",
.product(name: "SystemPackage", package: "swift-system"),
],
resources: [
.embedInCode("mock-signing-key-private.pgp"),
],
Expand Down
9 changes: 5 additions & 4 deletions Sources/LinuxPlatform/Extract.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import CLibArchive
import Foundation
import SystemPackage

// The code in this file consists mainly of a Swift port of the "Complete Extractor" example included in the libarchive
// documentation: https://github.com/libarchive/libarchive/wiki/Examples#a-complete-extractor
Expand Down Expand Up @@ -44,7 +45,7 @@ func copyData(readArchive: OpaquePointer?, writeArchive: OpaquePointer?) throws
/// the provided closure which will return the path the file will be written to.
///
/// This uses libarchive under the hood, so a wide variety of archive formats are supported (e.g. .tar.gz).
func extractArchive(atPath archivePath: URL, transform: (String) -> URL) throws {
func extractArchive(atPath archivePath: FilePath, transform: (String) -> FilePath) throws {
var flags = Int32(0)
flags = ARCHIVE_EXTRACT_TIME
flags |= ARCHIVE_EXTRACT_PERM
Expand All @@ -66,8 +67,8 @@ func extractArchive(atPath archivePath: URL, transform: (String) -> URL) throws
archive_write_free(ext)
}

if archive_read_open_filename(a, archivePath.path, 10240) != 0 {
throw ExtractError(message: "Failed to open \"\(archivePath.path)\"")
if archive_read_open_filename(a, archivePath.string, 10240) != 0 {
throw ExtractError(message: "Failed to open \"\(archivePath)\"")
}

while true {
Expand All @@ -82,7 +83,7 @@ func extractArchive(atPath archivePath: URL, transform: (String) -> URL) throws
}

let currentPath = String(cString: archive_entry_pathname(entry))
archive_entry_set_pathname(entry, transform(currentPath).path)
archive_entry_set_pathname(entry, transform(currentPath).string)
r = archive_write_header(ext, entry)
guard r == ARCHIVE_OK else {
throw ExtractError(archive: ext)
Expand Down
Loading