mirror of
https://github.com/moeru-ai/airi.git
synced 2026-04-28 06:29:33 +00:00
feat(ci): lint swift code
This commit is contained in:
parent
0540918719
commit
f40b9bcd89
9 changed files with 203 additions and 0 deletions
12
.cursor/commands/deslop.md
Normal file
12
.cursor/commands/deslop.md
Normal file
|
|
@ -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
|
||||
72
.github/actions/setup-swiftlint/README.md
vendored
Normal file
72
.github/actions/setup-swiftlint/README.md
vendored
Normal file
|
|
@ -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
|
||||
96
.github/actions/setup-swiftlint/action.yml
vendored
Normal file
96
.github/actions/setup-swiftlint/action.yml
vendored
Normal file
|
|
@ -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
|
||||
2
.github/workflows/autofix.yaml
vendored
2
.github/workflows/autofix.yaml
vendored
|
|
@ -14,6 +14,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: ./.github/actions/setup-swiftlint
|
||||
- uses: pnpm/action-setup@v3
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
|
|
@ -23,6 +24,7 @@ jobs:
|
|||
- run: pnpm install
|
||||
- run: pnpm prune && pnpm dedupe
|
||||
- run: pnpm run lint:fix
|
||||
- run: pnpm run lint:swift --fix
|
||||
|
||||
# - name: AutoCorrect
|
||||
# uses: huacnlee/autocorrect-action@main
|
||||
|
|
|
|||
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
|
@ -15,6 +15,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: ./.github/actions/setup-swiftlint
|
||||
- uses: pnpm/action-setup@v3
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
|
|
@ -23,6 +24,7 @@ jobs:
|
|||
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm run lint
|
||||
- run: pnpm run lint:swift
|
||||
|
||||
build-test:
|
||||
name: Build Test (${{ matrix.app_name }})
|
||||
|
|
|
|||
3
apps/stage-pocket/ios/.gitignore
vendored
3
apps/stage-pocket/ios/.gitignore
vendored
|
|
@ -11,3 +11,6 @@ capacitor-cordova-ios-plugins
|
|||
# Generated Config files
|
||||
App/App/capacitor.config.json
|
||||
App/App/config.xml
|
||||
|
||||
App.xcarchive
|
||||
archive.plist
|
||||
|
|
|
|||
14
apps/stage-pocket/ios/App/CapApp-SPM/Package.resolved
Normal file
14
apps/stage-pocket/ios/App/CapApp-SPM/Package.resolved
Normal file
|
|
@ -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": {
|
||||
"build": "vite build",
|
||||
"lint": "eslint .",
|
||||
"lint:swift": "swiftlint",
|
||||
"preview": "vite preview",
|
||||
"typecheck": "vue-tsc --noEmit",
|
||||
"dev:web": "vite",
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
"lint": "moeru-lint .",
|
||||
"lint:fix": "moeru-lint --fix .",
|
||||
"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",
|
||||
"typecheck": "pnpm -rF=\"./packages/*\" -F=\"./apps/*\" -F=\"./docs\" --parallel typecheck",
|
||||
"up": "taze -w -r -I && pnpm prune && pnpm dedupe",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue