Skip to content

Add Swift Package Manager component detection support #1316

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

Conversation

raporpe
Copy link
Contributor

@raporpe raporpe commented Nov 28, 2024

Component detection does not currently support detection of Swift Package Manager. This package manager is the new default for swift-related projects now that CocoaPods (supported by Component detection) is on maintenance mode.

This new detector adds basic support to SwiftPM by parsing the JSON file Package.resolved that is generated when dependencies are resolved. This file is usually present in repositories and after building a Swift Package and its contents are enough to detect both direct and transitive dependencies.

This detector does not parse the Package.swift file (hard to parse and does not include transitive dependencies) and does not differentiate between build dependencies, transitive dependencies, and direct dependencies (it is not possible by just parsing Package.resolved).

This detector will register two kind of components: a SwiftPMComponent and a GitComponent. I have decided to also register a Git component because SwiftPM does not rely in a repository infrastructure such as NPM, it directly downloads other Swift Packages from the git repositories. I need feedback in this regard, since I do not know what is the best practice (maybe having two registered components for the same dependency is not a good idea?)

I had to invest time in troubleshooting the verification tests because I was not passing them. The issue is that the reference snapshot has less packages because the environments differ for PipReport since PR #1259. I have added the same environment vars to the snapshot-publish pipeline although maybe @pauld-msft could take a look at this PR to verify that my modification is correct.

@raporpe raporpe requested a review from a team as a code owner November 28, 2024 13:08
@raporpe raporpe requested a review from JamieMagee November 28, 2024 13:08
@raporpe
Copy link
Contributor Author

raporpe commented Nov 28, 2024

@raporpe please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree company="Microsoft"

Copy link

codecov bot commented Nov 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.4%. Comparing base (477409a) to head (5976737).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1316     +/-   ##
=======================================
+ Coverage   89.2%   89.4%   +0.1%     
=======================================
  Files        393     398      +5     
  Lines      30445   30997    +552     
  Branches    1854    1867     +13     
=======================================
+ Hits       27175   27726    +551     
+ Misses      2867    2866      -1     
- Partials     403     405      +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@raporpe raporpe requested a review from grvillic February 20, 2025 12:56
@grvillic grvillic merged commit f763e96 into microsoft:main Feb 24, 2025
22 of 23 checks passed
Copy link

👋 Hi! It looks like you modified some files in the Detectors folder.
You may need to bump the detector versions if any of the following scenarios apply:

  • The detector detects more or fewer components than before
  • The detector generates different parent/child graph relationships than before
  • The detector generates different devDependencies values than before

If none of the above scenarios apply, feel free to ignore this comment 🙂

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.

3 participants