Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Run Apple lint locally and in CI

Manav Rathi46c32fedd013
diff --git a/.github/scripts/ci/paths.json b/.github/scripts/ci/paths.json
index 533dfda147..f64b64ed08 100644
--- a/.github/scripts/ci/paths.json
+++ b/.github/scripts/ci/paths.json
@@ -1,4 +1,5 @@
{
+ "apple-lint": [".github/workflows/apple-lint.yml", "apple/**"],
"dependency-review": [
"**/Cargo.lock",
"**/Cargo.toml",
diff --git a/.github/workflows/apple-lint.yml b/.github/workflows/apple-lint.yml
new file mode 100644
index 0000000000..1361c9ca0e
--- /dev/null
+++ b/.github/workflows/apple-lint.yml
@@ -0,0 +1,16 @@
+name: "Lint (Apple)"
+
+on:
+ workflow_call:
+
+permissions:
+ contents: read
+
+jobs:
+ lint:
+ runs-on: macos-latest
+ steps:
+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
+ with:
+ persist-credentials: false
+ - run: apple/scripts/lint.sh
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ab809d8cb3..b744fc9f93 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -24,6 +24,11 @@ jobs:
- id: select
run: node .github/scripts/ci/check.mjs select HEAD^1 HEAD
+ apple-lint:
+ needs: select
+ if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'apple-lint') }}
+ uses: ./.github/workflows/apple-lint.yml
+
dependency-review:
needs: select
if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'dependency-review') }}
@@ -99,6 +104,7 @@ jobs:
if: ${{ always() }}
needs:
- select
+ - apple-lint
- dependency-review
- desktop-lint
- docs-verify-build
diff --git a/apple/.swiftlint.yml b/apple/.swiftlint.yml
index 30c85abcbd..b814018b52 100644
--- a/apple/.swiftlint.yml
+++ b/apple/.swiftlint.yml
@@ -8,11 +8,14 @@ only_rules:
- identical_operands
- duplicate_conditions
- unused_setter_value
+ - empty_count
- blanket_disable_command
- superfluous_disable_command
+empty_count:
+ only_after_dot: true
+
excluded:
+ - apps/ensu # TODO: Include Ensu.
- apps/cast/Cast/Generated/cast.swift
-
-allow_zero_lintable_files: false
-strict: true
+ - .build
diff --git a/apple/scripts/Package.resolved b/apple/Package.resolved
similarity index 100%
rename from apple/scripts/Package.resolved
rename to apple/Package.resolved
diff --git a/apple/scripts/Package.swift b/apple/Package.swift
similarity index 100%
rename from apple/scripts/Package.swift
rename to apple/Package.swift
diff --git a/apple/packages/EnteOnnxRuntime/Package.swift b/apple/packages/EnteOnnxRuntime/Package.swift
index eb43259178..e2f11f63d4 100644
--- a/apple/packages/EnteOnnxRuntime/Package.swift
+++ b/apple/packages/EnteOnnxRuntime/Package.swift
@@ -18,7 +18,8 @@ let package = Package(
targets: [
.binaryTarget(
name: "onnxruntime",
- url: "https://github.com/ente/ort-packaging/releases/download/ort-1.28.1-r1/onnxruntime-coreml-ios-1.28.1-r1.zip",
+ url:
+ "https://github.com/ente/ort-packaging/releases/download/ort-1.28.1-r1/onnxruntime-coreml-ios-1.28.1-r1.zip",
checksum: "774b986bdd8a9f729a3e80ce7f7e7e695f0387be6f66633feaa9835c05e8557e"
)
]
diff --git a/apple/scripts/lint.sh b/apple/scripts/lint.sh
new file mode 100755
index 0000000000..82316a7bef
--- /dev/null
+++ b/apple/scripts/lint.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+set -eo pipefail
+
+cd "$(dirname "$0")/.."
+
+# TODO: Include Ensu.
+git ls-files -z --cached --others --exclude-standard -- '*.swift' ':!:apps/ensu/**' |
+ xargs -0 swift format lint --strict
+swift package plugin --allow-writing-to-package-directory swiftlint lint --strict