Skip to content

Commit 0f2bf34

Browse files
authored
Add a GitHub Action to run swiftlint, swift build, and swift test
https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift
1 parent 2c9eb8b commit 0f2bf34

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.github/workflows/swift.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift
2+
3+
name: Swift
4+
on: [push, pull_request]
5+
jobs:
6+
build:
7+
name: Swift
8+
runs-on: macos-latest
9+
steps:
10+
- run: brew install homebrew/cask/swift swiftlint
11+
- uses: actions/checkout@v4
12+
- run: swiftlint --version
13+
- run: swiftlint --fix --quiet && git diff
14+
- run: swiftlint --quiet | tee swiftlint.out.txt
15+
- name: Failing SwiftLint rules
16+
shell: python
17+
run: |
18+
with open("swiftlint.out.txt") as in_file:
19+
errors = set(line.rsplit("(")[-1][:-2] for line in in_file if line.strip().endswith(")"))
20+
print(f"{len(errors) = }\ndisabled_rules:")
21+
print(" - " + "\n - ".join(sorted(errors)))
22+
- run: swift build
23+
- run: swift test

0 commit comments

Comments
 (0)