Skip to content

[FSSDK-13498] ci: run SwiftLint on Sources - #674

Open
Muzahidul Islam (muzahidul-opti) wants to merge 4 commits into
masterfrom
muzahidul/ci-swiftlint
Open

Muzahidul Islam (muzahidul-opti) wants to merge 4 commits into
masterfrom
muzahidul/ci-swiftlint

Conversation

@muzahidul-opti

@muzahidul-opti Muzahidul Islam (muzahidul-opti) commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Added a swiftlint job to swift.yml that runs swiftlint Sources on ubuntu-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.
  • Warnings are reported with the github-actions-logging reporter, so they show as annotations on the PR diff.
  • Added swiftlint:disable:next for the two remaining errors in Sources: type_body_length on DefaultDecisionService and type_name on _ObjcOPTEventDispatcher (it is a public Swift protocol, so renaming it breaks source compatibility and would fail api_breaking_changes).
  • CONTRIBUTING.md now notes that CI pins SwiftLint 0.65.1.

CONTRIBUTING.md and the constitution require SwiftLint to pass, but no CI job enforced it. Scope is Sources only, matching the DemoSwiftApp build phase. master currently has 61 SwiftLint warnings in Sources; they are not fixed here and do not fail the job.

Follow-ups

  • Pay down the 61 warnings, then add --strict.

Test plan

  • Ran swiftlint Sources --reporter github-actions-logging locally on macOS (0.65.1): 0 errors, 61 warnings, exit code 0.
  • Ran the pinned static Linux binary (linux/amd64, in an ubuntu:24.04 container) on Sources: 61 violations, 0 serious, same as macOS.
  • Checked the pinned sha256 against both the downloaded swiftlint_linux_amd64.zip and the digest GitHub publishes for the 0.65.1 release.
  • Before the change, swiftlint on master reported 3 errors (2 in Sources, 1 in DemoSwiftApp).
  • Verify the new swiftlint job passes on this PR.

Issues

  • FSSDK-13498

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@alexjoeyyong Alex Yong (alexjoeyyong) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

  1. 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 the curl, add echo "c1e429b0… swiftlint.zip" | shasum -a 256 -c - (full hash from the release), and update it when you bump the version.
  2. 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, and swiftlint is not among them. The PR says no CI job enforced SwiftLint; after this merges a failing swiftlint job 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) + the if: 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.zip is a static binary for ubuntu-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:next lines 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_name justification 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 a public Swift protocol, so a rename breaks source compatibility (the api_breaking_changes job). 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.

@coveralls

Coveralls (coveralls) commented Nov 25, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 93.964%. remained the same — muzahidul/ci-swiftlint into master

…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>
@datadog-optimizely-experimentation

datadog-optimizely-experimentation Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Pipelines

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c835214 | Docs | Give us feedback!

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>
@muzahidul-opti

Copy link
Copy Markdown
Contributor Author

Thanks Alex Yong (@alexjoeyyong), all addressed in e90c651 and c835214. CI is green.

Should-fix

  1. Integrity check: the download is now verified against a pinned sha256 (SWIFTLINT_SHA256, next to SWIFTLINT_VERSION). I checked the hash against both the zip I downloaded and the digest GitHub publishes for 0.65.1.
  2. Required check: swiftlint has been added to master branch protection.

Over-engineering

  • Cache: removed the cache step and the if: on the download step. The download was not flaky.
  • Linux: switched the job to ubuntu-latest with the static swiftlint-static binary. I ran it in an ubuntu:24.04 container on Sources: 61 violations, 0 serious, the same as macOS. I extract only the one binary, so the 67 MB zip is not unpacked in full.
  • Reporter: added --reporter github-actions-logging, so warnings now annotate the diff.

Nits

  • type_name: fixed the PR description. The real reason is that _ObjcOPTEventDispatcher is a public Swift protocol, so renaming it breaks source compatibility.
  • Version drift: CONTRIBUTING.md now says CI pins SwiftLint 0.65.1.
  • --strict: left for a follow-up that pays down the 61 warnings first.

This branch has not been deployed

No deployments
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