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

Package.resolve isn't updated after update Package.swift #6924

Open
ra1028 opened this issue Aug 6, 2020 · 30 comments
Open

Package.resolve isn't updated after update Package.swift #6924

ra1028 opened this issue Aug 6, 2020 · 30 comments
Labels
manager:swift Related to the Swift package manager priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:in-progress Someone is working on implementation type:feature Feature (new functionality)

Comments

@ra1028
Copy link

ra1028 commented Aug 6, 2020

What Renovate type are you using?

Renovate for GitHub

Describe the bug

Renovate supports Swift Package Manager, but Package.resolved isn't updated after Package.swift is updated.
That's a lock file of Swift tool dependencies, so it should be updated if it exists on git, otherwise, always diff will be made on the local environment after only Package.swift is updated.

Relevant debug logs

There is no such thing as a log, as it's a specification failure, not a runtime error.

To Reproduce

This happens whenever there is an update to the Swift package listed in Package.swift.

@ra1028 ra1028 changed the title Package.resolve is't updated after update Package.swift Package.resolve isn't updated after update Package.swift Aug 6, 2020
@rarkins rarkins added manager:swift Related to the Swift package manager type:feature Feature (new functionality) priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others auto:reproduction A minimal reproduction is necessary to proceed labels Aug 6, 2020
@rarkins
Copy link
Collaborator

rarkins commented Aug 6, 2020

Thanks, this feature is not yet supported. Please assist by providing:

  • Link(s) to where this is best documented
  • Any guides to how this can be run under Linux
  • A public repo that reproduces the problem/requirement

@ra1028
Copy link
Author

ra1028 commented Aug 6, 2020

@rarkins
Hi, thanks for your response.
I've created a sample public repository about this issue.

Link(s) to where this is best documented

renovate swift document: https://docs.renovatebot.com/modules/manager/swift
sample pr: ra1028/sample-renovate6924#1

Any guides to how this can be run under Linux

Just run swift package update after Package.swift is updated on the image that Swift lang is installed.

A public repo that reproduces the problem/requirement

@rarkins
Copy link
Collaborator

rarkins commented Aug 6, 2020

Definitely update and not resolve?

Also I was hoping for Swift's own documentation rather than ours, plus any examples of running it in Ubuntu 18.04 under Docker, or something close.

@ra1028
Copy link
Author

ra1028 commented Aug 6, 2020

@rarkins

As you can see, Package.resolved is not changed after Package.swift is updated.
ra1028/sample-renovate6924#1

Swift package manager documentation:

@viceice
Copy link
Member

viceice commented Aug 6, 2020

I think we need to call swift package resolve this will only update the resolved file, while swift package update updates the swift file too with latest available updates

@rarkins
Copy link
Collaborator

rarkins commented Aug 6, 2020

I think it should be swift package resolve and not swift package update

@viceice
Copy link
Member

viceice commented Aug 6, 2020

Official docker images: https://hub.docker.com/_/swift

@viceice
Copy link
Member

viceice commented Aug 6, 2020

docker file:
https://github.com/apple/swift-docker/blob/bcaa665ab185e9af7d82612c9436950e92466451/5.2/ubuntu/18.04/Dockerfile

we need to update our buildpack and a new gitrepo for docker-swift

@viceice
Copy link
Member

viceice commented Aug 6, 2020

then renovate needs to extract tools version from comment to use correct swift version

// swift-tools-version:5.3

https://github.com/ra1028/sample-renovate6924/blob/a11e2e7eb7445db0d4df0e1982b78c1a5c4398ae/Package.swift#L1

@viceice
Copy link
Member

viceice commented Aug 6, 2020

We can use git-tags as datasource with a regex versioning swift-5.2.5-RELEASE

I think we need use stabillityDays=1 to wait for build binaries.

@rarkins
Copy link
Collaborator

rarkins commented Aug 6, 2020

@Ali-Dervisoglu
Copy link

Yes

@viceice
Copy link
Member

viceice commented Oct 21, 2020

which swift version we should build? Where to start? v5, v5.3, v4 ...

