Skip to content

Commit

Permalink
fix compilation after validation result decoupling, add unit testing …
Browse files Browse the repository at this point in the history
…ci flow
  • Loading branch information
nicorichard committed Jul 9, 2024
1 parent 19a4798 commit 23f0fc1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Unit Test
on:
push:

jobs:
test:
name: Unit Test
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: unit test package
run: swift test
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ struct CommandLineReporter: Reporter {
func report(results: [Validator.Validation]) throws {
for result in results {
let message = "xcstringslint failed for key `\(result.key)`: " + result.validations.map { validation in
"\(validation.message) (\(type(of: validation.rule).name))"
"\(validation.message) (\(validation.name))"
}.joined(separator: ",")

if result.validations.map(\.rule.severity).contains(.error) {
if result.validations.map(\.severity).contains(.error) {
print(message)
} else {
print(message)
Expand All @@ -30,7 +30,7 @@ struct CommandLineReporter: Reporter {
result.validations
}

let errors = validations.filter { $0.rule.severity == .error }
let errors = validations.filter { $0.severity == .error }

if !errors.isEmpty {
print("Found \(results.count) total xcstringlint issues in \(results.count) keys, \(errors.count) serious")
Expand Down
6 changes: 3 additions & 3 deletions Sources/XCStringsLint/services/Reporter/XcodeReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ struct XcodeReporter: Reporter {
func report(results: [Validator.Validation]) throws {
for result in results {
let message = "xcstringslint failed for key `\(result.key)`: " + result.validations.map { validation in
"\(validation.message) (\(type(of: validation.rule).name))"
"\(validation.message) (\(validation.name))"
}.joined(separator: ",")

if result.validations.map(\.rule.severity).contains(.error) {
if result.validations.map(\.severity).contains(.error) {
print(level: .error, message)
} else {
print(level: .warning, message)
Expand All @@ -32,7 +32,7 @@ struct XcodeReporter: Reporter {
result.validations
}

let errors = validations.filter { $0.rule.severity == .error }
let errors = validations.filter { $0.severity == .error }

if !errors.isEmpty {
print(level: .error, "Found \(validations.count) total xcstringlint issues in \(results.count) keys, \(errors.count) serious")
Expand Down

0 comments on commit 23f0fc1

Please sign in to comment.