-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (72 loc) · 2.68 KB
/
linting.yml
File metadata and controls
76 lines (72 loc) · 2.68 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Linting
on:
pull_request:
# Running on main ensures a cache is available for PRs to reuse
push:
branches:
- main
# GitHub Action cannot handle this if this workflow is required
# paths:
# - '.github/workflows/linting.yml'
# - '.swiftformat'
# - '.swiftlint.yml'
# - '**/*.swift'
jobs:
SwiftLint:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Read version from Mintfile
run: echo "SWIFTLINT_VERSION=$(awk '/SwiftLint/ {split($0, a, "@"); print a[2]}' Mintfile)" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
path: .build/release/swiftlint
key: ${{ runner.os }}-linting-swiftlint-${{ env.SWIFTLINT_VERSION }}
- name: Build realm/SwiftLint
run: |
if [ -f ".build/release/swiftlint" ]; then
sudo cp -f .build/release/swiftlint /usr/local/bin/swiftlint
else
git clone --depth 1 --branch ${{ env.SWIFTLINT_VERSION }} https://github.com/realm/SwiftLint
cd SwiftLint
swift build --disable-sandbox -c release
mv .build .. && cd ..
rm -rf SwiftLint
sudo cp -f .build/release/swiftlint /usr/local/bin/swiftlint
fi
- name: SwiftLint
run: |
swiftlint --version
swiftlint lint --strict --config .swiftlint.yml --quiet
env:
LINUX_SOURCEKIT_LIB_PATH: /usr/share/swift/usr/lib # FIXED: Fatal error: Loading libsourcekitdInProc.so failed
SwiftFormat:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Read version from Mintfile
run: echo "SWIFTFORMAT_VERSION=$(awk '/SwiftFormat/ {split($0, a, "@"); print a[2]}' Mintfile)" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
path: .build/release/swiftformat
key: ${{ runner.os }}-linting-swiftformat-${{ env.SWIFTFORMAT_VERSION }}
- name: Build nicklockwood/SwiftFormat
run: |
if [ -f ".build/release/swiftformat" ]; then
if ! [ -x "$(command -v swift-format)" ]; then
sudo cp -f .build/release/swiftformat /usr/local/bin/swiftformat
fi
else
git clone --depth 1 --branch ${{ env.SWIFTFORMAT_VERSION }} https://github.com/nicklockwood/SwiftFormat
cd SwiftFormat
swift build --disable-sandbox -c release
mv .build .. && cd ..
rm -rf SwiftFormat
sudo cp -f .build/release/swiftformat /usr/local/bin/swiftformat
fi
- name: SwiftFormat
run: |
swiftformat --version
swiftformat . --config .swiftformat --lint