Skip to content

Commit

Permalink
Apply standard Swift package configuration (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinder-cfuller authored Dec 15, 2023
1 parent b932637 commit fe5c9e0
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/artifactory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
tags: ['[0-9]+.[0-9]+.[0-9]+']

env:
DEVELOPER_DIR: /Applications/Xcode_14.3.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer

jobs:
artifactory:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ main ]

env:
DEVELOPER_DIR: /Applications/Xcode_14.3.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer

jobs:
bazel:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ main ]

env:
DEVELOPER_DIR: /Applications/Xcode_14.3.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer

jobs:
swift:
Expand Down Expand Up @@ -40,5 +40,5 @@ jobs:
run: xcodebuild -resolvePackageDependencies
- name: Build
run: xcodebuild build-for-testing -scheme "Layout" -destination "name=$SIMULATOR,OS=latest"
- name: Run tests
- name: Test
run: xcodebuild test-without-building -scheme "Layout" -destination "name=$SIMULATOR,OS=latest"
5 changes: 4 additions & 1 deletion .swiftlint-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ only_rules:
- anonymous_argument_in_multiline_closure
- anyobject_protocol
- array_init
- attributes
# - attributes
- balanced_xctest_lifecycle
- blanket_disable_command
- block_based_kvo
Expand Down Expand Up @@ -129,6 +129,7 @@ only_rules:
- no_grouping_extension
# - no_magic_numbers
- no_space_in_method_call
- non_overridable_class_declaration
- notification_center_detachment
- ns_number_init_as_function_reference
- nslocalizedstring_key
Expand All @@ -154,6 +155,7 @@ only_rules:
- private_outlet
- private_over_fileprivate
- private_subject
- private_swiftui_state
- private_unit_test
- prohibited_interface_builder
- prohibited_super_call
Expand Down Expand Up @@ -209,6 +211,7 @@ only_rules:
- unavailable_function
- unhandled_throwing_task
- unneeded_break_in_switch
# - unneeded_override
- unneeded_parentheses_in_closure_argument
- unneeded_synthesized_initializer
- unowned_variable_capture
Expand Down
21 changes: 15 additions & 6 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,35 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state" : {
"revision" : "a23ded2c91df9156628a6996ab4f347526f17b6b",
"version" : "2.1.2"
"revision" : "dc9af4781f2afdd1e68e90f80b8603be73ea7abc",
"version" : "2.2.0"
}
},
{
"identity" : "nimble",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Quick/Nimble.git",
"state" : {
"revision" : "f552a16f434eef1f18b62985172489f41d37a18e",
"version" : "12.2.0"
"revision" : "d616f15123bfb36db1b1075153f73cf40605b39d",
"version" : "13.0.0"
}
},
{
"identity" : "swift-snapshot-testing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing.git",
"state" : {
"revision" : "dc46eeb3928a75390651fac6c1ef7f93ad59a73b",
"version" : "1.11.1"
"revision" : "59b663f68e69f27a87b45de48cb63264b8194605",
"version" : "1.15.1"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036",
"version" : "509.0.2"
}
}
],
Expand Down
10 changes: 5 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.8
// swift-tools-version:5.9

import PackageDescription

Expand All @@ -22,10 +22,10 @@ let package = Package(
dependencies: [
.package(
url: "https://github.com/Quick/Nimble.git",
from: "12.2.0"),
from: "13.0.0"),
.package(
url: "https://github.com/pointfreeco/swift-snapshot-testing.git",
from: "1.11.0"),
from: "1.15.0"),
],
targets: [
.target(
Expand Down Expand Up @@ -59,7 +59,7 @@ let package = Package(
path: "Plugins/SwiftLintPlugin"),
.binaryTarget(
name: SwiftLint.binary,
url: "https://github.com/realm/SwiftLint/releases/download/0.52.4/SwiftLintBinary-macos.artifactbundle.zip",
checksum: "8a8095e6235a07d00f34a9e500e7568b359f6f66a249f36d12cd846017a8c6f5"),
url: "https://github.com/realm/SwiftLint/releases/download/0.54.0/SwiftLintBinary-macos.artifactbundle.zip",
checksum: "963121d6babf2bf5fd66a21ac9297e86d855cbc9d28322790646b88dceca00f1"),
]
)
9 changes: 7 additions & 2 deletions Plugins/SwiftLintPlugin/SwiftLintPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ internal struct SwiftLintPlugin: BuildToolPlugin {
target: Target
) throws -> [String: String] {

let workingDirectory: Path = try target.directory.resolveWorkingDirectory(in: context.package.directory)
let workingDirectory: Path = try target
.directory
.resolveWorkingDirectory(in: context.package.directory)

return ["BUILD_WORKSPACE_DIRECTORY": "\(workingDirectory)"]
}
Expand All @@ -81,9 +83,12 @@ internal struct SwiftLintPlugin: BuildToolPlugin {

print("Environment:", environment)

guard !swiftFiles.isEmpty
else { return [] }

let arguments: [String] = ["lint", "--quiet", "--force-exclude", "--cache-path", "\(path)"]

return swiftFiles.isEmpty ? [] : [
return [
.prebuildCommand(
displayName: "SwiftLint",
executable: executable.path,
Expand Down

0 comments on commit fe5c9e0

Please sign in to comment.