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

grain.social/grain-ios

1 collaborator
0
1

Pulls check formatting and SwiftLint on the runner

Merged chadtmiller.com asked to merge into main from grain.social/grain-ios:ci/workflows
.knotless/workflows/format.ymlnew+45−0
@@ -0,0 +1,45 @@
# Formatting, as `just format` checks it: `swiftformat --lint` over Grain
# and GrainTests with the repository's .swiftformat, on pushes to main and
# pulls into it. It lists each file it would change and fails if there is
# one; `just format-fix` changes them.
#
# The build and the tests are not here, nor anything else that needs Xcode:
# the runner is Linux, and xcodebuild runs on macOS alone. SwiftFormat and
# SwiftLint (lint.yml) are what has a Linux build.
#
# SwiftFormat is its Linux release, pinned by version and SHA-256, so a
# release's new rules land on purpose rather than with an unrelated push.
# 0.62.1 is the version the code is formatted with: 0.64.5 adds rules
# (repeatedGuard, nestedIf, extensionAttributes) that main does not pass,
# and a bump here comes with `just format-fix` run on that version.
# Its own image will not do: the runner starts the image with
# `tail -f /dev/null` to run each step in, and the image's entrypoint is
# swiftformat. The download is kept between runs.
image: debian:trixie-slim
on:
push: { refs: [refs/heads/main] }
pull: { base: [refs/heads/main] }
cache: [/opt/swiftformat]
env:
SWIFTFORMAT_VERSION: 0.62.1
SWIFTFORMAT_SHA256: 61ff55f3581e2144a4ad114831167102c38be853df75c1477d20b40a8e8120aa
steps:
- name: swiftformat
timeout: 10
run: |
if [ "$(cat /opt/swiftformat/.version 2>/dev/null)" != "$SWIFTFORMAT_VERSION" ]; then
apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends ca-certificates curl unzip >/dev/null
find /opt/swiftformat -mindepth 1 -delete
curl -fsSL -o /tmp/swiftformat.zip "https://github.com/nicklockwood/SwiftFormat/releases/download/$SWIFTFORMAT_VERSION/swiftformat_linux.zip"
echo "$SWIFTFORMAT_SHA256 /tmp/swiftformat.zip" | sha256sum -c -
unzip -q /tmp/swiftformat.zip -d /opt/swiftformat
bin=$(find /opt/swiftformat -type f -name 'swiftformat*' ! -name '*.zip' | head -1)
chmod +x "$bin" && ln -sf "$bin" /opt/swiftformat/swiftformat-bin
echo "$SWIFTFORMAT_VERSION" > /opt/swiftformat/.version
fi
- name: format
timeout: 10
run: |
/opt/swiftformat/swiftformat-bin --version
/opt/swiftformat/swiftformat-bin Grain GrainTests --lint
.knotless/workflows/lint.ymlnew+39−0
@@ -0,0 +1,39 @@
# SwiftLint, as `just lint` runs it: over Grain and GrainTests with the
# repository's .swiftlint.yml, on pushes to main and pulls into it. An
# error fails the step; warnings are reported and pass, as they do locally.
#
# Xcode does not run on the Linux runner, so the build and the tests are
# not here: see format.yml.
#
# SwiftLint is its Linux release, pinned by version and SHA-256, so a
# release's new rules land on purpose rather than with an unrelated push.
# Its own image will not do, for format.yml's reason: its entrypoint is
# swiftlint. The release's `swiftlint-static` is the one that runs on a
# bare Debian: `swiftlint` wants libxml2 and the Swift runtime. The
# download is kept between runs.
image: debian:trixie-slim
on:
push: { refs: [refs/heads/main] }
pull: { base: [refs/heads/main] }
cache: [/opt/swiftlint]
env:
SWIFTLINT_VERSION: 0.65.1
SWIFTLINT_SHA256: caeed6f4a679c35539ffaf124f6c4ab4a8416917f7d8796279dc52b74026059d
steps:
- name: swiftlint
timeout: 10
run: |
if [ "$(cat /opt/swiftlint/.version 2>/dev/null)" != "$SWIFTLINT_VERSION" ]; then
apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends ca-certificates curl unzip >/dev/null
find /opt/swiftlint -mindepth 1 -delete
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
echo "$SWIFTLINT_VERSION" > /opt/swiftlint/.version
fi
- name: lint
timeout: 10
run: |
/opt/swiftlint/swiftlint-static version
/opt/swiftlint/swiftlint-static lint Grain GrainTests
.knotless/workflows/lint.ymllines 38 to 39

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.