-
Notifications
You must be signed in to change notification settings - Fork 328
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
Pin SwiftLint #4258
base: main
Are you sure you want to change the base?
Pin SwiftLint #4258
Changes from 12 commits
0a821c3
cc2ce28
0565f33
dfea1ec
4892ba5
43f2fc8
1235b90
12cf9eb
6022e17
5b75763
cf1aa39
eb8e20c
8f0256a
854cd35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,8 @@ let shouldIncludeDocCPlugin = environmentVariables["INCLUDE_DOCC_PLUGIN"] == "tr | |
var dependencies: [Package.Dependency] = [ | ||
.package(url: "[email protected]:Quick/Nimble.git", from: "10.0.0"), | ||
// SST requires iOS 13 starting from version 1.13.0 | ||
.package(url: "[email protected]:pointfreeco/swift-snapshot-testing.git", .upToNextMinor(from: "1.12.0")) | ||
.package(url: "[email protected]:pointfreeco/swift-snapshot-testing.git", .upToNextMinor(from: "1.12.0")), | ||
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", exact: "0.57.0") | ||
] | ||
if shouldIncludeDocCPlugin { | ||
// Versions 1.4.0 and 1.4.1 are failing to compile, so we are pinning it to 1.3.0 for now | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Arm64 macs have this destination. | ||
HOMEBREW_BINARY_DESTINATION="/opt/homebrew/bin" | ||
if ! test -d $HOMEBREW_BINARY_DESTINATION; then | ||
# X86_64 macs have this destination | ||
HOMEBREW_BINARY_DESTINATION="/usr/local/bin" | ||
fi | ||
|
||
echo "Adding homebrew bin folder to PATH (${HOMEBREW_BINARY_DESTINATION})" | ||
PATH="${HOMEBREW_BINARY_DESTINATION}:${PATH}" | ||
|
||
if which swiftlint >/dev/null; then | ||
script_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | ||
source_path="${script_path}/../" | ||
swiftlint_path="$(which swiftlint)" | ||
|
||
echo "linter path:" | ||
echo $swiftlint_path | ||
|
||
lint_command="${swiftlint_path} lint" | ||
echo "linter command: ${lint_command}" | ||
|
||
pushd "${source_path}" | ||
# Run swiftlint but filter out "Linting ..." to clean up output | ||
$lint_command 2>&1 | grep -v 'Linting ' | ||
popd | ||
else | ||
echo "Warning: SwiftLint not installed in ${HOMEBREW_BINARY_DESTINATION}, download from https://github.com/realm/SwiftLint" | ||
fi | ||
|
||
swift package plugin swiftlint lint --quiet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Running this in a Run Script Build Phase in Xcode doesn't work. I suspect it has to do with environment variables because I can reproduce it in the terminal if I
Happens on CI too, see here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome, thanks! Is there an advantage of using the absolute path to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No advantage if it's already available via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work because somehow swift package plugins run for every module. Only the last of those runs will save the output file, causing issues to be lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running it with verbose output tells me it's running for each module, which map to the targets specified in our
Package.swift
:I think this is
swift package
that's running theplugin
command for each target. It seems to be happening outside ofswiftlint
's control. Not sure yet how to makeswift package
confine itself to a single target.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a convention to support a
--target
argument. SwiftLint's command plugin supports it partly. It passes the--target
argument on to the actualswiftlint
program, which doesn't recognize it and errors out.There’s a fork that fixes this issue. I’ve asked if they can propose their fix upstream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.57.1 includes a fix for this.