Skip to content

Commit

Permalink
Update generator to swift 6.0 (#782)
Browse files Browse the repository at this point in the history
* 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](actions/checkout@692973e...d632683)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
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](actions/checkout@d632683...11bd719)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
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] <[email protected]>
Co-authored-by: András B Nagy <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Shaver <[email protected]>

* 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](actions/checkout@692973e...d632683)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
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](actions/checkout@d632683...11bd719)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
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] <[email protected]>
Co-authored-by: András B Nagy <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Shaver <[email protected]>

* 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](actions/checkout@692973e...d632683)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
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](actions/checkout@d632683...11bd719)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
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] <[email protected]>
Co-authored-by: András B Nagy <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Shaver <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: András B Nagy <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Shaver <[email protected]>
  • Loading branch information
4 people authored Dec 25, 2024
1 parent 4394b31 commit 3c46168
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.3
// swift-tools-version:6.0

import PackageDescription
import Foundation
Expand Down
4 changes: 2 additions & 2 deletions generator/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion generator/Sources/Generator/generator-help.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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] ?? [:]
}
Expand Down
3 changes: 1 addition & 2 deletions generator/Sources/Generator/main.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Foundation
import Stencil
import SwiftFormat
import SwiftFormatConfiguration

enum GeneratorError: Error {
case invalidArgumentCount
Expand Down Expand Up @@ -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)
}

Expand Down
41 changes: 21 additions & 20 deletions generator/Tests/GeneratorTests/GeneratorTests.swift
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 3c46168

Please sign in to comment.