Skip to content

Commit cec4ae2

Browse files
ajkoleanfortmarek
andauthored
fix: update URLs APIs to work with linux (#103)
* fix: Update URLs APIs to work with linux * [gh actions] restore linux jobs * Fix Linux build * Fix obtaining path on Linux --------- Co-authored-by: fortmarek <marekfort@me.com>
1 parent b2c6c9a commit cec4ae2

File tree

7 files changed

+100
-58
lines changed

7 files changed

+100
-58
lines changed

.github/workflows/file-system.yml

Lines changed: 61 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: FileSystem
33
on:
44
push:
55
branches:
6-
- main
6+
- main
77
pull_request: {}
88

99
env:
@@ -18,63 +18,85 @@ jobs:
1818
name: "Release build on macOS 14"
1919
runs-on: macos-14
2020
steps:
21-
- uses: actions/checkout@v4
22-
- uses: jdx/mise-action@v2
23-
with:
24-
experimental: true
25-
- name: Run
26-
run: mise run build-spm
21+
- uses: actions/checkout@v4
22+
- uses: jdx/mise-action@v2
23+
with:
24+
experimental: true
25+
- name: Run
26+
run: mise run build-spm
27+
28+
build-linux:
29+
name: "Release build on Linux"
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: jdx/mise-action@v2
34+
with:
35+
experimental: true
36+
- name: Run
37+
run: mise run build-linux
2738

2839
build_tuist:
2940
name: "Tuist build"
3041
runs-on: "macos-14"
3142
steps:
32-
- uses: actions/checkout@v4
33-
- name: Select Xcode
34-
run: sudo xcode-select -switch /Applications/Xcode_$(cat .xcode-version).app
35-
- uses: jdx/mise-action@v2
36-
with:
37-
experimental: true
38-
- name: Run
39-
run: |
40-
mise x -- tuist install
41-
mise run build
43+
- uses: actions/checkout@v4
44+
- name: Select Xcode
45+
run: sudo xcode-select -switch /Applications/Xcode_$(cat .xcode-version).app
46+
- uses: jdx/mise-action@v2
47+
with:
48+
experimental: true
49+
- name: Run
50+
run: |
51+
mise x -- tuist install
52+
mise run build
4253
4354
test:
4455
name: "Test on macOS 14"
4556
runs-on: macos-14
4657
steps:
47-
- uses: actions/checkout@v4
48-
- uses: jdx/mise-action@v2
49-
with:
50-
experimental: true
51-
- name: Run
52-
run: mise run test-spm
58+
- uses: actions/checkout@v4
59+
- uses: jdx/mise-action@v2
60+
with:
61+
experimental: true
62+
- name: Run
63+
run: mise run test-spm
64+
65+
test_linux:
66+
name: "Test on Linux"
67+
runs-on: ubuntu-latest
68+
steps:
69+
- uses: actions/checkout@v4
70+
- uses: jdx/mise-action@v2
71+
with:
72+
experimental: true
73+
- name: Run
74+
run: mise run test-linux
5375

5476
test_tuist:
5577
name: "Tuist test"
5678
runs-on: "macos-14"
5779
env:
5880
TUIST_CONFIG_CLOUD_TOKEN: ${{ secrets.TUIST_CONFIG_CLOUD_TOKEN }}
5981
steps:
60-
- uses: actions/checkout@v4
61-
- name: Select Xcode
62-
run: sudo xcode-select -switch /Applications/Xcode_$(cat .xcode-version).app
63-
- uses: jdx/mise-action@v2
64-
with:
65-
experimental: true
66-
- name: Run
67-
run: |
68-
mise x -- tuist install
69-
mise run test
82+
- uses: actions/checkout@v4
83+
- name: Select Xcode
84+
run: sudo xcode-select -switch /Applications/Xcode_$(cat .xcode-version).app
85+
- uses: jdx/mise-action@v2
86+
with:
87+
experimental: true
88+
- name: Run
89+
run: |
90+
mise x -- tuist install
91+
mise run test
7092
7193
lint:
7294
name: Lint
7395
runs-on: macos-14
7496
steps:
75-
- uses: actions/checkout@v4
76-
- uses: jdx/mise-action@v2
77-
with:
78-
experimental: true
79-
- name: Run
80-
run: mise run lint
97+
- uses: actions/checkout@v4
98+
- uses: jdx/mise-action@v2
99+
with:
100+
experimental: true
101+
- name: Run
102+
run: mise run lint

.mise/tasks/build-linux

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ fi
1212
$CONTAINER_RUNTIME run --rm \
1313
--volume "$MISE_PROJECT_ROOT:/package" \
1414
--workdir "/package" \
15-
swift:5.9.2 \
15+
swift:6.0.3 \
1616
/bin/bash -c \
17-
"swift build --configuration release --build-path ./.build/linux"
17+
"swift build --configuration release --build-path ./.build/linux"

.mise/tasks/test-linux

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ fi
1212
$CONTAINER_RUNTIME run --rm \
1313
--volume "$MISE_PROJECT_ROOT:/package" \
1414
--workdir "/package" \
15-
swift:5.9.2 \
15+
swift:6.0.3 \
1616
/bin/bash -c \
17-
"swift test"
17+
"swift test"

Package.resolved

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
"kind" : "remoteSourceControl",
4242
"location" : "https://github.com/apple/swift-nio",
4343
"state" : {
44-
"revision" : "dca6594f65308c761a9c409e09fbf35f48d50d34",
45-
"version" : "2.77.0"
44+
"revision" : "ba72f31e11275fc5bf060c966cf6c1f36842a291",
45+
"version" : "2.79.0"
4646
}
4747
},
4848
{
@@ -59,8 +59,8 @@
5959
"kind" : "remoteSourceControl",
6060
"location" : "https://github.com/weichsel/ZIPFoundation",
6161
"state" : {
62-
"revision" : "02b6abe5f6eef7e3cbd5f247c5cc24e246efcfe0",
63-
"version" : "0.9.19"
62+
"branch" : "development",
63+
"revision" : "e9b1917bd4d7d050e0ff4ec157b5d6e253c84385"
6464
}
6565
}
6666
],

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let package = Package(
1515
name: "FileSystem",
1616
platforms: [
1717
.macOS("13.0"),
18-
.iOS("13.0"),
18+
.iOS("16.0"),
1919
],
2020
products: [
2121
.library(
@@ -28,7 +28,7 @@ let package = Package(
2828
.package(url: "https://github.com/tuist/Path", .upToNextMajor(from: "0.3.8")),
2929
.package(url: "https://github.com/apple/swift-nio", .upToNextMajor(from: "2.79.0")),
3030
.package(url: "https://github.com/apple/swift-log", .upToNextMajor(from: "1.6.2")),
31-
.package(url: "https://github.com/weichsel/ZIPFoundation", .upToNextMajor(from: "0.9.19")),
31+
.package(url: "https://github.com/weichsel/ZIPFoundation", branch: "development"),
3232
],
3333
targets: [
3434
.target(

Sources/FileSystem/FileSystem.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,9 @@ public struct FileSystem: FileSysteming, Sendable {
314314

315315
/// The path to the directory /var is a symlink to /var/private.
316316
/// NSTemporaryDirectory() returns the path to the symlink, so the logic here removes the symlink from it.
317-
if systemTemporaryDirectory.starts(with: "/var/") {
318-
systemTemporaryDirectory = "/private\(systemTemporaryDirectory)"
319-
}
317+
// if systemTemporaryDirectory.starts(with: "/var/") {
318+
// systemTemporaryDirectory = "/private\(systemTemporaryDirectory)"
319+
// }
320320
let temporaryDirectory = try AbsolutePath(validating: systemTemporaryDirectory)
321321
.appending(component: "\(prefix)-\(UUID().uuidString)")
322322
logger?.debug("Creating a temporary directory at path \(temporaryDirectory.pathString).")

Sources/Glob/GlobSearch.swift

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ public func search(
4646
case let .constant(constant):
4747
if constant.hasSuffix("/") {
4848
(
49-
baseURL.appending(path: constant.dropLast()),
49+
baseURL.appendingPath(constant.dropLast()),
5050
Pattern(sections: Array(include.sections.dropFirst()), options: include.options)
5151
)
5252
} else if include.sections.count == 1 {
5353
(
54-
baseURL.appending(path: constant),
54+
baseURL.appendingPath(constant),
5555
Pattern(sections: Array(include.sections.dropFirst()), options: include.options)
5656
)
5757
} else if case .componentWildcard = include.sections[1] {
5858
(
59-
baseURL.appending(path: constant.components(separatedBy: "/").dropLast().joined(separator: "/")),
59+
baseURL.appendingPath(constant.components(separatedBy: "/").dropLast().joined(separator: "/")),
6060
Pattern(
6161
sections: [.constant(constant.components(separatedBy: "/").last ?? "")] +
6262
Array(include.sections.dropFirst()),
@@ -65,7 +65,7 @@ public func search(
6565
)
6666
} else {
6767
(
68-
baseURL.appending(path: constant),
68+
baseURL.appendingPath(constant),
6969
Pattern(sections: Array(include.sections.dropFirst()), options: include.options)
7070
)
7171
}
@@ -83,7 +83,7 @@ public func search(
8383
}
8484

8585
let path = baseURL.absoluteString.removingPercentEncoding ?? baseURL.absoluteString
86-
let symbolicLinkDestination = URL(filePath: path).resolvingSymlinksInPath()
86+
let symbolicLinkDestination = URL.with(filePath: path).resolvingSymlinksInPath()
8787
var isDirectory: ObjCBool = false
8888

8989
let symbolicLinkDestinationPath: String = symbolicLinkDestination
@@ -182,7 +182,7 @@ private func search(
182182

183183
let matchResult = try matching(url, relativePath)
184184

185-
let foundPath = directory.appending(path: url.relativePath)
185+
let foundPath = directory.appendingPath(url.lastPathComponent)
186186

187187
if matchResult.matches {
188188
continuation.yield(foundPath)
@@ -222,3 +222,23 @@ private func search(
222222
try await group.waitForAll()
223223
}
224224
}
225+
226+
extension URL {
227+
public static func with(filePath: String) -> URL {
228+
#if os(Linux)
229+
return URL(fileURLWithPath: filePath)
230+
#else
231+
return URL(filePath: filePath)
232+
#endif
233+
}
234+
235+
public func appendingPath(_ path: any StringProtocol) -> URL {
236+
#if os(Linux)
237+
return path
238+
.split(separator: "/")
239+
.reduce(self) { $0.appendingPathComponent(String($1)) }
240+
#else
241+
return appending(path: path)
242+
#endif
243+
}
244+
}

0 commit comments

Comments
 (0)