Skip to content

Update CI scripts to support dependency overrides where traits are used#902

Merged
simonjbeaumont merged 2 commits into
apple:mainfrom
simonjbeaumont:sb/fix-package-override-in-ci-scripts
May 5, 2026
Merged

Update CI scripts to support dependency overrides where traits are used#902
simonjbeaumont merged 2 commits into
apple:mainfrom
simonjbeaumont:sb/fix-package-override-in-ci-scripts

Conversation

@simonjbeaumont
Copy link
Copy Markdown
Collaborator

@simonjbeaumont simonjbeaumont commented May 5, 2026

Motivation

This project has CI for example projects and an integration test. These use a standalone package with a dependency on
swift-openapi-generator. The scripts driving this CI used swift package edit to override this dependency to the
checkout of the PR under test.

Unfortunately this does not work in the presence of package traits. In open PR #875 the OpenAPIKit dependency is being
bumped and is switched to disabling default traits. However, the CI is failing to perform the swift package edit
command. The root cause is that swift package edit performs dependency resolution in order to edit the dependency.
This resolves OpenAPIKit to a version satisfying the constraints on main -- a version of OpenAPIKit that has no traits.
After the override, the build fails because SwiftPM forbids disabling traits on a package that has no declared traits.
This is because OpenAPIKit is not re-resolved to the version declared in the local PR branch, even though it has been
bumped. After quite some investigation, it appears there's no way to influence this behaviour or to defer resolution
until after the dependency edit. This thesis aligns with the open SwiftPM issue tracking support for traits for swift package edit1

Modifications

Workaround the lack of trait-aware swift package edit by updating the examples and integration test CI scripts to
instead inject an override block into the package manifest.

Result

The scripts should now work as intended, even when the minimum version of a transitive dependency is bumped and/or when
transitive dependencies make use of package traits.

Test Plan

Reproduced the original error in #875:

% git rev-parse --symbolic-full-name HEAD
refs/heads/update-openapi-kit-to-v5

% SINGLE_EXAMPLE_PACKAGE=hello-world-urlsession-client-example ./scripts/test-examples.sh
...
error: Disabled default traits by package 'swift-openapi-generator' (swift-openapi-generator) on package 'openapikit' (OpenAPIKit) that declares no traits. This is prohibited to allow packages to adopt traits initially without causing an API break.

With this patch applied we can run the script fine on the PR branch:

% git cherry-pick sb/fix-package-override-in-ci-scripts
[update-openapi-kit-to-v5 2544c13] Update CI scripts to support dependency overrides where traits are used
 Date: Tue May 5 14:55:35 2026 +0100
 2 files changed, 29 insertions(+), 18 deletions(-)

% SINGLE_EXAMPLE_PACKAGE=hello-world-urlsession-client-example ./scripts/test-examples.sh
...
** Overriding swift-openapi-generator dependency in hello-world-urlsession-client-example to use /Users/Si/work/code/swift-openapi-generator
** Building example package: hello-world-urlsession-client-example
...
Computing version for https://github.com/mattpolzin/OpenAPIKit
Computed https://github.com/mattpolzin/OpenAPIKit at 6.0.0 (14.10s)
...
Creating working copy for https://github.com/mattpolzin/OpenAPIKit
Working copy of https://github.com/mattpolzin/OpenAPIKit resolved at 6.0.0
...
Build complete! (44.22s)
** ✅ Successfully built the example package hello-world-urlsession-client-example.

Footnotes

  1. https://github.com/swiftlang/swift-package-manager/issues/8354

@simonjbeaumont simonjbeaumont added the semver/none No version bump required. label May 5, 2026
@simonjbeaumont simonjbeaumont marked this pull request as ready for review May 5, 2026 15:20
@simonjbeaumont simonjbeaumont merged commit 0d5694c into apple:main May 5, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver/none No version bump required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants