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

Add update checker #5613

Merged
merged 22 commits into from
Jul 6, 2024

Conversation

mildm8nnered
Copy link
Collaborator

@mildm8nnered mildm8nnered commented May 29, 2024

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 mildm8nnered changed the title Mildm8nnered check for updates Add update checker Jun 14, 2024
Source/SwiftLintCore/Models/Configuration.swift Outdated Show resolved Hide resolved
Source/SwiftLintCore/Models/Version.swift Outdated Show resolved Hide resolved
Source/swiftlint/Helpers/LintOrAnalyzeArguments.swift Outdated Show resolved Hide resolved
Source/swiftlint/Helpers/UpdateChecker.swift Show resolved Hide resolved
Source/SwiftLintCore/Models/Version.swift Outdated Show resolved Hide resolved
@mildm8nnered mildm8nnered force-pushed the mildm8nnered-check-for-updates branch from 5017b0f to 735f371 Compare June 24, 2024 08:44
@SwiftLintBot
Copy link

SwiftLintBot commented Jun 24, 2024

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

Generated by 🚫 Danger

@mildm8nnered mildm8nnered force-pushed the mildm8nnered-check-for-updates branch 5 times, most recently from 6899365 to a86b335 Compare June 29, 2024 15:01
@mildm8nnered mildm8nnered force-pushed the mildm8nnered-check-for-updates branch from 79c9df6 to ddeab5d Compare July 3, 2024 13:34
@SimplyDanny SimplyDanny force-pushed the mildm8nnered-check-for-updates branch from 8a4e922 to cee4b3e Compare July 4, 2024 21:06
Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

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

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

@mildm8nnered
Copy link
Collaborator Author

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 mildm8nnered marked this pull request as ready for review July 5, 2024 13:17
@SimplyDanny
Copy link
Collaborator

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.

@mildm8nnered
Copy link
Collaborator Author

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 mildm8nnered merged commit e0b9295 into realm:main Jul 6, 2024
12 checks passed
@mildm8nnered mildm8nnered deleted the mildm8nnered-check-for-updates branch July 6, 2024 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants