Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
88 changes: 88 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Pull Request

on:
pull_request:
branches: [ main ]
workflow_dispatch:

env:
SCHEME: "TranslationCatalog"

jobs:
Lint:
runs-on: macos-26
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Lint
run: swiftformat --lint . --reporter github-actions-log

Swift:
strategy:
fail-fast: false
matrix:
os: [
macos-26,
ubuntu-latest,
]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Cache
uses: actions/cache@v5
with:
path: |
.build
~/Library/Developer/Xcode/DerivedData/ModuleCache.noindex
~/Library/Caches/org.swift.swiftpm
~/Library/org.swift.swiftpm
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.swift', '**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: Package Resolution
run: swift package resolve
- name: Build
run: swift build
- name: Test
run: swift test

Xcode:
strategy:
fail-fast: false
matrix:
platform: [
"macOS",
"iOS",
"tvOS",
"watchOS",
"visionOS",
"macOS,variant=Mac Catalyst",
]
runs-on: macos-26
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Cache
uses: actions/cache@v5
with:
path: |
.build
~/Library/Developer/Xcode/DerivedData/ModuleCache.noindex
~/Library/Caches/org.swift.swiftpm
~/Library/org.swift.swiftpm
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.swift', '**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: Package Resolution
run: set -o pipefail && xcodebuild -resolvePackageDependencies | xcbeautify
- name: Build
env:
DESTINATION: "generic/platform=${{ matrix.platform }}"
shell: bash
run: |
xcodebuild \
-scheme "$SCHEME" \
-destination "$DESTINATION" \
build \
| xcbeautify
33 changes: 0 additions & 33 deletions .github/workflows/swift.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
--disable blankLinesAtStartOfScope
--disable hoistPatternLet
--disable redundantType
--disable swiftTestingTestCaseNames
--disable unusedArguments
--disable wrapArguments
--disable wrapPropertyBodies
2 changes: 1 addition & 1 deletion Sources/TranslationCatalogIO/Internal/Resource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct Resource: Codable, DynamicNodeDecoding, DynamicNodeEncoding {
.element
}
}

