feat(ci): lint swift code
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
# Remove AI code slop
|
||||||
|
|
||||||
|
Check the diff against main, and remove all AI generated slop introduced in this branch.
|
||||||
|
|
||||||
|
This includes:
|
||||||
|
|
||||||
|
- Extra comments that a human wouldn't add or is inconsistent with the rest of the file
|
||||||
|
- Extra defensive checks or try/catch blocks that are abnormal for that area of the codebase (especially if called by trusted / validated codepaths)
|
||||||
|
- Casts to any to get around type issues
|
||||||
|
- Any other style that is inconsistent with the file
|
||||||
|
|
||||||
|
Report at the end with only a 1-3 sentence summary of what you changed
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
# Setup SwiftLint Action
|
||||||
|
|
||||||
|
A reusable GitHub Action that downloads and installs SwiftLint binary from [SwiftLint releases](https://github.com/realm/SwiftLint/releases/) to `/usr/bin`.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Basic usage
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: ./.github/actions/setup-swiftlint
|
||||||
|
```
|
||||||
|
|
||||||
|
This will install the latest version of SwiftLint.
|
||||||
|
|
||||||
|
### Specify version
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: ./.github/actions/setup-swiftlint
|
||||||
|
with:
|
||||||
|
version: '0.58.2'
|
||||||
|
```
|
||||||
|
|
||||||
|
Or use version with `v` prefix:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: ./.github/actions/setup-swiftlint
|
||||||
|
with:
|
||||||
|
version: 'v0.58.2'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
|
||||||
|
| Input | Description | Required | Default |
|
||||||
|
|-------|-------------|----------|---------|
|
||||||
|
| `version` | SwiftLint version (e.g., `0.58.2`). If not specified, the latest version will be used | No | `latest` |
|
||||||
|
|
||||||
|
## Example workflow
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Install SwiftLint
|
||||||
|
uses: ./.github/actions/setup-swiftlint
|
||||||
|
with:
|
||||||
|
version: '0.58.2'
|
||||||
|
|
||||||
|
- name: Run SwiftLint
|
||||||
|
run: swiftlint
|
||||||
|
```
|
||||||
|
|
||||||
|
## Supported operating systems
|
||||||
|
|
||||||
|
- macOS
|
||||||
|
- Linux
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- This action requires `sudo` permissions to install the binary to `/usr/bin`
|
||||||
|
- After installation, the `swiftlint` command will be globally available in PATH
|
||||||
|
- If the specified version does not exist, the action will fail with an error message
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
name: 'Setup SwiftLint'
|
||||||
|
description: 'Download and install SwiftLint binary to /usr/bin'
|
||||||
|
branding:
|
||||||
|
icon: 'code'
|
||||||
|
color: 'blue'
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: 'SwiftLint version (e.g., 0.58.2). If not specified, the latest version will be used'
|
||||||
|
required: false
|
||||||
|
default: 'latest'
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
- name: Detect OS
|
||||||
|
id: os
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [[ "$RUNNER_OS" == "macOS" ]]; then
|
||||||
|
echo "platform=macos" >> $GITHUB_OUTPUT
|
||||||
|
echo "archive_name=portable_swiftlint.zip" >> $GITHUB_OUTPUT
|
||||||
|
elif [[ "$RUNNER_OS" == "Linux" ]]; then
|
||||||
|
echo "platform=linux" >> $GITHUB_OUTPUT
|
||||||
|
echo "archive_name=swiftlint_linux.zip" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "Error: Unsupported OS $RUNNER_OS"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Get latest version
|
||||||
|
if: inputs.version == 'latest'
|
||||||
|
id: version
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
VERSION=$(curl -s https://api.github.com/repos/realm/SwiftLint/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||||
|
if [[ -z "$VERSION" ]]; then
|
||||||
|
echo "Error: Failed to get latest version"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "Latest version: $VERSION"
|
||||||
|
|
||||||
|
- name: Set version
|
||||||
|
if: inputs.version != 'latest'
|
||||||
|
id: version
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
VERSION="${{ inputs.version }}"
|
||||||
|
if [[ ! "$VERSION" =~ ^v ]]; then
|
||||||
|
VERSION="v$VERSION"
|
||||||
|
fi
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "Using specified version: $VERSION"
|
||||||
|
|
||||||
|
- name: Download and install SwiftLint
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
|
||||||
|
PLATFORM="${{ steps.os.outputs.platform }}"
|
||||||
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
|
ARCHIVE_NAME="${{ steps.os.outputs.archive_name }}"
|
||||||
|
DOWNLOAD_URL="https://github.com/realm/SwiftLint/releases/download/${VERSION}/${ARCHIVE_NAME}"
|
||||||
|
|
||||||
|
echo "Downloading SwiftLint from $DOWNLOAD_URL..."
|
||||||
|
|
||||||
|
if ! curl -L -f -o swiftlint.zip "$DOWNLOAD_URL"; then
|
||||||
|
echo "Error: Download failed, please check if the version is correct"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Extracting..."
|
||||||
|
unzip -q swiftlint.zip
|
||||||
|
|
||||||
|
if [[ -f "swiftlint" ]]; then
|
||||||
|
BINARY_PATH="swiftlint"
|
||||||
|
elif [[ -f "swiftlint_linux/swiftlint" ]]; then
|
||||||
|
BINARY_PATH="swiftlint_linux/swiftlint"
|
||||||
|
elif [[ -f "portable_swiftlint/swiftlint" ]]; then
|
||||||
|
BINARY_PATH="portable_swiftlint/swiftlint"
|
||||||
|
else
|
||||||
|
echo "Error: Could not find swiftlint binary"
|
||||||
|
ls -la
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod +x "$BINARY_PATH"
|
||||||
|
sudo mv "$BINARY_PATH" /usr/bin/swiftlint
|
||||||
|
|
||||||
|
if ! swiftlint version; then
|
||||||
|
echo "Error: SwiftLint installation verification failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf swiftlint.zip swiftlint_linux portable_swiftlint 2>/dev/null || true
|
||||||
@@ -14,6 +14,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
- uses: ./.github/actions/setup-swiftlint
|
||||||
- uses: pnpm/action-setup@v3
|
- uses: pnpm/action-setup@v3
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
@@ -23,6 +24,7 @@ jobs:
|
|||||||
- run: pnpm install
|
- run: pnpm install
|
||||||
- run: pnpm prune && pnpm dedupe
|
- run: pnpm prune && pnpm dedupe
|
||||||
- run: pnpm run lint:fix
|
- run: pnpm run lint:fix
|
||||||
|
- run: pnpm run lint:swift --fix
|
||||||
|
|
||||||
# - name: AutoCorrect
|
# - name: AutoCorrect
|
||||||
# uses: huacnlee/autocorrect-action@main
|
# uses: huacnlee/autocorrect-action@main
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
- uses: ./.github/actions/setup-swiftlint
|
||||||
- uses: pnpm/action-setup@v3
|
- uses: pnpm/action-setup@v3
|
||||||
- uses: actions/setup-node@v5
|
- uses: actions/setup-node@v5
|
||||||
with:
|
with:
|
||||||
@@ -23,6 +24,7 @@ jobs:
|
|||||||
|
|
||||||
- run: pnpm install --frozen-lockfile
|
- run: pnpm install --frozen-lockfile
|
||||||
- run: pnpm run lint
|
- run: pnpm run lint
|
||||||
|
- run: pnpm run lint:swift
|
||||||
|
|
||||||
build-test:
|
build-test:
|
||||||
name: Build Test (${{ matrix.app_name }})
|
name: Build Test (${{ matrix.app_name }})
|
||||||
|
|||||||
@@ -11,3 +11,6 @@ capacitor-cordova-ios-plugins
|
|||||||
# Generated Config files
|
# Generated Config files
|
||||||
App/App/capacitor.config.json
|
App/App/capacitor.config.json
|
||||||
App/App/config.xml
|
App/App/config.xml
|
||||||
|
|
||||||
|
App.xcarchive
|
||||||
|
archive.plist
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"pins" : [
|
||||||
|
{
|
||||||
|
"identity" : "capacitor-swift-pm",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/ionic-team/capacitor-swift-pm.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "596259033e94829dffc552a40e7129262122995e",
|
||||||
|
"version" : "8.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" : 2
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
|
"lint:swift": "swiftlint",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"typecheck": "vue-tsc --noEmit",
|
"typecheck": "vue-tsc --noEmit",
|
||||||
"dev:web": "vite",
|
"dev:web": "vite",
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
"lint": "moeru-lint .",
|
"lint": "moeru-lint .",
|
||||||
"lint:fix": "moeru-lint --fix .",
|
"lint:fix": "moeru-lint --fix .",
|
||||||
"lint:rust": "cargo fmt --check && cargo clippy --workspace",
|
"lint:rust": "cargo fmt --check && cargo clippy --workspace",
|
||||||
|
"lint:swift": "pnpm -rF @proj-airi/stage-pocket run lint:swift",
|
||||||
"to-avif": "tsx docs/scripts/avif.ts",
|
"to-avif": "tsx docs/scripts/avif.ts",
|
||||||
"typecheck": "pnpm -rF=\"./packages/*\" -F=\"./apps/*\" -F=\"./docs\" --parallel typecheck",
|
"typecheck": "pnpm -rF=\"./packages/*\" -F=\"./apps/*\" -F=\"./docs\" --parallel typecheck",
|
||||||
"up": "taze -w -r -I && pnpm prune && pnpm dedupe",
|
"up": "taze -w -r -I && pnpm prune && pnpm dedupe",
|
||||||
|
|||||||
Reference in New Issue
Block a user