From 5c11554314b9b808d297bc96c599d00a101915cf Mon Sep 17 00:00:00 2001 From: Guillaume Algis Date: Fri, 6 Mar 2026 21:27:14 +0100 Subject: [PATCH 1/2] Add extension to String init(contentsOfFile:encoding) --- Sources/Extensions.swift | 11 +++++++++++ Tests/PathTests/PathTests.swift | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/Sources/Extensions.swift b/Sources/Extensions.swift index 27f84b8..c0e05f2 100644 --- a/Sources/Extensions.swift +++ b/Sources/Extensions.swift @@ -44,11 +44,22 @@ public extension Bundle { /// Extensions on `String` that work with `Path` rather than `String` or `URL` public extension String { /// Initializes this `String` with the contents of the provided path. + /// - SeeAlso: `init(contentsOf:encoding:)` + @available(macOS, deprecated: 15, message: "Use `init(contentsOf:encoding:)` instead") + @available(iOS, deprecated: 18, message: "Use `init(contentsOf:encoding:)` instead") + @available(tvOS, deprecated: 18, message: "Use `init(contentsOf:encoding:)` instead") + @available(watchOS, deprecated: 11, message: "Use `init(contentsOf:encoding:)` instead") @inlinable init(contentsOf path: P) throws { try self.init(contentsOfFile: path.string) } + /// Initializes this `String` with the contents of the provided path interpreted using a given encoding. + @inlinable + init(contentsOf path: P, encoding: String.Encoding) throws { + try self.init(contentsOfFile: path.string, encoding: encoding) + } + /// - Returns: `to` to allow chaining @inlinable @discardableResult diff --git a/Tests/PathTests/PathTests.swift b/Tests/PathTests/PathTests.swift index 65a5ada..5e0f7ab 100644 --- a/Tests/PathTests/PathTests.swift +++ b/Tests/PathTests/PathTests.swift @@ -496,6 +496,13 @@ class PathTests: XCTestCase { } } + func testStringEncodingExtensions() throws { + let string = try String(contentsOf: Path(#file)!, encoding: .utf8) + try Path.mktemp { tmpdir in + _ = try string.write(to: tmpdir.foo, encoding: .utf8) + } + } + func testFileHandleExtensions() throws { _ = try FileHandle(forReadingAt: Path(#file)!) _ = try FileHandle(forWritingAt: Path(#file)!) From 1b49c451edbf7d73864d29c6a7b39fa690c029a3 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Mon, 16 Mar 2026 13:16:04 -0400 Subject: [PATCH 2/2] Fix CI (#101) --- .github/workflows/ci.yml | 49 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d52aba..87b0086 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,44 +1,34 @@ name: CI on: pull_request: - schedule: - - cron: '3 3 * * 5' # 3:03 AM, every Friday concurrency: group: ${{ github.head_ref || 'push' }} cancel-in-progress: true jobs: - verify-linuxmain: - runs-on: macos-10.15 - steps: - - uses: actions/checkout@v2 - - run: swift test --generate-linuxmain - - run: git diff --exit-code - + # we want to test more macOS versions but GitHub make that difficult without + # constant maintenance because runners are deprecated and removed apple: - runs-on: ${{ matrix.os }} + runs-on: macos-latest strategy: matrix: - os: - - macos-10.15 - - macos-11 platform: - iOS - tvOS - macOS - watchOS steps: - - uses: actions/checkout@v2 - - uses: mxcl/xcodebuild@v1 + - uses: actions/checkout@v6 + - uses: mxcl/xcodebuild@latest with: platform: ${{ matrix.platform }} code-coverage: true - warnings-as-errors: true - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v5 linux: runs-on: ubuntu-latest + continue-on-error: true strategy: matrix: swift: @@ -48,26 +38,37 @@ jobs: - swift:5.2 - swift:5.3 - swift:5.4 - - swiftlang/swift:nightly-5.5 + - swift:5.5 + - swift:5.6 + - swift:5.7 + - swift:5.8 + - swift:5.9 + - swift:5.10 + # - swift:6.0 strangely fails + - swift:6.1 + - swift:6.2 container: image: ${{ matrix.swift }} steps: - - uses: mxcl/get-swift-version@v1 - id: swift + - uses: actions/checkout@v1 - - uses: actions/checkout@v2 + - name: Get Swift version + id: swift + run: | + ver=$(swift --version | head -1 | sed 's/.*Swift version \([0-9]*\).*/\1/') + echo "marketing-version=$ver" >> $GITHUB_OUTPUT - run: useradd -ms /bin/bash mxcl - run: chown -R mxcl . # ^^ we need to be a normal user and not root for the tests to be valid - run: echo ARGS=--enable-code-coverage >> $GITHUB_ENV - if: ${{ steps.swift.outputs.marketing-version > 5 }} + if: ${{ steps.swift.outputs.marketing-version > 6.1 }} - run: su mxcl -c "swift test --parallel $ARGS" - name: Generate `.lcov` - if: ${{ steps.swift.outputs.marketing-version > 5 }} + if: ${{ steps.swift.outputs.marketing-version > 6.1 }} run: | apt-get -qq update && apt-get -qq install curl b=$(swift build --show-bin-path) @@ -79,6 +80,6 @@ jobs: > info.lcov - uses: codecov/codecov-action@v1 - if: ${{ steps.swift.outputs.marketing-version > 5 }} + if: ${{ steps.swift.outputs.marketing-version > 6.1 }} with: file: ./info.lcov