Add --lint to validate a project without building - #23
Conversation
--lint loads the build-info and checks it without invoking pkgbuild, for a fast PR/CI pre-check. Errors (empty version, name that isn't a single path component, project with neither payload nor scripts, undecodable build-info) exit non-zero; warnings (non-reverse-DNS identifier, name not ending .pkg, notarization without signing, script missing a shebang or exec bit) are advisory. Findings go to stderr; the exit code is the machine signal. Tests: LinterTests cover clean, error, and warning cases. verify-loop.sh lints a good project (passes) and a bad one (must fail).
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdds a non-building linter for Swift package projects, exposes it through a new ChangesPackage linting
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CLIParser
participant CLICommand
participant SwiftPkg
participant Linter
CLIParser->>CLICommand: resolve --lint options
CLICommand->>SwiftPkg: dispatch lint command
SwiftPkg->>Linter: lint project
Linter-->>SwiftPkg: return findings
SwiftPkg-->>CLIParser: print results and return exit status
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai full review |
✅ Action performedFull review finished. Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 57 minutes. |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@swiftpkg/Linter.swift`:
- Around line 45-49: The identifier validation in Linter.swift around the
configuration identifier checks must validate every dot-separated component,
emitting the existing style warning for leading, repeated, or trailing dots as
well as identifiers without a dot. Add regression cases in
swiftpkgTests/LinterTests.swift covering leading-, repeated-, and trailing-dot
identifiers at lines 38-46.
- Around line 85-91: Update the install-script validation around
fileManager.fileExists(atPath:) to detect when script.path refers to a
directory, emit an error finding, and reject it before the shebang and
executable-permission checks. Preserve the existing checks for valid script
files.
In `@swiftpkgTests/LinterTests.swift`:
- Around line 65-77: Update the warnsOnBadScript test’s makeProject call to use
addPayload: false, creating a payload-free project with install scripts. Keep
the existing shebang and executable warning assertions, and additionally assert
that every finding has warning severity so the scripts-only compatibility path
does not report an error.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cbe73391-1b3f-43e1-9385-fa5d2cae4bb5
📒 Files selected for processing (5)
scripts/verify-loop.shswiftpkg/Linter.swiftswiftpkgCLI/CLI.swiftswiftpkgCLI/SwiftPkg.swiftswiftpkgTests/LinterTests.swift
…ories The reverse-DNS check only tested for a dot, so ".example", "com..example", and "com.example." passed; it now requires at least two non-empty dot-separated components. lintScripts used fileExists, which also matches a directory, letting a preinstall/postinstall directory skip the shebang check and pass the executable-bit check; it now errors on a directory. Added regression tests plus a scripts-only compatibility case.
|
All three addressed in the latest commit: reverse-DNS validation now requires ≥2 non-empty dot-separated components (rejecting |
warnsOnBadScript kept the default payload, so it proved the script findings appear but not that they appear alone. A payload-free project with scripts is supported, and nothing asserted that such a project escapes the "neither a payload nor a non-empty scripts directory" error while still reporting the shebang and permission warnings. Drop the payload from that test and require every finding to be a warning. Also cover the boundary the hasScripts check draws: a scripts directory holding nothing but .DS_Store is not a scripts directory, and a project with only that is still empty.
|
Addressed. Added one more while in there: a scripts directory holding nothing but Suite green (31 tests) and |
--lintchecks a project's build-info and layout — identifier style, name safety, notarization-without-signing, missing payload/scripts, non-executable scripts without a shebang — and reports findings without running a build.Note: this PR intentionally does not warn on a missing
.pkgextension. The companion "munki-pkg drop-in compatibility" PR normalizes the resolved name to end in.pkg, so such a warning would be redundant. If that PR isn't merged, the only effect is the absence of that one advisory warning.Tests:
LinterTests; full suite green (26 tests).Part of a 9-PR series splitting a batch of features into small, themed, independently reviewable PRs. Each applies cleanly to
mainon its own; the ordering below only minimizes rebases as they land:Happy to squash, split, or reorder any of these to suit your review preferences.
Summary by CodeRabbit
New Features
--lintcommand to validate package projects without building them.Tests