Skip to content

Commit 43ef2f7

Browse files
authored
ci: automate code formatting and linting with git hooks (#39)
1 parent 0f1a9bd commit 43ef2f7

19 files changed

Lines changed: 144 additions & 116 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ concurrency:
2323
cancel-in-progress: true
2424

2525
jobs:
26-
SwiftLint:
27-
runs-on: ubuntu-latest
28-
steps:
29-
- uses: actions/checkout@v5
30-
- name: GitHub Action for SwiftLint
31-
uses: norio-nomura/action-swiftlint@3.2.1
32-
with:
33-
args: --strict
34-
env:
35-
DIFF_BASE: ${{ github.base_ref }}
3626
macOS:
3727
name: ${{ matrix.name }}
3828
runs-on: ${{ matrix.runsOn }}
@@ -205,23 +195,3 @@ jobs:
205195
with:
206196
name: MergedResult
207197
path: test_output/final
208-
209-
discover-typos:
210-
name: Discover Typos
211-
runs-on: macos-15
212-
env:
213-
DEVELOPER_DIR: /Applications/Xcode_16.4.app/Contents/Developer
214-
steps:
215-
- uses: actions/checkout@v5
216-
217-
- name: Set up Python environment
218-
run: |
219-
python3 -m venv .venv
220-
source .venv/bin/activate
221-
pip install --upgrade pip
222-
pip install codespell
223-
224-
- name: Discover typos
225-
run: |
226-
source .venv/bin/activate
227-
codespell --ignore-words-list="hart,inout,msdos,sur" --skip="./.build/*,./.git/*"

.github/workflows/lint.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
paths:
9+
- "Sources/**"
10+
- ".github/workflows/ci.yml"
11+
- "Tests/**"
12+
13+
concurrency:
14+
group: lint-${{ github.head_ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
lint:
19+
name: lint
20+
runs-on: macos-15
21+
steps:
22+
- uses: actions/checkout@v5
23+
with:
24+
fetch-depth: 0
25+
- uses: jdx/mise-action@v3
26+
- name: Run
27+
run: mise run lint
28+
29+
discover-typos:
30+
name: discover-typos
31+
runs-on: macos-15
32+
env:
33+
DEVELOPER_DIR: /Applications/Xcode_16.4.app/Contents/Developer
34+
steps:
35+
- uses: actions/checkout@v5
36+
37+
- name: Set up Python environment
38+
run: |
39+
python3 -m venv .venv
40+
source .venv/bin/activate
41+
pip install --upgrade pip
42+
pip install codespell
43+
44+
- name: Discover typos
45+
run: |
46+
source .venv/bin/activate
47+
codespell --ignore-words-list="hart,inout,msdos,sur" --skip="./.build/*,./.git/*"

.swiftformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Stream rules
22

3-
--swiftversion 6.2
3+
--swiftversion 5.10
44

55
# Use 'swiftformat --options' to list all of the possible options
66

.swiftlint.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
excluded:
2-
- Tests
32
- Package.swift
43
- Package@swift-5.10.swift
54
- Package@swift-6.0.swift
@@ -12,9 +11,9 @@ disabled_rules:
1211
- trailing_comma
1312
- todo
1413
- opening_brace
14+
- statement_position
1515

1616
opt_in_rules: # some rules are only opt-in
17-
- anyobject_protocol
1817
- array_init
1918
- closure_body_length
2019
- closure_end_indentation
@@ -43,7 +42,6 @@ opt_in_rules: # some rules are only opt-in
4342
- ibinspectable_in_extension
4443
- identical_operands
4544
- implicit_return
46-
- inert_defer
4745
- joined_default_parameter
4846
- last_where
4947
- legacy_multiple

Makefile

Lines changed: 0 additions & 19 deletions
This file was deleted.

Mintfile

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ dependencies: [
259259
Bootstrapping development environment
260260

261261
```
262-
make bootstrap
262+
mise install
263263
```
264264

265265
Please feel free to help out with this project! If you see something that could be made better or want a new feature, open up an issue or send a Pull Request!

Sources/ValidatorCore/Classes/Extensions/ValidationResult+Equatable.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ extension ValidationResult: Equatable {
99
public static func == (lhs: ValidationResult, rhs: ValidationResult) -> Bool {
1010
switch (lhs, rhs) {
1111
case (.valid, .valid):
12-
return true
12+
true
1313
case let (.invalid(errors: lhs), .invalid(errors: rhs)):
14-
return lhs.map(\.message).joined() == rhs.map(\.message).joined()
14+
lhs.map(\.message).joined() == rhs.map(\.message).joined()
1515
default:
16-
return false
16+
false
1717
}
1818
}
1919
}

Sources/ValidatorCore/Classes/Rules/URLValidationRule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Validator
3-
// Copyright © 2025 Space Code. All rights reserved.
3+
// Copyright © 2023 Space Code. All rights reserved.
44
//
55

66
import Foundation

Sources/ValidatorUI/Classes/IUIValidatable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public protocol IUIValidatable: AnyObject {
2121
/// - rule: The validation rule.
2222
///
2323
/// - Returns: A validation result.
24-
func validate<T>(rule: some IValidationRule<T>) -> ValidationResult where T == Input
24+
func validate(rule: some IValidationRule<Input>) -> ValidationResult
2525

2626
/// Validates an input value.
2727
///

0 commit comments

Comments
 (0)