Skip to content

Add Swift Build Tool Plugin for automatic dependency validation#3

Merged
tonyarnold merged 20 commits intomainfrom
build-plugins
Jul 18, 2025
Merged

Add Swift Build Tool Plugin for automatic dependency validation#3
tonyarnold merged 20 commits intomainfrom
build-plugins

Conversation

@tonyarnold
Copy link
Copy Markdown
Owner

  • Implement DependencyAuditPlugin conforming to BuildToolPlugin protocol
  • Plugin runs prebuild commands with target-specific analysis and Xcode output
  • Update Package.swift with plugin target definition and capability
  • Add documentation and examples for plugin usage

- Implement DependencyAuditPlugin conforming to BuildToolPlugin protocol
- Plugin runs prebuild commands with target-specific analysis and Xcode output
- Update Package.swift with plugin target definition and capability
- Add documentation and examples for plugin usage
@tonyarnold tonyarnold requested a review from Copilot July 17, 2025 04:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a Swift Package Manager build tool plugin to automate dependency validation during package and Xcode builds.

  • Implements DependencyAuditPlugin conforming to BuildToolPlugin to run the audit prebuild
  • Updates Package.swift to declare the plugin product and target
  • Adds documentation in README.md and notes in CHANGELOG.md for plugin usage

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
README.md Added Build Tool Plugin integration documentation
Plugins/DependencyAuditPlugin/DependencyAuditPlugin.swift Implemented plugin that runs a prebuild dependency audit
Package.swift Added plugin product and target definitions
CHANGELOG.md Updated changelog with plugin features and architecture

cd "\(context.package.directoryURL.path)"

# Run dependency audit for specific target
swift run swift-dependency-audit \\
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

[nitpick] Invoking the audit tool via swift run can be slower and less robust; consider using the PackagePlugin API (context.tool(named:)) to locate and execute the swift-dependency-audit executable directly.

Suggested change
swift run swift-dependency-audit \\
"\(try context.tool(named: "swift-dependency-audit").path)" \\

Copilot uses AI. Check for mistakes.
Comment on lines +35 to +36
// Check if target name contains "Test" to identify test targets
if !target.name.lowercased().contains("test") {
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

[nitpick] Detecting test targets by checking the name substring is brittle; use the target’s type (e.g., TestTarget) or another metadata property to differentiate test and non-test targets.

Suggested change
// Check if target name contains "Test" to identify test targets
if !target.name.lowercased().contains("test") {
// Check if the target is not a TestTarget to identify non-test targets
if !(target is TestTarget) {

Copilot uses AI. Check for mistakes.
Comment on lines +65 to +67
// For now, analyze all targets and let the tool itself filter appropriately
// The tool will skip targets that don't have source directories
return true
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

[nitpick] Analyzing all targets can lead to unnecessary executions on non-source modules; consider filtering to SourceModuleTarget instances within shouldAnalyzeTarget to reduce overhead.

Suggested change
// For now, analyze all targets and let the tool itself filter appropriately
// The tool will skip targets that don't have source directories
return true
// Only analyze source-based targets
return target is SourceModuleTarget

Copilot uses AI. Check for mistakes.
@tonyarnold tonyarnold force-pushed the build-plugins branch 2 times, most recently from 50dc49a to 3c91619 Compare July 17, 2025 11:34
@tonyarnold tonyarnold marked this pull request as ready for review July 18, 2025 00:00
@tonyarnold tonyarnold merged commit 963de27 into main Jul 18, 2025
3 checks passed
@tonyarnold tonyarnold deleted the build-plugins branch July 18, 2025 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants