Skip to content

Commit 9be0807

Browse files
lucas-zimermanantonis
authored andcommitted
Ref(internal) do not use npm swiftlint. (#5215)
1 parent dbfd7e1 commit 9be0807

File tree

5 files changed

+61
-15
lines changed

5 files changed

+61
-15
lines changed

.github/workflows/buildandtest.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ jobs:
4949
cache-dependency-path: yarn.lock
5050
- name: Install Dependencies
5151
run: yarn install
52+
53+
- name: Install Swiftly
54+
run: |
55+
SWIFTLY_FILE="swiftly-$(uname -m).tar.gz"
56+
curl -sL https://download.swift.org/swiftly/linux/swiftly-x86_64.tar.gz -o $SWIFTLY_FILE
57+
tar zxf $SWIFTLY_FILE
58+
59+
./swiftly init --quiet-shell-followup
60+
. "${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}/env.sh"
61+
hash -r
62+
sudo apt-get -y install libcurl4-openssl-dev
63+
5264
- name: Lint
5365
run: yarn lint
5466

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,6 @@ node_modules.bak
9191
# Sentry React Native Monorepo
9292
/packages/core/README.md
9393
.env.sentry-build-plugin
94+
95+
# SwiftLint
96+
swiftlint/*

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"set-version-samples": "lerna run set-version"
2929
},
3030
"devDependencies": {
31-
"@expo/swiftlint": "^0.57.1",
3231
"@naturalcycles/ktlint": "^1.13.0",
3332
"@sentry/cli": "2.53.0",
3433
"clang-format": "^1.8.0",

scripts/swiftlint.sh

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,57 @@ fi
1111
# Set the mode based on the first argument
1212
mode=$1
1313

14-
DARWIN_PATH="$(dirname "$0")/../node_modules/@expo/swiftlint/bin/darwin-arm64/swiftlint"
15-
LINUX_PATH="$(dirname "$0")/../node_modules/@expo/swiftlint/bin/linux-x64/swiftlint"
14+
SWIFT_PATH=$(which swift 2>/dev/null || true)
15+
16+
if [ -z "$SWIFT_PATH" ]; then
17+
echo "SwiftLint requires swift, which is not installed or not found in PATH"
18+
echo "To install Swift:"
19+
echo " * ubuntu: follow steps here: https://www.swift.org/install/"
20+
echo " * arch: yay -S swift-bin"
21+
exit 1
22+
fi
23+
24+
LINUX_BIN="https://github.com/realm/SwiftLint/releases/download/0.61.0/swiftlint_linux_amd64.zip"
25+
LINUX_SHA="sha256:02f4f580bbb27fb618dbfa24ce2f14c926461c85c26941289f58340151b63ae4"
26+
DARWIN_BIN="https://github.com/realm/SwiftLint/releases/download/0.61.0/portable_swiftlint.zip"
27+
DARWIN_SHA="sha256:2342f3784307a02117e18f745fcd350c6acc6cab0e521c0c0e01c32a53a3b274"
1628

1729
if [[ "$OSTYPE" == "darwin"* ]]; then
18-
CMD="$DARWIN_PATH"
30+
EXPECTED_SHA="$DARWIN_SHA"
31+
EXPECTED_BIN="$DARWIN_BIN"
1932
else
20-
CMD="$LINUX_PATH"
33+
EXPECTED_SHA="$LINUX_SHA"
34+
EXPECTED_BIN="$LINUX_BIN"
2135
fi
2236

37+
# Make ../swiftlint folder if it doesn't exist
38+
SWIFTLINT_DIR="$(dirname "$0")/../swiftlint"
39+
mkdir -p "$SWIFTLINT_DIR"
40+
41+
# Skip download if sha256sum swiftlint.sha matches EXPECTED_SHA
42+
SHA_FILE="$SWIFTLINT_DIR/swiftlint.sha"
43+
if [ -f "$SHA_FILE" ] && [ "$(cat "$SHA_FILE")" = "$EXPECTED_SHA" ]; then
44+
echo "SwiftLint already downloaded and verified."
45+
else
46+
echo "Clearing swiftlint folder..."
47+
rm -rf "$SWIFTLINT_DIR"/*
48+
49+
echo "Downloading SwiftLint..."
50+
curl -L "$EXPECTED_BIN" -o "$SWIFTLINT_DIR/swiftlint.zip"
51+
unzip "$SWIFTLINT_DIR/swiftlint.zip" -d "$SWIFTLINT_DIR"
52+
# Save sha256sum of swiftlint.zip to ../swiftlint/swiftlint.sha
53+
echo "$EXPECTED_SHA" > "$SHA_FILE"
54+
# Remove swiftlint.zip
55+
rm "$SWIFTLINT_DIR/swiftlint.zip"
56+
fi
57+
58+
if [ ! -f "$SHA_FILE" ] || [ "$(cat "$SHA_FILE")" != "$EXPECTED_SHA" ]; then
59+
echo "Invalid SwiftLint, sha doesn't match the expected download."
60+
exit 1
61+
fi
62+
63+
CMD="$(dirname "$0")/../swiftlint/swiftlint"
64+
2365
if [ "$mode" = "fix" ]; then
2466
$CMD --fix
2567
elif [ "$mode" = "lint" ]; then

yarn.lock

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5916,15 +5916,6 @@ __metadata:
59165916
languageName: node
59175917
linkType: hard
59185918

5919-
"@expo/swiftlint@npm:^0.57.1":
5920-
version: 0.57.1
5921-
resolution: "@expo/swiftlint@npm:0.57.1"
5922-
dependencies:
5923-
"@expo/spawn-async": ^1.5.0
5924-
checksum: 87f744bb45cc3a4aa2a40424d21995547c138eef4d4918a3990859c9f143acd3ce463ff3f0c421c0b3e95a694abf7d8fcb8c8545dbe00d81767fc461a68c8378
5925-
languageName: node
5926-
linkType: hard
5927-
59285919
"@expo/vector-icons@npm:^14.0.0":
59295920
version: 14.0.2
59305921
resolution: "@expo/vector-icons@npm:14.0.2"
@@ -27493,7 +27484,6 @@ __metadata:
2749327484
version: 0.0.0-use.local
2749427485
resolution: "sentry-react-native@workspace:."
2749527486
dependencies:
27496-
"@expo/swiftlint": ^0.57.1
2749727487
"@naturalcycles/ktlint": ^1.13.0
2749827488
"@sentry/cli": 2.53.0
2749927489
clang-format: ^1.8.0

0 commit comments

Comments
 (0)