static func nodeEncoding(for key: any CodingKey) -> XMLEncoder.NodeEncoding {
switch key {
case CodingKeys.name, CodingKeys.formatted:
Expand Down
4 changes: 2 additions & 2 deletions Sources/TranslationCatalogIO/Internal/StringsXml.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct StringsXml: Codable, DynamicNodeDecoding, DynamicNodeEncoding {
static func nodeDecoding(for key: CodingKey) -> XMLDecoder.NodeDecoding {
.element
}

static func nodeEncoding(for key: any CodingKey) -> XMLEncoder.NodeEncoding {
.element
}
Expand All @@ -25,7 +25,7 @@ struct StringsXml: Codable, DynamicNodeDecoding, DynamicNodeEncoding {
static func make(with data: Data) throws -> StringsXml {
try XMLDecoder().decode(StringsXml.self, from: data)
}

func encoded() throws -> Data {
let encoder = XMLEncoder()
encoder.outputFormatting = [.sortedKeys]
Expand Down
3 changes: 1 addition & 2 deletions Sources/localizer/Extensions/FileManager+localizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ extension FileManager {

// Relative Path?
let directory = URL(fileURLWithPath: currentDirectoryPath, isDirectory: true)
let relativeURL = directory.appendingPathComponent(filename)
return relativeURL
return directory.appendingPathComponent(filename)
}

@available(*, deprecated)
Expand Down
8 changes: 4 additions & 4 deletions Tests/TranslationCatalogTests/ExpressionEncoderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import TranslationCatalog
import XCTest

final class ExpressionEncoderTests: XCTestCase {

private let locale: Locale = Locale(identifier: "en_US")
private let expressions: [TranslationCatalog.Expression] = [
Expression(
Expand All @@ -25,7 +25,7 @@ final class ExpressionEncoderTests: XCTestCase {
languageCode: .english
),
]

func testAndroidXMLEncoding() throws {
let data = try ExpressionEncoder.encodeValues(
for: expressions,
Expand All @@ -43,7 +43,7 @@ final class ExpressionEncoderTests: XCTestCase {
</resources>
""")
}

func testAppleStringsEncoding() throws {
let data = try ExpressionEncoder.encodeValues(
for: expressions,
Expand All @@ -58,7 +58,7 @@ final class ExpressionEncoderTests: XCTestCase {
"EXP_03" = "Hello %@, welcome to %@!";
""")
}

func testJSONEncoding() throws {
let data = try ExpressionEncoder.encodeValues(
for: expressions,
Expand Down
10 changes: 5 additions & 5 deletions Tests/TranslationCatalogTests/FilesystemEncodingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import XCTest
class FilesystemEncodingTests: XCTestCase {

func testProjectDocumentEncoding() throws {
let document = ProjectDocument(
id: UUID(uuidString: "24D67823-F859-40A1-88C2-A56F1170905B")!,
let document = try ProjectDocument(
id: XCTUnwrap(UUID(uuidString: "24D67823-F859-40A1-88C2-A56F1170905B")),
name: "Example",
expressionIds: [
UUID(uuidString: "7F9D2FF1-31C1-47A1-94EE-E23BB0A7AD2B")!,
UUID(uuidString: "592E488D-4E3C-490B-8725-C45FF7DEC872")!,
UUID(uuidString: "FB7C761C-9026-49C2-BBC7-9B7B897CAA6D")!,
XCTUnwrap(UUID(uuidString: "7F9D2FF1-31C1-47A1-94EE-E23BB0A7AD2B")),
XCTUnwrap(UUID(uuidString: "592E488D-4E3C-490B-8725-C45FF7DEC872")),
XCTUnwrap(UUID(uuidString: "FB7C761C-9026-49C2-BBC7-9B7B897CAA6D")),
]
)

Expand Down
12 changes: 6 additions & 6 deletions Tests/TranslationCatalogTests/KeyHierarchy2Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class KeyHierarchy2Tests: XCTestCase {
hierarchy = try KeyHierarchy.make(with: keys)
}

func testHierarchyGeneration() throws {
func testHierarchyGeneration() {
XCTAssertTrue(hierarchy.contents.isEmpty)
XCTAssertEqual(hierarchy.nodes.count, 1)
XCTAssertEqual(hierarchy.nodes.map(\.id), [
Expand All @@ -63,7 +63,7 @@ final class KeyHierarchy2Tests: XCTestCase {
XCTAssertTrue(hierarchy.containsPhantoms)
}

func testNodeAtPath() throws {
func testNodeAtPath() {
var node = hierarchy.node(at: [["UNKNOWN"]])
XCTAssertNil(node)
node = hierarchy.node(at: [["PAYMENT"], ["METHOD"], ["EXPIRATION"]])
Expand All @@ -72,12 +72,12 @@ final class KeyHierarchy2Tests: XCTestCase {
XCTAssertNotNil(node)
}

func testRemoveNodeAtPath() throws {
func testRemoveNodeAtPath() {
let node = hierarchy.removeNode(at: [["PAYMENT"], ["METHOD"], ["CONFIRM"]])
XCTAssertNotNil(node)
}

func testOrphanNodes() throws {
func testOrphanNodes() {
let nodes = hierarchy.orphanNodes()
XCTAssertEqual(nodes.count, 8)
XCTAssertEqual(nodes, [
Expand All @@ -92,7 +92,7 @@ final class KeyHierarchy2Tests: XCTestCase {
])
}

func testPhantomNodes() throws {
func testPhantomNodes() {
let nodes = hierarchy.phantomNodes()
XCTAssertEqual(nodes.count, 2)
XCTAssertEqual(nodes, [
Expand All @@ -101,7 +101,7 @@ final class KeyHierarchy2Tests: XCTestCase {
])
}

func testLocalizedStringConvertible() throws {
func testLocalizedStringConvertible() {
let syntax = hierarchy.syntaxTree()
XCTAssertEqual(syntax, """
import LocaleSupport
Expand Down
14 changes: 7 additions & 7 deletions Tests/TranslationCatalogTests/KeyHierarchyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class KeyHierarchyTests: XCTestCase {
hierarchy = try KeyHierarchy.make(with: keys)
}

func testHierarchyGeneration() throws {
func testHierarchyGeneration() {
XCTAssertEqual(hierarchy.contents.count, 1)
XCTAssertEqual(Array(hierarchy.contents.keys), [
["GREETING"],
Expand All @@ -65,7 +65,7 @@ final class KeyHierarchyTests: XCTestCase {
XCTAssertTrue(hierarchy.containsPhantoms)
}

func testNodeAtPath() throws {
func testNodeAtPath() {
var node = hierarchy.node(at: [["UNKNOWN"]])
XCTAssertNil(node)
node = hierarchy.node(at: [["HIDDEN"]])
Expand All @@ -74,12 +74,12 @@ final class KeyHierarchyTests: XCTestCase {
XCTAssertNotNil(node)
}

func testRemoveNodeAtPath() throws {
func testRemoveNodeAtPath() {
let node = hierarchy.removeNode(at: [["PLATFORM"], ["APPLE"]])
XCTAssertNotNil(node)
}

func testOrphanNodes() throws {
func testOrphanNodes() {
let nodes = hierarchy.orphanNodes()
XCTAssertEqual(nodes.count, 4)
XCTAssertEqual(nodes, [
Expand All @@ -90,15 +90,15 @@ final class KeyHierarchyTests: XCTestCase {
])
}

func testPhantomNodes() throws {
func testPhantomNodes() {
let nodes = hierarchy.phantomNodes()
XCTAssertEqual(nodes.count, 1)
XCTAssertEqual(nodes, [
[["ZULU"]],
])
}

func testLocalizedStringConvertible() throws {
func testLocalizedStringConvertible() {
let syntax = hierarchy.syntaxTree()
XCTAssertEqual(syntax, """
import LocaleSupport
Expand Down Expand Up @@ -214,7 +214,7 @@ final class KeyHierarchyTests: XCTestCase {
key: "ZULU_ZONE",
defaultValue: "zone"
)
var test = hierarchy!
var test = try XCTUnwrap(hierarchy)
try test.processKey(key, path: [["ZULU"], ["ZONE"]])
let syntax = try test
.compressed(mergePhantoms: false)
Expand Down
2 changes: 1 addition & 1 deletion Tests/TranslationCatalogTests/NodeSortTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ final class NodeSortTests: XCTestCase {

let comparator = NodePathSortComparator()

func testSorting() throws {
func testSorting() {
let nodes: [Node] = [
[["Account"], ["New"]],
[["Account"], ["Add"]],
Expand Down
Loading