Skip to content

Commit

Permalink
Apply standard Swift package configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
tinder-cfuller committed Jan 27, 2025
1 parent 3651882 commit 8576b1c
Show file tree
Hide file tree
Showing 18 changed files with 159 additions and 566 deletions.
1 change: 0 additions & 1 deletion .bazelversion

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/bazel.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/docc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: DocC

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer

jobs:
docc:
name: DocC
runs-on: macos-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Build
run: make docs open="no" DERIVED_DATA_PATH="$(mktemp -d)"
38 changes: 7 additions & 31 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,22 @@ on:
branches: [ main ]

env:
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer
SWIFT_STRICT_CONCURRENCY: complete
DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer

jobs:
swift:
name: Swift
runs-on: macos-13
runs-on: macos-latest
env:
SIMULATOR: iPhone 14
SIMULATOR: iPhone 15
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Validate excluded snapshots
run: |
SNAPSHOTS=$(find Tests -type d -name "__Snapshots__" | sort)
EXCLUDED=$(swift package dump-package | jq -r '.targets[] | select(.type == "test") | "Tests/" + .name + "/" + .exclude[]' | sort)
UNEXCLUDED=$(comm -23 <(echo "$SNAPSHOTS") <(echo "$EXCLUDED"))
if test -n "$UNEXCLUDED"
then
echo "::error::Snapshot directories must be excluded from Swift package:" >&2
echo "$UNEXCLUDED" >&2
exit 1
fi
uses: actions/checkout@v4
- name: Download swiftlint binary
run: swift package resolve
- name: Lint
run: |
DIRECTORY_NAME=$(echo "${PWD##*/}" | tr '[:upper:]' '[:lower:]')
"$(find ".build/artifacts/${DIRECTORY_NAME}" -type f -name swiftlint -perm +111 -print -quit)" \
run: >
"$(find ".build/artifacts/swiftlint" -type f -name swiftlint -perm +111 -print -quit)"
lint --strict --reporter github-actions-logging
- name: Resolve package dependencies
run: xcodebuild -resolvePackageDependencies
Expand All @@ -45,21 +32,10 @@ jobs:
build-for-testing
-scheme "Layout-Package"
-destination "name=$SIMULATOR,OS=latest"
SWIFT_TREAT_WARNINGS_AS_ERRORS=YES
-skipPackagePluginValidation
- name: Test
run: >
xcodebuild
test-without-building
-scheme "Layout-Package"
-destination "name=$SIMULATOR,OS=latest"
- name: Delete snapshots
run: make delete-snapshots
- name: Record snapshots
run: >
xcodebuild
test-without-building
-scheme "Layout-Package"
-destination "name=$SIMULATOR,OS=latest"
continue-on-error: true
- name: Validate recorded snapshots
run: test -z "$(git status --porcelain)"
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@
# Xcode
*.xcworkspace/
*.xcodeproj/

# Bazel
bazel-*
9 changes: 9 additions & 0 deletions .swiftlint-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ only_rules:
- contains_over_filter_is_empty
- contains_over_first_not_nil
- contains_over_range_nil_comparison
# - contrasted_opening_brace
- control_statement
- convenience_type
- custom_rules
Expand Down Expand Up @@ -73,6 +74,7 @@ only_rules:
- file_name
- file_name_no_space
- file_types_order
- final_test_case
- first_where
- flatmap_over_map_reduce
- for_where
Expand Down Expand Up @@ -124,11 +126,13 @@ only_rules:
- multiple_closures_with_trailing_closure
- nesting
- nimble_operator
# - no_empty_block
- no_extension_access_modifier
- no_fallthrough_only
- no_grouping_extension
# - no_magic_numbers
- no_space_in_method_call
- non_optional_string_data_conversion
- non_overridable_class_declaration
- notification_center_detachment
- ns_number_init_as_function_reference
Expand All @@ -137,6 +141,7 @@ only_rules:
- nsobject_prefer_isequal
- number_separator
# - object_literal
# - one_declaration_per_file
- opening_brace
- operator_usage_whitespace
- operator_whitespace
Expand All @@ -146,6 +151,7 @@ only_rules:
- override_in_extension
- pattern_matching_keywords
- period_spacing
- prefer_key_path
- prefer_nimble
- prefer_self_in_static_references
- prefer_self_type_over_type_of_self
Expand Down Expand Up @@ -181,6 +187,7 @@ only_rules:
# - return_value_from_void_function
- self_binding
- self_in_property_initialization
# - shorthand_argument
- shorthand_operator
- shorthand_optional_binding
- single_test_class
Expand All @@ -189,6 +196,7 @@ only_rules:
- sorted_imports
- statement_position
- static_operator
- static_over_final_class
- strict_fileprivate
- strong_iboutlet
- superfluous_disable_command
Expand Down Expand Up @@ -221,6 +229,7 @@ only_rules:
- unused_control_flow_label
- unused_enumerated
- unused_optional_binding
- unused_parameter
- unused_setter_value
- valid_ibinspectable
- vertical_parameter_alignment
Expand Down
1 change: 0 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
included:
- Plugins
- Sources
- Tests

Expand Down
16 changes: 0 additions & 16 deletions BUILD.bazel

This file was deleted.

23 changes: 19 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Contributing to Layout

