From 3c461689f67db24f5fee3e6d911a0bd969999775 Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Wed, 25 Dec 2024 23:30:27 +0100 Subject: [PATCH] Update generator to swift 6.0 (#782) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update generator to swift 6.0 * Use beta versio * Update to use swift 6 formatter * Remove macos version mention * Set minimum macOS version to 12 in Package.swift * Sync branch (#809) * Sync docs and metadata (#771) * Bump actions/checkout from 4.1.7 to 4.2.0 (#772) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/692973e3d937129bcbf40652eb9f2f61becf3332...d632683dd7b4114ad314bca15554477dd762a938) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix avogadro constant (#777) * Update about.md (#778) * Update about.md Fix word-choice error. * Also make fixes in concept:numbers:introduction.md and exercises:freelancer-rates:introduction.md * Fix `NESButtons` typo (#779) * Fix `NESButtons` typo Just a little typo in the enum name. * fix other mentions of `NESButtons` * Bump actions/checkout from 4.2.0 to 4.2.2 (#775) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.0 to 4.2.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/d632683dd7b4114ad314bca15554477dd762a938...11bd71901bbe5b1630ceea73d27597364c9af683) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * [New Exercise]: Armstrong Numbers (#708) * Add Armstrong Numbers exercise * Add author * [Armstrong number]: Fix formatting (#783) * Fix formatting * Fix * [New Exercise]: Darts (#707) * Add Darts exercise * Add author * Fix * Sync exercise to problem spec * Update CI configuration and add Swift Numerics dependency (#806) * Update CI configuration and add Swift Numerics dependency * Check if swift6 is available in macos 15 --------- Signed-off-by: dependabot[bot] Co-authored-by: András B Nagy <20251272+BNAndras@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mike Shaver * Remove uneeded import * Sync (#813) * Sync docs and metadata (#771) * Bump actions/checkout from 4.1.7 to 4.2.0 (#772) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/692973e3d937129bcbf40652eb9f2f61becf3332...d632683dd7b4114ad314bca15554477dd762a938) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix avogadro constant (#777) * Update about.md (#778) * Update about.md Fix word-choice error. * Also make fixes in concept:numbers:introduction.md and exercises:freelancer-rates:introduction.md * Fix `NESButtons` typo (#779) * Fix `NESButtons` typo Just a little typo in the enum name. * fix other mentions of `NESButtons` * Bump actions/checkout from 4.2.0 to 4.2.2 (#775) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.0 to 4.2.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/d632683dd7b4114ad314bca15554477dd762a938...11bd71901bbe5b1630ceea73d27597364c9af683) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * [New Exercise]: Armstrong Numbers (#708) * Add Armstrong Numbers exercise * Add author * [Armstrong number]: Fix formatting (#783) * Fix formatting * Fix * [New Exercise]: Darts (#707) * Add Darts exercise * Add author * Fix * Sync exercise to problem spec * Update CI configuration and add Swift Numerics dependency (#806) * Update CI configuration and add Swift Numerics dependency * Check if swift6 is available in macos 15 * Remove obsolete LinuxMain.swift and XCTestManifests.swift files from various exercises (#812) --------- Signed-off-by: dependabot[bot] Co-authored-by: András B Nagy <20251272+BNAndras@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mike Shaver * Sync (#815) * Sync docs and metadata (#771) * Bump actions/checkout from 4.1.7 to 4.2.0 (#772) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/692973e3d937129bcbf40652eb9f2f61becf3332...d632683dd7b4114ad314bca15554477dd762a938) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix avogadro constant (#777) * Update about.md (#778) * Update about.md Fix word-choice error. * Also make fixes in concept:numbers:introduction.md and exercises:freelancer-rates:introduction.md * Fix `NESButtons` typo (#779) * Fix `NESButtons` typo Just a little typo in the enum name. * fix other mentions of `NESButtons` * Bump actions/checkout from 4.2.0 to 4.2.2 (#775) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.0 to 4.2.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/d632683dd7b4114ad314bca15554477dd762a938...11bd71901bbe5b1630ceea73d27597364c9af683) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * [New Exercise]: Armstrong Numbers (#708) * Add Armstrong Numbers exercise * Add author * [Armstrong number]: Fix formatting (#783) * Fix formatting * Fix * [New Exercise]: Darts (#707) * Add Darts exercise * Add author * Fix * Sync exercise to problem spec * Update CI configuration and add Swift Numerics dependency (#806) * Update CI configuration and add Swift Numerics dependency * Check if swift6 is available in macos 15 * Remove obsolete LinuxMain.swift and XCTestManifests.swift files from various exercises (#812) * Remove redundant test cases from MagicianInTrainingTests (#814) --------- Signed-off-by: dependabot[bot] Co-authored-by: András B Nagy <20251272+BNAndras@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mike Shaver --------- Signed-off-by: dependabot[bot] Co-authored-by: András B Nagy <20251272+BNAndras@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mike Shaver --- .github/workflows/ci.yml | 4 +- Package.swift | 2 +- generator/Package.swift | 4 +- .../Sources/Generator/generator-help.swift | 2 +- generator/Sources/Generator/main.swift | 3 +- .../Tests/GeneratorTests/GeneratorTests.swift | 41 ++++++++++--------- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 865e0abae..eb0214761 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: - name: Run tests run: swift test generator-tests: - runs-on: macos-13 + runs-on: macos-15 env: RUNALL: "true" steps: @@ -28,7 +28,7 @@ jobs: - name: Run tests run: swift test --package-path ./generator generator-template-tests: - runs-on: macos-13 + runs-on: macos-15 steps: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 diff --git a/Package.swift b/Package.swift index 4002074ad..c566f2b74 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.3 +// swift-tools-version:6.0 import PackageDescription import Foundation diff --git a/generator/Package.swift b/generator/Package.swift index 318d64f6c..63701123f 100644 --- a/generator/Package.swift +++ b/generator/Package.swift @@ -6,12 +6,12 @@ import PackageDescription let package = Package( name: "Generator", platforms: [ - .macOS(.v10_15) // Set the minimum macOS version to 10.15 or any version greater than 10.15. + .macOS(.v12) // Set the minimum macOS version to 10.15 or any version greater than 10.15. ], dependencies: [ .package(url: "https://github.com/stencilproject/Stencil.git", from: "0.15.1"), .package(url: "https://github.com/LebJe/TOMLKit.git", from: "0.5.5"), - .package(url: "https://github.com/apple/swift-format", from: "508.0.1"), + .package(url: "https://github.com/apple/swift-format", from: "600.0.0"), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. diff --git a/generator/Sources/Generator/generator-help.swift b/generator/Sources/Generator/generator-help.swift index 76c19e46b..0c3aa21d8 100644 --- a/generator/Sources/Generator/generator-help.swift +++ b/generator/Sources/Generator/generator-help.swift @@ -25,7 +25,7 @@ class GeneratorHelp { } catch { throw GeneratorError.remoteError("No remote file found") } - let data = try String(contentsOf: url) ?? "" + let data = try String(contentsOf: url, encoding: .utf8) let fileData = Data(data.utf8) json = try JSONSerialization.jsonObject(with: fileData, options: []) as? [String: Any] ?? [:] } diff --git a/generator/Sources/Generator/main.swift b/generator/Sources/Generator/main.swift index b5db548dc..3134ba795 100644 --- a/generator/Sources/Generator/main.swift +++ b/generator/Sources/Generator/main.swift @@ -1,7 +1,6 @@ import Foundation import Stencil import SwiftFormat -import SwiftFormatConfiguration enum GeneratorError: Error { case invalidArgumentCount @@ -42,7 +41,7 @@ class Generator { var text = "" let configuration = Configuration() let swiftFormat = SwiftFormatter(configuration: configuration) - try swiftFormat.format(source: template, assumingFileURL: nil, to: &text) + try swiftFormat.format(source: template, assumingFileURL: nil, selection: .infinite, to: &text) try text.write(toFile: path, atomically: true, encoding: .utf8) } diff --git a/generator/Tests/GeneratorTests/GeneratorTests.swift b/generator/Tests/GeneratorTests/GeneratorTests.swift index 6909c9a16..26da747c0 100644 --- a/generator/Tests/GeneratorTests/GeneratorTests.swift +++ b/generator/Tests/GeneratorTests/GeneratorTests.swift @@ -1,25 +1,26 @@ -import XCTest +import Testing @testable import Generator -class GeneratorTests: XCTestCase { - func testAllTestsIncluded() { - let generatorHelp = GeneratorHelp(exercise: "two-fer", filePath: "./Tests/GeneratorTests/files/all-tests-included") - XCTAssertNoThrow(try generatorHelp.toml()) - let expected = ["1cf3e15a-a3d7-4a87-aeb3-ba1b43bc8dce", "3549048d-1a6e-4653-9a79-b0bda163e8d5", "b4c6dbb8-b4fb-42c2-bafd-10785abe7709"] - XCTAssertEqual(generatorHelp.uuids, expected) - } +@Test("Testing having all tests be included") +func testAllTestsIncluded() { + let generatorHelp = GeneratorHelp(exercise: "two-fer", filePath: "./Tests/GeneratorTests/files/all-tests-included") + #expect(throws: Never.self) {try generatorHelp.toml()} + let expected = ["1cf3e15a-a3d7-4a87-aeb3-ba1b43bc8dce", "3549048d-1a6e-4653-9a79-b0bda163e8d5", "b4c6dbb8-b4fb-42c2-bafd-10785abe7709"] + #expect(generatorHelp.uuids == expected) +} - func testAllTestsRemoved() { - let generatorHelp = GeneratorHelp(exercise: "two-fer", filePath: "./Tests/GeneratorTests/files/all-test-removed") - XCTAssertNoThrow(try generatorHelp.toml()) - let expected: [String] = [] - XCTAssertEqual(generatorHelp.uuids, expected) - } +@Test("Testing having all tests be removed") +func testAllTestsRemoved() { + let generatorHelp = GeneratorHelp(exercise: "two-fer", filePath: "./Tests/GeneratorTests/files/all-test-removed") + #expect(throws: Never.self) {try generatorHelp.toml()} + let expected: [String] = [] + #expect(generatorHelp.uuids == expected) +} - func testTwoTestsRemoved() { - let generatorHelp = GeneratorHelp(exercise: "two-fer", filePath: "./Tests/GeneratorTests/files/two-tests-removed") - XCTAssertNoThrow(try generatorHelp.toml()) - let expected = ["b4c6dbb8-b4fb-42c2-bafd-10785abe7709"] - XCTAssertEqual(generatorHelp.uuids, expected) - } +@Test("Testing having two tests be removed") +func testTwoTestsRemoved() { + let generatorHelp = GeneratorHelp(exercise: "two-fer", filePath: "./Tests/GeneratorTests/files/two-tests-removed") + #expect(throws: Never.self) {try generatorHelp.toml()} + let expected = ["b4c6dbb8-b4fb-42c2-bafd-10785abe7709"] + #expect(generatorHelp.uuids == expected) }