Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update dogfood tool to support new format of package.resolved #800

Conversation

ncreated
Copy link
Member

@ncreated ncreated commented Apr 5, 2022

What and why?

⚙️ This PR fixes the problem of the recent dogfooding automation failure:

❌ Failed to dogfood: .package.resolved uses version 2 but `package_resolved.py` supports version 1. Update `package_resolved.py` to new format.

swiftlang/swift-package-manager#3717 introduced a new format of package.resolved in Swfit 5.6 toolchain (CHANGELOG). Before, both dd-sdk-ios and its dependant projects (Shopist iOS and Datadog iOS app) were using package.resolved in version: 1. Recently, Datadog iOS app's build was upgraded to new toolchain and it uses version: 2.

This PR enhances dogfood script to support both formats, so we can freely use different toolchains in different repositories.

V1's package.resolved example:

{
    "object": {
        "pins": [
            {
                "package": "DatadogSDK",
                "repositoryURL": "https://github.com/DataDog/dd-sdk-ios",
                "state": {
                    "branch": "dogfooding",
                    "revision": "6f662103771eb4523164e64f7f936bf9276f6bd0",
                    "version": null
                }
            },
            // ...
        ]
    },
    "version": 1
}

V2's package.resolved example:

{
    "pins" : [
        {
            "identity" : "dd-sdk-ios",
            "kind" : "remoteSourceControl",
            "location" : "https://github.com/DataDog/dd-sdk-ios",
            "state" : {
                "branch" : "dogfooding",
                "revision" : "6f662103771eb4523164e64f7f936bf9276f6bd0"
            }
        },
        ...
    ]
    "version" : 2
}

How?

The PackageResolvedFile now uses one of 2 wrapped types:

  • PackageResolvedContentV1 - for manipulating version: 1 structure,
  • PackageResolvedContentV2 - for manipulating version: 2 structure.

Because dependencies now need to be identified differently, e.g.:

  • "package": "DatadogSDK" - in v1
  • "identity" : "dd-sdk-ios" - in v2

I introduced PackageID concept, which manages ID for both formats (through id.v1 and id.v2).

This isolation is to simplify migration once we drop version: 1 in all projects. To avoid mistakes, I added full tests coverage for PackageResolvedFile and both formats.

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)
  • Make sure each commit and the PR mention the Issue number or JIRA reference
  • Add CHANGELOG entry for user facing change.

@ncreated ncreated requested a review from a team as a code owner April 5, 2022 12:26
@ncreated ncreated self-assigned this Apr 5, 2022
@ncreated ncreated changed the title Update dogfooding tool to support new format of package.resolved Update dogfood tool to support new format of package.resolved Apr 5, 2022
Copy link
Member

@maxep maxep left a comment

Choose a reason for hiding this comment

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

Wow, nice catch and nice fix 👏

@ncreated ncreated merged commit 1275996 into develop Apr 6, 2022
@ncreated ncreated deleted the ncreated/update-dogfooding-tool-to-support-new-format-of-package-resolved branch April 6, 2022 07:19
@ncreated ncreated mentioned this pull request Apr 6, 2022
3 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants