Skip to content
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
20 changes: 20 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,23 @@ tasks.register<JavaExec>("ktlintFormat") {
main = "com.pinterest.ktlint.Main"
args = listOf("-F") + lintPaths
}

// Swift lint tasks (mirrors CI lint.yml workflow)

tasks.register<Exec>("swiftlint") {
description = "Run swiftlint (standard + analyzer on compiled code), matching CI."
group = "Verification"
commandLine("bash", "scripts/swiftlint-ci.sh")
}

tasks.register<Exec>("swiftlintFormat") {
description = "Auto fix Swift lint violations (standard + analyzer)."
group = "formatting"
commandLine("bash", "scripts/swiftlint-ci.sh", "--fix")
}

tasks.register<Exec>("swiftlintAnalyze") {
description = "Run swiftlint analyzer only (requires compilation)."
group = "Verification"
commandLine("bash", "scripts/swiftlint-ci.sh", "--analyze-only")
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've never had Gradle tasks for swiftlint before... is there a reason we're adding them versus just calling the script directly?

Copy link
Copy Markdown
Contributor Author

@dayaffe dayaffe Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it would make it easy/consistent to run since we already use a gradle task for ktlint (note this is just for local use and CI is not using it)

44 changes: 44 additions & 0 deletions scripts/swiftlint-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
#
# Runs swiftlint the same way CI does, including the analyzer pass on compiled code.
# Usage: ./scripts/swiftlint-ci.sh [--analyze-only | --lint-only] [--fix]
#
set -euo pipefail
cd "$(dirname "$0")/.."

MODE="all"
FIX=""
for arg in "$@"; do
case "$arg" in
--fix) FIX="--fix" ;;
--lint-only) MODE="lint" ;;
--analyze-only) MODE="analyze" ;;
-h|--help)
echo "Usage: $0 [--analyze-only | --lint-only] [--fix]"
exit 0
;;
*) echo "Unknown arg: $arg"; exit 1 ;;
esac
done

run_lint() {
swiftlint --strict $FIX
}

run_analyze() {
rm -rf Sources/Services/*
cd AWSSDKSwiftCLI
swift run AWSSDKSwiftCLI generate-package-manifest ..
cd ..
xcodebuild -scheme aws-sdk-swift-Package -destination platform=macOS > xcodebuild.log 2>&1 || {
echo "xcodebuild failed. See xcodebuild.log"
exit 1
}
swiftlint analyze --strict --compiler-log-path xcodebuild.log $FIX
}

case "$MODE" in
lint) run_lint ;;
analyze) run_analyze ;;
all) run_lint; run_analyze ;;
esac
Loading