1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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