Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify swift-format soundness script #108

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ let package = Package(
.testTarget(
name: "OpenAPIGeneratorCoreTests",
dependencies: [
"_OpenAPIGeneratorCore",
"_OpenAPIGeneratorCore"
]
),

Expand All @@ -103,7 +103,7 @@ let package = Package(
.product(name: "SwiftFormatConfiguration", package: "swift-format"),
],
resources: [
.copy("Resources"),
.copy("Resources")
]
),

Expand All @@ -113,7 +113,7 @@ let package = Package(
.testTarget(
name: "PetstoreConsumerTests",
dependencies: [
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime")
]
),

Expand All @@ -131,7 +131,7 @@ let package = Package(
name: "OpenAPIGenerator",
capability: .buildTool(),
dependencies: [
"swift-openapi-generator",
"swift-openapi-generator"
]
),
]
Expand Down
11 changes: 3 additions & 8 deletions scripts/run-swift-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,16 @@ REPO_ROOT="$(git -C "${CURRENT_SCRIPT_DIR}" rev-parse --show-toplevel)"

SWIFTFORMAT_BIN=${SWIFTFORMAT_BIN:-$(command -v swift-format)} || fatal "❌ SWIFTFORMAT_BIN unset and no swift-format on PATH"

"${SWIFTFORMAT_BIN}" lint \
--parallel --recursive --strict \
"${REPO_ROOT}/Examples" \
"${REPO_ROOT}/IntegrationTest" \
"${REPO_ROOT}/Plugins" \
"${REPO_ROOT}/Sources" \
"${REPO_ROOT}/Tests" \
git -C "${REPO_ROOT}" ls-files -z '*.swift' \
| xargs -0 "${SWIFTFORMAT_BIN}" lint --parallel --strict \
&& SWIFT_FORMAT_RC=$? || SWIFT_FORMAT_RC=$?

if [ "${SWIFT_FORMAT_RC}" -ne 0 ]; then
fatal "❌ Running swift-format produced errors.

To fix, run the following command:

% swift-format format --parallel --recursive --in-place Examples IntegrationTest Plugins Sources Tests
% git ls-files -z '*.swift' | xargs -0 swift-format --in-place --parallel
"
exit "${SWIFT_FORMAT_RC}"
fi
Expand Down