Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/buildandtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ jobs:
clang --version
clang-format --version

- name: Install Swiftly
run: |
SWIFTLY_FILE="swiftly-$(uname -m).tar.gz"
curl -sL https://download.swift.org/swiftly/linux/swiftly-x86_64.tar.gz -o $SWIFTLY_FILE
tar zxf $SWIFTLY_FILE

./swiftly init --quiet-shell-followup
. "${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}/env.sh"
hash -r
sudo apt-get -y install libcurl4-openssl-dev
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swiftly recommends this package install when installing swift


- name: Lint
run: yarn lint

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@ node_modules.bak
# Sentry React Native Monorepo
/packages/core/README.md
.env.sentry-build-plugin

# SwiftLint
swiftlint/*
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"clean": "lerna run clean",
"circularDepCheck": "lerna run circularDepCheck",
"test": "lerna run test",
"fix": "run-s fix:lerna fix:android fix:kotlin fix:clang",
"fix": "run-s fix:lerna fix:android fix:kotlin fix:clang fix:swift",
"fix:lerna": "lerna run fix",
"fix:android": "run-s 'java:format fix' java:pmd",
"fix:clang": "run-s 'clang:format fix'",
"fix:swift": "run-s 'swift:lint fix'",
"fix:kotlin": "npx ktlint --relative --format '!**/node_modules/**'",
"lint": "run-s lint:lerna lint:android lint:kotlin lint:clang",
"lint": "run-s lint:lerna lint:android lint:kotlin lint:clang lint:swift ",
"lint:lerna": "lerna run lint",
"lint:android": "run-s 'java:format lint' java:pmd",
"lint:clang": "run-s 'clang:format lint'",
Expand All @@ -28,7 +28,6 @@
"set-version-samples": "lerna run set-version"
},
"devDependencies": {
"@expo/swiftlint": "^0.57.1",
"@naturalcycles/ktlint": "^1.13.0",
"@sentry/cli": "2.55.0",
"downlevel-dts": "^0.11.0",
Expand Down
50 changes: 46 additions & 4 deletions scripts/swiftlint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,57 @@ fi
# Set the mode based on the first argument
mode=$1

DARWIN_PATH="$(dirname "$0")/../node_modules/@expo/swiftlint/bin/darwin-arm64/swiftlint"
LINUX_PATH="$(dirname "$0")/../node_modules/@expo/swiftlint/bin/linux-x64/swiftlint"
SWIFT_PATH=$(which swift 2>/dev/null || true)

if [ -z "$SWIFT_PATH" ]; then
echo "SwiftLint requires swift, which is not installed or not found in PATH"
echo "To install Swift:"
echo " * ubuntu: follow steps here: https://www.swift.org/install/"
echo " * arch: yay -S swift-bin"
exit 1
fi

LINUX_BIN="https://github.com/realm/SwiftLint/releases/download/0.61.0/swiftlint_linux_amd64.zip"
LINUX_SHA="sha256:02f4f580bbb27fb618dbfa24ce2f14c926461c85c26941289f58340151b63ae4"
DARWIN_BIN="https://github.com/realm/SwiftLint/releases/download/0.61.0/portable_swiftlint.zip"
DARWIN_SHA="sha256:2342f3784307a02117e18f745fcd350c6acc6cab0e521c0c0e01c32a53a3b274"

if [[ "$OSTYPE" == "darwin"* ]]; then
CMD="$DARWIN_PATH"
EXPECTED_SHA="$DARWIN_SHA"
EXPECTED_BIN="$DARWIN_BIN"
else
CMD="$LINUX_PATH"
EXPECTED_SHA="$LINUX_SHA"
EXPECTED_BIN="$LINUX_BIN"
fi

# Make ../swiftlint folder if it doesn't exist
SWIFTLINT_DIR="$(dirname "$0")/../swiftlint"
mkdir -p "$SWIFTLINT_DIR"

# Skip download if sha256sum swiftlint.sha matches EXPECTED_SHA
SHA_FILE="$SWIFTLINT_DIR/swiftlint.sha"
if [ -f "$SHA_FILE" ] && [ "$(cat "$SHA_FILE")" = "$EXPECTED_SHA" ]; then
echo "SwiftLint already downloaded and verified."
else
echo "Clearing swiftlint folder..."
rm -rf "$SWIFTLINT_DIR"/*

echo "Downloading SwiftLint..."
curl -L "$EXPECTED_BIN" -o "$SWIFTLINT_DIR/swiftlint.zip"
unzip "$SWIFTLINT_DIR/swiftlint.zip" -d "$SWIFTLINT_DIR"
# Save sha256sum of swiftlint.zip to ../swiftlint/swiftlint.sha
echo "$EXPECTED_SHA" > "$SHA_FILE"
# Remove swiftlint.zip
rm "$SWIFTLINT_DIR/swiftlint.zip"
fi

if [ ! -f "$SHA_FILE" ] || [ "$(cat "$SHA_FILE")" != "$EXPECTED_SHA" ]; then
echo "Invalid SwiftLint, sha doesn't match the expected download."
exit 1
fi

CMD="$(dirname "$0")/../swiftlint/swiftlint"

if [ "$mode" = "fix" ]; then
$CMD --fix
elif [ "$mode" = "lint" ]; then
Expand Down
10 changes: 0 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5916,15 +5916,6 @@ __metadata:
languageName: node
linkType: hard

"@expo/swiftlint@npm:^0.57.1":
version: 0.57.1
resolution: "@expo/swiftlint@npm:0.57.1"
dependencies:
"@expo/spawn-async": ^1.5.0
checksum: 87f744bb45cc3a4aa2a40424d21995547c138eef4d4918a3990859c9f143acd3ce463ff3f0c421c0b3e95a694abf7d8fcb8c8545dbe00d81767fc461a68c8378
languageName: node
linkType: hard

"@expo/vector-icons@npm:^14.0.0":
version: 14.0.2
resolution: "@expo/vector-icons@npm:14.0.2"
Expand Down Expand Up @@ -28327,7 +28318,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "sentry-react-native@workspace:."
dependencies:
"@expo/swiftlint": ^0.57.1
"@naturalcycles/ktlint": ^1.13.0
"@sentry/cli": 2.55.0
downlevel-dts: ^0.11.0
Expand Down
Loading