From 219d80318beb6172c9d6e9125a7ed6cd6b0818eb Mon Sep 17 00:00:00 2001 From: Lukas Pistrol Date: Mon, 26 Feb 2024 11:29:00 +0100 Subject: [PATCH] add swiftlint workflow --- .github/workflows/build-documentation.yml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/lint.yml | 12 ++++++++++++ .swiftlint.yml | 16 ++++++++++++++++ Package.swift | 11 ++++++----- README.md | 1 + .../TaskTrigger/TaskTriggerViewModifier.swift | 4 ++-- .../TaskTriggerDemo/ContentView.swift | 2 +- 8 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .swiftlint.yml diff --git a/.github/workflows/build-documentation.yml b/.github/workflows/build-documentation.yml index 0728db0..83d1be7 100644 --- a/.github/workflows/build-documentation.yml +++ b/.github/workflows/build-documentation.yml @@ -9,7 +9,7 @@ on: jobs: build-documentation: - runs-on: macOS-13 + runs-on: macos-14 steps: - name: Checkout Repository uses: actions/checkout@v3 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 418d4b5..e33553e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ on: push jobs: build: - runs-on: macOS-13 + runs-on: macos-14 steps: - name: Checkout Repository uses: actions/checkout@v3 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..22867c0 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,12 @@ +name: lint +on: push + +jobs: + build: + runs-on: macos-14 + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Run SwiftLint + run: | + swiftlint --strict diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000..7f9924a --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,16 @@ +opt_in_rules: + - file_header + +excluded: + - Package.swift + - TaskTriggerDemo + +file_header: + severity: error + required_pattern: | + \/\/ + \/\/ .+\.swift + \/\/ TaskTrigger + \/\/ + \/\/ Created by .+ on \d{2}\.\d{2}\.\d{2}\. + \/\/ diff --git a/Package.swift b/Package.swift index d3cb6b7..66168f7 100644 --- a/Package.swift +++ b/Package.swift @@ -1,10 +1,11 @@ // swift-tools-version: 5.8 -// The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription +let taskTrigger = "TaskTrigger" + let package = Package( - name: "TaskTrigger", + name: taskTrigger, platforms: [ .iOS(.v15), .macOS(.v12), @@ -14,13 +15,13 @@ let package = Package( ], products: [ .library( - name: "TaskTrigger", - targets: ["TaskTrigger"] + name: taskTrigger, + targets: [taskTrigger] ), ], targets: [ .target( - name: "TaskTrigger" + name: taskTrigger ), ] ) diff --git a/README.md b/README.md index cacfa59..e132746 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Flukepistrol%2FTaskTrigger%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/lukepistrol/TaskTrigger) [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Flukepistrol%2FTaskTrigger%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/lukepistrol/TaskTrigger) +[![](https://img.shields.io/github/license/lukepistrol/TaskTrigger)](https://github.com/lukepistrol/TaskTrigger/blob/main/LICENSE) Attach async tasks to SwiftUI views using a trigger mechanism. See [this](#the-solution) for examples. diff --git a/Sources/TaskTrigger/TaskTriggerViewModifier.swift b/Sources/TaskTrigger/TaskTriggerViewModifier.swift index b90d05b..1a8a0a7 100644 --- a/Sources/TaskTrigger/TaskTriggerViewModifier.swift +++ b/Sources/TaskTrigger/TaskTriggerViewModifier.swift @@ -19,9 +19,9 @@ struct TaskTriggerViewModifier: ViewModifier where Value: Send self.action = action } - @Binding + @Binding private var trigger: TaskTrigger - + private let action: Action func body(content: Content) -> some View { diff --git a/TaskTriggerDemo/TaskTriggerDemo/ContentView.swift b/TaskTriggerDemo/TaskTriggerDemo/ContentView.swift index d8fc5c0..01fa359 100644 --- a/TaskTriggerDemo/TaskTriggerDemo/ContentView.swift +++ b/TaskTriggerDemo/TaskTriggerDemo/ContentView.swift @@ -32,7 +32,7 @@ struct ContentView: View { @State private var randomTrigger = TaskTrigger() @State private var resetTrigger = PlainTaskTrigger() - + var body: some View { VStack { Text(randomNumber, format: .number)