~ knotless Search/
↑↓ move↵ open⇧↵ all results

grain.social/grain-ios

1 collaborator
0
1

Pulls check formatting and SwiftLint on the runner

Merged
Merged chadtmiller.com asked to merge into main from grain.social/grain-ios:ci/workflows
1 reviewer 1 asked for changes

What changes

format.yml runs swiftformat Grain GrainTests --lint with the repository's .swiftformat, as just format does, with SwiftFormat 0.62.1.

lint.yml runs swiftlint lint Grain GrainTests with .swiftlint.yml, as just lint does, with SwiftLint 0.65.1. Errors fail it; warnings are reported and pass, as locally.

Both run on pushes to main and on pulls into it, on runner.knotless.dev, in debian:trixie-slim with each tool's Linux release, pinned by version and SHA-256 and kept in the run cache.

Why

Pulls here had no checks but the GitHub mirror. The runner is Linux in Docker, so formatting and lint are what it can check.

The build and the tests need a macOS runner with Xcode, and are not run anywhere on knotless. xcodebuild runs on macOS alone.

The tools' own images (ghcr.io/nicklockwood/swiftformat, ghcr.io/realm/swiftlint) do not work on the runner: each sets the tool as its entrypoint, and the runner starts every image with tail -f /dev/null to run its steps in, so the container never starts. SwiftLint's release has two binaries; swiftlint-static is the one that runs on a bare Debian (swiftlint wants libxml2 and the Swift runtime).

SwiftFormat is pinned at 0.62.1, the version the code is formatted with. 0.64.5, the newest, fails main with rules it added since (repeatedGuard, nestedIf, extensionAttributes, and some sortImports and indent). A bump here should come with just format-fix run on that version.

How it was checked

Only on the runner. At this head: format passes in 26s, 0 of 253 files needing formatting; lint passes in 14s with 1 warning (legacy_swiftui_aspect_ratio at NotificationsView.swift:464) and no errors.

Shortcomings

No build and no tests, as above. SwiftLint without Xcode cannot run analyzer rules, though .swiftlint.yml enables none. Anyone formatting locally with a Homebrew SwiftFormat newer than 0.62.1 will make changes this check does not ask for, and the reverse.

🤖 Generated with Claude Code

chadtmiller.com added 1 commit
Approved

This adds two workflows, format.yml and lint.yml. They run swiftformat Grain GrainTests --lint and swiftlint lint Grain GrainTests in pinned upstream images, on pushes to main and on pulls into main. The commands match the format and lint recipes in the justfile (lines 112 and 120), and the triggers and pins look fine.

I couldn't confirm the workflows run. Both checks for this commit were still queued when I looked, so there are no results or logs. Before merging, check that both go green. In particular, check that the two images start with a shell, since the run step needs sh, and that the swiftformat --version and swiftlint version calls work.

The PR body already says a SwiftFormat version mismatch can flag files formatted locally with an older version. Beyond that, I found nothing that needs changing.

chadtmiller.com added 1 commit
Asked for changes

The first round's checks failed because the images' entrypoints conflicted with the runner. This commit switches both workflows to debian:trixie-slim. They now download the pinned release, check its SHA-256, and cache it under /opt/.... That fixes the cause of the earlier failures, but I can't confirm it works yet. Both checks for 0e70193 are still queued, so there are no logs.

Please change these:

  • The PR description is out of date. It says the workflows run "in SwiftFormat's own image" and "SwiftLint's own image". They now use debian:trixie-slim with downloaded release zips. Update the "What changes" section. The "Shortcomings" section should say that the downloads come from GitHub and that the checksums are pinned.
  • lint.yml still has what looks like a debug ls -la /opt/swiftlint (line 31). lint.yml also assumes the zip puts a binary named swiftlint at its top level. format.yml locates its binary with find, but lint.yml doesn't. If the zip ships swiftlint-static, or a dynamically linked swiftlint that needs the Swift runtime libraries, the lint step will fail on trixie-slim. Resolve the binary the way format.yml does, and make sure the one you pick runs without a Swift toolchain.

Once both checks pass, this should be ready to merge.

.knotless/workflows/lint.ymllines 30 to 32Outdated
unzip -q /tmp/swiftlint.zip -d /opt/swiftlint
ls -la /opt/swiftlint
echo "$SWIFTLINT_VERSION" > /opt/swiftlint/.version
review.knotless.dev

Remove the debug ls -la. Also confirm the zip really holds a runnable /opt/swiftlint/swiftlint. The lint step at line 37 relies on that name and path. format.yml finds its binary instead of assuming a name.

Asked for changes

This commit pins SwiftFormat to 0.62.1, the version the code is formatted with. That is a sensible fix, since 0.64.5 would flag main. My round-2 requests are still open, and both checks for 09a269e are still queued, so there are no logs.

  • lint.yml still has the debug ls -la /opt/swiftlint. Remove it. The lint step also still assumes the zip holds a runnable /opt/swiftlint/swiftlint. format.yml finds its binary instead of assuming a name. Do the same here, or confirm from a passing lint run that the name and path are right.
  • The PR description is still out of date. It says the workflows run in each tool's own image, and it pins SwiftFormat at 0.64.5. Both are wrong now. The workflows use debian:trixie-slim with release zips downloaded from GitHub and checked against pinned SHA-256s. SwiftFormat is 0.62.1, and the reason is that 0.64.5 adds rules that main fails. Update "What changes" and "Shortcomings" to say so.

Once both checks pass and these are fixed, this is ready to merge.

.knotless/workflows/lint.ymlline 31Outdated
curl -fsSL -o /tmp/swiftlint.zip "https://github.com/realm/SwiftLint/releases/download/$SWIFTLINT_VERSION/swiftlint_linux_amd64.zip"
echo "$SWIFTLINT_SHA256 /tmp/swiftlint.zip" | sha256sum -c -
unzip -q /tmp/swiftlint.zip -d /opt/swiftlint
ls -la /opt/swiftlint
review.knotless.dev

Still here: remove the debug ls -la, and locate the binary with find as format.yml does rather than assuming /opt/swiftlint/swiftlint.

Asked for changes

The debug ls -la is gone, and lint.yml now runs the swiftlint-static binary, which suits a bare Debian image. That fixes the workflow items I raised. The PR description is still unchanged, and I've now asked for that update twice.

  • PR description is out of date. It says both tools run in their own images and that SwiftFormat is pinned at 0.64.5. Neither is true now:
    • Both workflows use debian:trixie-slim and download release zips from GitHub, checked against pinned SHA-256s.
    • SwiftFormat is 0.62.1, because 0.64.5 adds rules that main fails.
    • SwiftLint uses swiftlint-static.
    • The "Shortcomings" line about versions being newer than local installs no longer matches.
    • Please update "What changes" and "Shortcomings" with edit_item.
  • Checks have not run. Both checks for e298601 are still queued, so I can't confirm the workflows work. lint.yml assumes the zip has swiftlint-static at its top level. Before merging, check that both go green, or fall back to find for that name if lint can't find the binary.

Once the description is accurate and both checks pass, this is ready to merge.

.knotless/workflows/lint.ymllines 38 to 39
/opt/swiftlint/swiftlint-static version
/opt/swiftlint/swiftlint-static lint Grain GrainTests
review.knotless.dev

This relies on swiftlint-static sitting at the top level of the zip. The checks haven't run, so that is unconfirmed. If lint fails with "not found", locate the binary with find as format.yml does.

The description is updated: debian:trixie-slim with each tool's release zip from GitHub, checked against a pinned SHA-256; SwiftFormat 0.62.1 and why; swiftlint-static and why. Both checks pass at e298601: format in 26s (0/253 files need formatting), lint in 14s (1 warning, 0 serious), so swiftlint-static is at the zip's top level as the step expects, and it runs without a Swift toolchain. The zip holds swiftlint and swiftlint-static by those names, so a find would add nothing.

Merged as e298601