Repository navigation
[FSSDK-13498] ci: run SwiftLint on Sources - #674
Muzahidul Islam (muzahidul-opti) wants to merge 4 commits into
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Alex Yong (alexjoeyyong)
left a comment
There was a problem hiding this comment.
Verdict: comment. Two should-fixes, no blockers. The idea is right (CONTRIBUTING.md says SwiftLint must pass, and nothing enforced it), and the scope is sensible.
CI at 338c23d: the new swiftlint job passes, along with both Xcode builds, api_breaking_changes, the tvOS tests, markdown lint and the integration tests. Pending when I looked: the iPhone 17 and iPad Pro unit tests and the compat suite. I'm not waiting on them.
Checked myself: .swiftlint.yml sits at the repo root, so swiftlint Sources picks it up from the working directory (same config the DemoSwiftApp build phase passes explicitly). The pinned asset exists: portable_swiftlint.zip for 0.65.1 is 11.9 MB. I read the code and the workflow; I didn't run SwiftLint myself.
Good: persist-credentials: false, a pinned tool version, a 10-minute timeout, and no curl | bash (the shape #673 just removed). The two suppressions are narrow disable:next lines, not file-wide.
Should-fix
- The downloaded binary is executed without an integrity check (
swift.yml, Download SwiftLint step). A pinned version stops drift but not a swapped or corrupted asset, and this runs an unverified executable in CI. GitHub publishes the digest for this asset (sha256:c1e429b0599cf1b516f369a2d9ec04eaf0e436f3c12b637df8851fa52ff694d0). Fix: after thecurl, addecho "c1e429b0… swiftlint.zip" | shasum -a 256 -c -(full hash from the release), and update it when you bump the version. - The job isn't a required check, so it enforces nothing yet.
master's required checks are the builds, the unit tests and the compat suite, with strict mode on, andswiftlintis not among them. The PR says no CI job enforced SwiftLint; after this merges a failingswiftlintjob is still mergeable. Someone with admin rights has to add it to branch protection. Please note that in the PR so it isn't forgotten.
Ponytail (over-engineering)
swift.yml L33-38 (Cache SwiftLint) + theif:on the download step: delete.It caches a 12 MB download that takes seconds on a runner and adds a cache key to keep in sync with the version. Keep it only if the download was actually flaky (the last commit message mentions caching, so ask).swift.yml L24-26: shrink, optionally: runs-on: macos-15 for a lint job.macOS minutes cost several times Linux.swiftlint_linux_amd64.zipis a static binary forubuntu-latest(67 MB, so keep the cache if you switch). Only worth it if the macOS queue is a bottleneck. I haven't checked that the 61 existing warnings are identical on Linux.swift.yml L44: native: add --reporter github-actions-logging.The 61 warnings currently only exist in a log nobody opens. This native reporter turns new ones into annotations on the diff for one flag and no extra step.- The two
swiftlint:disable:nextlines are the cheapest honest way to clear two errors in a PR that isn't a refactor. Keep.
net: -7 lines possible (the cache step), plus one flag.
Nits
- The
type_namejustification is probably off. The PR says renaming_ObjcOPTEventDispatcher"could break the ObjC bridge", but the protocol is declared@objc(OPTEventDispatcher), which fixes the Objective-C name regardless of the Swift name. The real reason to keep it is that it's apublicSwift protocol, so a rename breaks source compatibility (theapi_breaking_changesjob). Say that in the PR. - Version drift. CI pins 0.65.1; CONTRIBUTING.md tells contributors to
brew install swiftlint, which installs whatever is current. A newer local SwiftLint can disagree with CI. Mention the pinned version in CONTRIBUTING.md, or accept the occasional mismatch. - With 61 warnings tolerated, new warnings won't fail anything. That is a fair first step; consider a follow-up that pays them down and then adds
--strict.
…nings - Verify the downloaded SwiftLint zip against its pinned sha256 - Remove the cache step; the download is small and now always verified - Use the github-actions-logging reporter so warnings annotate the diff - Note in CONTRIBUTING.md that CI pins SwiftLint 0.65.1 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Use the pinned static Linux binary (sha256-verified) instead of the macOS portable build; Linux reports the same 61 warnings and 0 errors on Sources. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks Alex Yong (@alexjoeyyong), all addressed in Should-fix
Over-engineering
Nits
|
Summary
swiftlintjob toswift.ymlthat runsswiftlint Sourcesonubuntu-latest. Errors fail the job; warnings are reported but do not. SwiftLint is pinned to 0.65.1 (static Linux binary) and the downloaded zip is verified against a pinned sha256.github-actions-loggingreporter, so they show as annotations on the PR diff.swiftlint:disable:nextfor the two remaining errors inSources:type_body_lengthonDefaultDecisionServiceandtype_nameon_ObjcOPTEventDispatcher(it is apublicSwift protocol, so renaming it breaks source compatibility and would failapi_breaking_changes).CONTRIBUTING.md and the constitution require SwiftLint to pass, but no CI job enforced it. Scope is
Sourcesonly, matching the DemoSwiftApp build phase.mastercurrently has 61 SwiftLint warnings inSources; they are not fixed here and do not fail the job.Follow-ups
--strict.Test plan
swiftlint Sources --reporter github-actions-logginglocally on macOS (0.65.1): 0 errors, 61 warnings, exit code 0.linux/amd64, in anubuntu:24.04container) onSources: 61 violations, 0 serious, same as macOS.swiftlint_linux_amd64.zipand the digest GitHub publishes for the 0.65.1 release.swiftlintonmasterreported 3 errors (2 inSources, 1 inDemoSwiftApp).swiftlintjob passes on this PR.Issues
🤖 Generated with Claude Code