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

Binary in Docker Image for 0.58.0 reports version 0.57.1 #5966

Closed
2 tasks done
andrewdmontgomery opened this issue Jan 15, 2025 · 4 comments
Closed
2 tasks done

Binary in Docker Image for 0.58.0 reports version 0.57.1 #5966

andrewdmontgomery opened this issue Jan 15, 2025 · 4 comments
Labels
bug Unexpected and reproducible misbehavior. integration Issues related to integration of SwiftLint into toolchains.

Comments

@andrewdmontgomery
Copy link
Contributor

New Issue Checklist

Bug Description

The swiftlint binary in the 0.58.0 docker image reports that it is version 0.57.1. Note that I am running this on Apple Silicon, hence the --platform option in the docker run command below. However, we also see the same thing in CI, which runs on linux/amd64.

Apple Silicon

$ docker run -it --platform linux/amd64 ghcr.io/realm/swiftlint:0.58.0 swiftlint --version
Unable to find image 'ghcr.io/realm/swiftlint:0.58.0' locally
0.58.0: Pulling from realm/swiftlint
de44b265507a: Pull complete
8718f4f5e50c: Pull complete
6e687c913312: Pull complete
b3d29ab723b4: Pull complete
cf3691679039: Pull complete
76e47102f2a9: Pull complete
6b3bcc82bc86: Pull complete
b4669235d0eb: Pull complete
537acf74a7a6: Pull complete
6431e8f7399a: Pull complete
d77fbf8071a1: Pull complete
39d62eca93cc: Pull complete
0b235ed03e37: Pull complete
d8961c0fcc94: Pull complete
953389c2006c: Pull complete
b2b2cca6f9e7: Pull complete
41a3c0af4e6c: Pull complete
d60384f06df9: Pull complete
f214275f516b: Pull complete
b530521e93c9: Pull complete
44522d4bf699: Pull complete
42ce554ae246: Pull complete
a2e7976b5aa5: Pull complete
69600c272f5e: Pull complete
1bda57782865: Pull complete
3cc7443e3f28: Pull complete
bc94a15fc249: Pull complete
5cfda18034e5: Pull complete
5817fb423b44: Pull complete
026259948dad: Pull complete
5cf5414d4378: Pull complete
4510959b5857: Pull complete
4f4fb700ef54: Pull complete
430b205bc580: Pull complete
Digest: sha256:27b2dc68fb35f554d5cebcb7b47345d95559f85011bc50ef511dab36d3ae1277
Status: Downloaded newer image for ghcr.io/realm/swiftlint:0.58.0
0.57.1

Since we specify swiftlint_version: 0.58.0 in our .swiftlint.yml, this causes SwiftLint to exit with a warning:

$ docker run -it --platform linux/amd64 -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.58.0
warning: Currently running SwiftLint 0.57.1 but configuration specified version 0.58.0.

CI

[2025-01-15T18:51:29Z] Status: Downloaded newer image for ghcr.io/realm/swiftlint:0.58.0
[2025-01-15T18:51:30Z] warning: Currently running SwiftLint 0.57.1 but configuration specified version 0.58.0.

Environment

  • SwiftLint version (run swiftlint version to be sure): swiftlint version reports 0.57.1. But the docker run invocation specifies 0.58.0
  • Xcode version (run xcodebuild -version to be sure): Xcode 16.2 (16C5032a)
  • Installation method used (Homebrew, CocoaPods, building from source, etc): Docker Image
  • Configuration file:
swiftlint_version: 0.58.0
only_rules: # Rules to run
  - custom_rules

# If true, SwiftLint will treat all warnings as errors.
strict: true

included:
  - Sources
  - Tests

custom_rules:
  no_ns_localized_string:
    included:
      - "Sources/.*\\.swift"
    name: "No NSLocalizedString"
    regex: "NSLocalizedString\\("
    match_kinds:
      - identifier
    message: "Use `SDKLocalizedString()` instead of `NSLocalizedString()`."
    severity: error
@AliSoftware
Copy link
Contributor

It seems the same off-by-one-version issue is happening for 0.58.1 image too, it having 0.58.0 version instead:

$ docker run -it --platform linux/amd64 ghcr.io/realm/swiftlint:0.58.0 swiftlint --version
0.57.1

$ docker run -it --platform linux/amd64 ghcr.io/realm/swiftlint:0.58.1 swiftlint --version
0.58.0

@andrewdmontgomery
Copy link
Contributor Author

andrewdmontgomery commented Jan 15, 2025

The Release GH Action reports the following inputs:

context: https://github.com/realm/SwiftLint.git#a86ab8d5e1b1cd5c282ee405afdd66779677366c
outputs:
  - type=registry
  - type=local,dest=artifacts
platforms:
  - linux/amd64
tags:
  - ghcr.io/realm/swiftlint:0.58.0

I believe that commit is too early. Looking at the history from the release commit (fcd437443), the version number was updated in commit (0c7d0098), which follows the one this build used (a86ab8d5).

$ git checkout tags/0.58.0
$ git log
commit fcd4374431159a645d27d549ac3879f3e0ee1fa6 (HEAD, tag: 0.58.0)
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Sun Jan 12 12:35:01 2025 +0000

    Release 0.58.0

commit 0c7d00983937f3abdc944b78335f362890d7c29d
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Sun Jan 12 12:23:29 2025 +0000

    Prepare 0.58.0 release

commit a86ab8d5e1b1cd5c282ee405afdd66779677366c
Author: Danny Mösch <danny.moesch@icloud.com>
Date:   Sun Jan 12 13:06:10 2025 +0100

    Name release assets

@andrewdmontgomery
Copy link
Contributor Author

andrewdmontgomery commented Jan 15, 2025

Looking a little more at this, I realize that the workflow accounts for this:

  1. Creates a release/0.58.0 branch
  2. Updates the versions
  3. commits and pushes the branch

So that seems to explain what I saw above.

And it looks like the Docker image job checks out the branch with the new commit.

@SimplyDanny
Copy link
Collaborator

I finally got it fixed. Thank you for the report and the analysis!

Turns out, the Docker build action doesn't care for the local repository being checked out. It builds the state of the repository the initial release action was started on. That was always the latest commit on main which is without the version bump.

The fix is actually easy: You add context: . to the Docker build action.

Long story short, 0.58.2 is finally available and it even reports the correct version. Please have a try.

@SimplyDanny SimplyDanny added bug Unexpected and reproducible misbehavior. integration Issues related to integration of SwiftLint into toolchains. labels Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior. integration Issues related to integration of SwiftLint into toolchains.
Projects
None yet
Development

No branches or pull requests

3 participants