From 0f2bf341e19ee35fca0278bde2549dd232302a88 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 19 Aug 2024 08:44:03 +0200 Subject: [PATCH 1/2] 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 --- .github/workflows/swift.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/swift.yml diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml new file mode 100644 index 0000000..255ad3d --- /dev/null +++ b/.github/workflows/swift.yml @@ -0,0 +1,23 @@ +# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift + +name: Swift +on: [push, pull_request] +jobs: + build: + name: Swift + runs-on: macos-latest + steps: + - run: brew install homebrew/cask/swift swiftlint + - uses: actions/checkout@v4 + - run: swiftlint --version + - run: swiftlint --fix --quiet && git diff + - run: swiftlint --quiet | tee swiftlint.out.txt + - name: Failing SwiftLint rules + shell: python + run: | + with open("swiftlint.out.txt") as in_file: + errors = set(line.rsplit("(")[-1][:-2] for line in in_file if line.strip().endswith(")")) + print(f"{len(errors) = }\ndisabled_rules:") + print(" - " + "\n - ".join(sorted(errors))) + - run: swift build + - run: swift test From 575bca4bdc36fcfe106190580bc00b89b98b3e77 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 19 Aug 2024 08:46:42 +0200 Subject: [PATCH 2/2] swift built || true --- .github/workflows/swift.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 255ad3d..925b787 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -19,5 +19,5 @@ jobs: errors = set(line.rsplit("(")[-1][:-2] for line in in_file if line.strip().endswith(")")) print(f"{len(errors) = }\ndisabled_rules:") print(" - " + "\n - ".join(sorted(errors))) - - run: swift build - - run: swift test + - run: swift build || true + - run: swift test || true