@viceice
Copy link
Member

viceice commented Oct 21, 2020

image
renovate won't be able to resolve under linux, because the test repo above explicit needs macos

@viceice
Copy link
Member

viceice commented Oct 21, 2020

which swift version we should build? Where to start? v5, v5.3, v4 ...

I propose v5.3, as this supports updating older resolved files and supports ubuntu 20.04 focal

@viceice
Copy link
Member

viceice commented Oct 21, 2020

@github-actions
Copy link
Contributor

Thank you for providing a reproduction! 🎉 🚀

The Renovate team will take a look at the reproduction repository. Once we confirm the provided repository reproduces the problem, the label will be changed to reproduction:confirmed.

@nabeelsaabna nabeelsaabna added impact:small status:in-progress Someone is working on implementation and removed status:ready labels Sep 23, 2022
@asa08

This comment was marked as outdated.

@viceice

This comment was marked as resolved.

@viceice

This comment was marked as outdated.

@Fab1n

This comment was marked as outdated.

@rarkins

This comment was marked as outdated.

@viceice

This comment was marked as outdated.

@eduardboamba

This comment was marked as spam.

@rarkins rarkins assigned eduardboamba and unassigned Fab1n Aug 16, 2023
@joseewu

This comment was marked as spam.

@rarkins rarkins assigned joseewu and unassigned eduardboamba Sep 15, 2023
@setchy
Copy link
Collaborator

setchy commented Sep 21, 2023

Earlier today my Lead iOS Engineer raised this as being a useful feature addition to our Renovate workflow.

Is there any pre-req items I should be aware of for this feature? I'd be happy to try and contribute it, although my interactions with Swift Package Manager are exactly undefined atm 😅

@rarkins
Copy link
Collaborator

rarkins commented Sep 22, 2023

Swift seems supported already in Containerbase: https://github.com/search?q=repo%3Acontainerbase%2Fbase%20swift&type=code

Hopefully this reproduction repo is still valid: https://github.com/ra1028/sample-renovate6924

Hopefully running swift resolve after a package file update is enough for a start.

A simple/similar one I added recently is Bun: https://github.com/renovatebot/renovate/blob/main/lib/modules/manager/bun/artifacts.ts

The main difference here is that you probably don't want to treat it as a Buffer/binary file although even that might work.

@doozMen
Copy link

doozMen commented Oct 2, 2023

I think it should be swift package resolve and not swift package update

ok so there seams to be confusion about this. It should be swift package update from the start. You should not suggest to update the Package.swift. Package.swift should be edited manually. The Package.swift file defines the minimum version a library is compatible with, the Package.resolved defines the version that is used during build.

Note: As a reference you could read package resolved docs

I will try to clarify why updating Package.swift for a dependency is not the way to go. The goal of the bot should be to detect wether there are updates available for the package. If versioning is done correctly it could suggest updates that can be done automatically. This is what swift package update does. It checks the package.swift file for how dependencies are defined and updates the once that are needed.

So the update process is handled by swift package update.

swift package resolve will resolve to the latest version that it can use based on what is defined in the package.swift file. But it will not go fetch the dependencies to be ready for build.

So in short if you would want to make the bot check wether ar not there are updates it should

  1. mv the package.resolved (if present) to a temp copy
  2. do swift package resolve
  3. diff the 2 resolved files
  4. come up with a suggestion of update

The updated version should then be committed to the resolved file.

When to update the Package.swift then?

When the library needs features that are in the next version of the dependency, effectively making it incompatible with packages that cannot yet update to that version number.

@doozMen
Copy link

doozMen commented Oct 2, 2023

Swift runs just fine in linux and you have installation options at https://www.swift.org/install/#:~:text=on%20download%20page.-,Linux,-Docker

As for github actions the latest ubuntu has swift build in so you do not need to do anything.

@malcommac

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
manager:swift Related to the Swift package manager priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:in-progress Someone is working on implementation type:feature Feature (new functionality)
Projects
None yet
Development

Successfully merging a pull request may close this issue.