-
Notifications
You must be signed in to change notification settings - Fork 28
Append swift-docc-plugin only when needed #109
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
Append swift-docc-plugin only when needed #109
Conversation
for package_file in $package_files; do | ||
log "Editing $package_file..." | ||
cat <<EOF >> "$package_file" | ||
# yq 3.1.0-3 doesn't have filter, otherwise we could replace the grep call with "filter(.identity == "swift-docc-plugin") | keys | .[]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Trying out filter via
hasDoccPlugin=$(swift package dump-package | yq -r '.dependencies[].sourceControl | filter(.identity == "swift-docc-plugin") | keys | .[]')
https://github.com/fboemer/swift-homomorphic-encryption/actions/runs/13997912746/job/39197486713
jq: error: filter/1 is not defined at <top-level>, line 1:[222](https://github.com/fboemer/swift-homomorphic-encryption/actions/runs/13997912746/job/39197486713#step:5:223)
.dependencies[].sourceControl | filter(.identity == "swift-docc-plugin") | keys | .[]
jq: 1 compile error
yq: Error running jq: BrokenPipeError: [Errno 32] Broken pipe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. Looks good to me, just one small comment.
log "Editing $package_file..." | ||
cat <<EOF >> "$package_file" | ||
# yq 3.1.0-3 doesn't have filter, otherwise we could replace the grep call with "filter(.identity == "swift-docc-plugin") | keys | .[]" | ||
hasDoccPlugin=$(swift package dump-package | yq -r '.dependencies[].sourceControl' | grep -e "\"identity\": \"swift-docc-plugin\"" || true ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swift package dump-package
is JSON, so should this be jq
instead of yq
?
Also: Trailing space after true
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already use yq
later on in the script, so I figured no need to an extra dependency, since yq
supports json (as well as yaml)
Also: Trailing space after true)
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good call. Good with me.
8107807
to
a74cf14
Compare
Currently, the
docs-check:
workflow always adds theswift-docc-plugin
dependency, forcing adopters to remove the dependency from their package. This PR edits the docs check to skip adding the dependency when already present.A package with swift-docc-plugin: https://github.com/fboemer/swift-homomorphic-encryption/actions/runs/13997582365/job/39196407070?pr=3#step:5:222
A package without swift-docc-plugin: https://github.com/fboemer/swift-homomorphic-encryption/actions/runs/13997685223/job/39196742443#step:5:222