Automattic / Automattic/dangermattic

Add rule to detect Swift packages that point to branches

Open
#85 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
10
Forks
2
PR merge metrics
No merged PRs in 30d

Description

As a non documented rule, we don't want to merge PRs with Swift packages (or any other dependency fetched via a manager) that point to branches. Branches can, and usually are, deleted after their PR lands on the main branch, which would result in a failed dependency resolution.

I'm guessing the implementation should be straightforward™. Similar to [what we do for CocoaPods](https://github.com/Automattic/dangermattic/blob/f7fe744847b4f917b48949b1bbe4a966716479ac/lib/dangermattic/plugins/podfile_checker.rb#L54-L74): Parse the `Package.resolved` JSON; for each dependency, ensure it points to a tag, commit, or project-relative path.

One thing I'm unsure about is how to determine which `Package.resolved` to look at. We should either defer to the caller explicitly passing a path (not the best DX) or implement (duplicate 😭... or is it worth extracting somehow?) [the logic from the CI toolkit](https://github.com/Automattic/a8c-ci-toolkit-buildkite-plugin/blob/e05b61bd2bba9ea507c5185e576ef97578903b38/bin/install_swiftpm_dependencies).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with lib/dangermattic/plugins/podfile_checker.rb, especially the linked dependency-checking logic, then inspect the CI toolkit's bin/install_swiftpm_dependencies entry point. Review the Package.resolved JSON shape and determine how its path should be selected. Done means the rule rejects branch-based dependencies while allowing tags, commits, and project-relative paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby, swift
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.