Skip to content

Commit

Permalink
Run swiftformat lint on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
dioKaratzas committed Dec 6, 2022
1 parent 17323cc commit 5620864
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 7 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ on:
branches: [ develop ]

jobs:
swiftformat:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Lint
run: ./scripts/runSwiftFormat.sh -l
macos:
needs: swiftformat
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -14,6 +21,7 @@ jobs:
- name: Tests
run: swift test -v
linux:
needs: swiftformat
runs-on: ubuntu-latest
container:
image: swift:5.5-bionic
Expand All @@ -22,4 +30,4 @@ jobs:
- name: Build
run: swift build -v
- name: Tests
run: swift test -v
run: swift test -v
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output

scripts/bin/*
45 changes: 41 additions & 4 deletions scripts/runSwiftFormat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,48 @@ SWIFT_VERSION=5.3

cd "$(dirname "$0")"

function downloadAndUnzip {
curl -L -o tool.zip $2
unzip -o -d $1/ tool.zip
rm tool.zip
}

if ! which swiftformat >/dev/null; then
echo "error: Swiftgen needs to be installed"
exit 1
if ! which bin/swiftformat >/dev/null; then
echo "warning: SwiftFormat not installed, installing..."

mkdir -p -- "bin"
cd bin
rm -r ./*

downloadAndUnzip "SwiftFormatTmp" "https://github.com/nicklockwood/SwiftFormat/releases/download/0.50.3/swiftformat.artifactbundle.zip"
mv -f ./SwiftFormatTmp/swiftformat.artifactbundle/swiftformat-0.50.3-macos/bin/swiftformat .
find . -name "*Tmp" -type d -prune -exec rm -rf '{}' +
for entry in ./*
do
chmod +x "$entry"
done
cd ../
fi

format() {
bin/swiftformat ../web3swift/src/ --config "swiftformat.yml" --swiftversion $SWIFT_VERSION
}

lint() {
bin/swiftformat --lint ../web3swift/src/ --config "swiftformat.yml" --swiftversion $SWIFT_VERSION
}

while getopts "fl" o; do
case "${o}" in
f)
format;
exit;;
l)
lint;
exit;;
*)
exit;;
esac
done

swiftformat ../web3swift/src/ --config "swiftformat.yml" --swiftversion $SWIFT_VERSION
format
2 changes: 1 addition & 1 deletion web3swift/src/Client/EthereumClient+Call.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private struct OffchainReadJSONBody: Encodable {
}

private struct OffchainReadResponse: Decodable {
@DataStr var data: Data
@DataStr var data: Data
}

private struct OffchainReadErrorResponse: Decodable {
Expand Down
2 changes: 1 addition & 1 deletion web3swift/src/ERC721/ERC721Responses.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public enum ERC721MetadataResponses {
public struct tokenURIResponse: ABIResponse, MulticallDecodableResponse {
public static var types: [ABIType.Type] = [URL.self]

@available(*, deprecated, renamed: "value") public var uri: URL { value }
@available(*, deprecated, renamed: "value") public var uri: URL { value }

public let value: URL

Expand Down

0 comments on commit 5620864

Please sign in to comment.