- [Open Package in Xcode](#open-package-in-xcode)
- [Static Analysis](#static-analysis)
- [Open Package](#open-package)
- [Lint Package](#lint-package)
- [Testing](#testing)
- [Creating Releases](#creating-releases)

## Open Package in Xcode
## Open Package

> The file header comment template will also be installed.
```
make open
```

## Static Analysis
## Lint Package

> SwiftLint violations are visible in Xcode as well.
Expand All @@ -35,3 +36,17 @@ To re-record all existing snapshot references, delete all using the following co
```
make delete-snapshots
```

## Creating Releases

Releases are made [on the GitHub website](https://github.com/Tinder/Layout/releases/new).

In all of the following steps, `X.X.X` is a placeholder to be substituted with the actual semantic version for the release.

- Enter a semantic version as the new tag (__WITHOUT__ `v` prefix)
- Set the `main` branch as the target (it should be the default)
- Enter the release title formatted as `Layout vX.X.X` (__WITH__ `v` prefix)
- Click on `Generate release notes`
- Leave `Set as a pre-release` unchecked
- Leave `Set as the latest release` checked
- Click `Publish release`
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fix:
@/usr/libexec/PlistBuddy -c \
"Delete :FILEHEADER" \
"$(XCSHAREDDATA)/IDETemplateMacros.plist" >/dev/null 2>&1 || true
@header=$$'\n// All Contributions by Match Group\n//\n// Copyright © ___YEAR___ Tinder (Match Group, LLC)\n//\n// Licensed under the Match Group Modified 3-Clause BSD License.\n// See https://github.com/Tinder/Layout/blob/main/LICENSE for license information.\n//'; \
@header=$$'\n// All Contributions by Match Group\n//\n// Copyright © ___YEAR___ Tinder \(Match Group, LLC\)\n//\n// Licensed under the Match Group Modified 3-Clause BSD License.\n// See https://github.com/Tinder/Layout/blob/main/LICENSE for license information.\n//'; \
/usr/libexec/PlistBuddy -c \
"Add :FILEHEADER string $$header" \
"$(XCSHAREDDATA)/IDETemplateMacros.plist" >/dev/null 2>&1
Expand All @@ -33,6 +33,7 @@ analyze:
-destination "$(destination)" \
-derivedDataPath "$$DERIVED_DATA" \
-configuration "Debug" \
-skipPackagePluginValidation \
CODE_SIGNING_ALLOWED="NO" \
> "$$XCODEBUILD_LOG"; \
swift package plugin \
Expand Down Expand Up @@ -75,6 +76,7 @@ docs:
-scheme "$(target)" \
-destination "$(destination)" \
-derivedDataPath "$(DERIVED_DATA_PATH)" \
-skipPackagePluginValidation \
OTHER_DOCC_FLAGS="--warnings-as-errors"
@find "$(DERIVED_DATA_PATH)" \
-type d \
Expand Down
86 changes: 79 additions & 7 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
{
"pins" : [
{
"identity" : "collectionconcurrencykit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/JohnSundell/CollectionConcurrencyKit.git",
"state" : {
"revision" : "b4f23e24b5a1bff301efc5e70871083ca029ff95",
"version" : "0.2.0"
}
},
{
"identity" : "cryptoswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/krzyzanowskim/CryptoSwift.git",
"state" : {
"revision" : "729e01bc9b9dab466ac85f21fb9ee2bc1c61b258",
"version" : "1.8.4"
}
},
{
"identity" : "cwlcatchexception",
"kind" : "remoteSourceControl",
Expand All @@ -23,26 +41,80 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Quick/Nimble.git",
"state" : {
"revision" : "d616f15123bfb36db1b1075153f73cf40605b39d",
"version" : "13.0.0"
"revision" : "54b4e52183f16fe806014cbfd63718a84f8ba072",
"version" : "13.4.0"
}
},
{
"identity" : "sourcekitten",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/SourceKitten.git",
"state" : {
"revision" : "fd4df99170f5e9d7cf9aa8312aa8506e0e7a44e7",
"version" : "0.35.0"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
"version" : "1.5.0"
}
},
{
"identity" : "swift-snapshot-testing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing.git",
"state" : {
"revision" : "59b663f68e69f27a87b45de48cb63264b8194605",
"version" : "1.15.1"
"revision" : "6d932a79e7173b275b96c600c86c603cf84f153c",
"version" : "1.17.4"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"location" : "https://github.com/swiftlang/swift-syntax",
"state" : {
"revision" : "515f79b522918f83483068d99c68daeb5116342d",
"version" : "600.0.0-prerelease-2024-08-14"
}
},
{
"identity" : "swiftlint",
"kind" : "remoteSourceControl",
"location" : "https://github.com/realm/SwiftLint.git",
"state" : {
"revision" : "a24488f26e60247d8fff7bbb03d51910af3dc91c",
"version" : "0.56.2"
}
},
{
"identity" : "swiftytexttable",
"kind" : "remoteSourceControl",
"location" : "https://github.com/scottrhoyt/SwiftyTextTable.git",
"state" : {
"revision" : "c6df6cf533d120716bff38f8ff9885e1ce2a4ac3",
"version" : "0.9.0"
}
},
{
"identity" : "swxmlhash",
"kind" : "remoteSourceControl",
"location" : "https://github.com/drmohundro/SWXMLHash.git",
"state" : {
"revision" : "a853604c9e9a83ad9954c7e3d2a565273982471f",
"version" : "7.0.2"
}
},
{
"identity" : "yams",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams.git",
"state" : {
"revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036",
"version" : "509.0.2"
"revision" : "3036ba9d69cf1fd04d433527bc339dc0dc75433d",
"version" : "5.1.3"
}
}
],
Expand Down
Loading

0 comments on commit 8576b1c

Please sign in to comment.