SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

Add update checker

Open mildm8nnered opened this issue 1 year ago • 1 comments

Adds an update check facility to SwiftLint - addresses #5551

This has been added as a --check-for-updates command line option to the version, lint, and analyze commands.

It can also be enabled via the configuration file, as check_for_updates.

Although the usefulness of an opt-in option is limited, at least this provides a good story for how users can keep their installs up to date. And it could easily be changed to opt-out either here or at some later date.

The update checker code is pretty closely based on Periphery's implementation, and should probably be credited in the source file.

The update check is performed after all other processing, so linting will never be delayed, and the code is completely synchronous, as we do not have to worry about blocking the main thread.

The messaging for a new version is: A new version of SwiftLint is available: 0.51.1

We currently do not print any messaging if the update check fails, which is probably wrong.

% swiftlint help version
OVERVIEW: Display the current version of SwiftLint

USAGE: swiftlint version [--verbose] [--check-for-updates]

OPTIONS:
  --check-for-updates     Check whether a later version of SwiftLint is available.

%
% ./swiftlint version --check-for-updates
0.55.1
Your version of SwiftLint is up to date
%
%
% swiftlint help lint
OVERVIEW: Print lint warnings and errors

USAGE: swiftlint lint [<options>] [<paths> ...]

ARGUMENTS:
  <paths>                 List of paths to the files or directories to lint.

OPTIONS:
  --check-for-updates     Check whether a later version of SwiftLint is available.

mildm8nnered avatar May 29 '24 21:05 mildm8nnered

17 Messages
:book: Linting Aerial with this PR took 0.68s vs 0.7s on main (2% faster)
:book: Linting Alamofire with this PR took 0.9s vs 0.91s on main (1% faster)
:book: Linting Brave with this PR took 5.19s vs 5.28s on main (1% faster)
:book: Linting DuckDuckGo with this PR took 2.99s vs 2.94s on main (1% slower)
:book: Linting Firefox with this PR took 8.09s vs 8.13s on main (0% faster)
:book: Linting Kickstarter with this PR took 6.81s vs 6.89s on main (1% faster)
:book: Linting Moya with this PR took 0.42s vs 0.42s on main (0% slower)
:book: Linting NetNewsWire with this PR took 1.85s vs 1.85s on main (0% slower)
:book: Linting Nimble with this PR took 0.59s vs 0.57s on main (3% slower)
:book: Linting PocketCasts with this PR took 6.11s vs 6.08s on main (0% slower)
:book: Linting Quick with this PR took 0.35s vs 0.35s on main (0% slower)
:book: Linting Realm with this PR took 3.41s vs 3.4s on main (0% slower)
:book: Linting Sourcery with this PR took 1.73s vs 1.75s on main (1% faster)
:book: Linting Swift with this PR took 3.1s vs 3.1s on main (0% slower)
:book: Linting VLC with this PR took 0.95s vs 0.91s on main (4% slower)
:book: Linting Wire with this PR took 12.14s vs 12.16s on main (0% faster)
:book: Linting WordPress with this PR took 9.04s vs 8.92s on main (1% slower)

Generated by :no_entry_sign: Danger

SwiftLintBot avatar Jun 24 '24 09:06 SwiftLintBot

Looks good to me! A CHANGELOG entry is all that's left.

changelog entry added, but it looks like we're failing CI on the server on the Linux build and Danger as well maybe.

mildm8nnered avatar Jul 05 '24 12:07 mildm8nnered

Seems like this is only going to work in Swift 6 (with libraries updated accordingly). So we can revert my changes and go with the classic implementation for now until we switch to Swift 6.

SimplyDanny avatar Jul 06 '24 07:07 SimplyDanny

Looks good to me! A CHANGELOG entry is all that's left.

changelog entry added, but it looks like we're failing CI on the server on the Linux build and Danger as well maybe.

Finally worked this out - the new protocol unsurprisingly needed to be public (and documented).

mildm8nnered avatar Jul 06 '24 22:07 mildm8nnered