fix(ci): 'should use swiftlint version from env not inputs' (#1025)
* fix(ci): 'should use swiftlint version from env not inputs' * fix(ci): remove `-it` * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Muhammad Nur Faiz <229660710+Meiw0@users.noreply.github.com>
This commit is contained in:
co-authored by
autofix-ci[bot]
Muhammad Nur Faiz
parent
9cc2a9a206
commit
9e5034fffc
@@ -1,72 +0,0 @@
|
||||
# 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
|
||||
@@ -1,134 +0,0 @@
|
||||
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 and architecture
|
||||
id: os
|
||||
shell: bash
|
||||
run: |
|
||||
ARCH=$(uname -m)
|
||||
if [[ "$ARCH" == "x86_64" ]]; then
|
||||
ARCH_SUFFIX="amd64"
|
||||
elif [[ "$ARCH" == "aarch64" ]] || [[ "$ARCH" == "arm64" ]]; then
|
||||
ARCH_SUFFIX="arm64"
|
||||
else
|
||||
echo "Error: Unsupported architecture $ARCH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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
|
||||
echo "arch=$ARCH_SUFFIX" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Resolve version
|
||||
id: version
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ "${{ inputs.version }}" == "latest" ]]; then
|
||||
# Fetch the latest release tag using a more robust method
|
||||
CURL_ARGS=(-s)
|
||||
if [[ -n "${{ github.token }}" ]]; then
|
||||
CURL_ARGS+=(-H "Authorization: Bearer ${{ github.token }}")
|
||||
fi
|
||||
CURL_ARGS+=(-H "Accept: application/vnd.github+json")
|
||||
CURL_ARGS+=(-H "X-GitHub-Api-Version: 2022-11-28")
|
||||
CURL_ARGS+=("https://api.github.com/repos/realm/SwiftLint/releases/latest")
|
||||
|
||||
API_RESPONSE=$(curl "${CURL_ARGS[@]}")
|
||||
|
||||
# Try using jq if available (most GitHub Actions runners have it)
|
||||
if command -v jq >/dev/null 2>&1; then
|
||||
VERSION=$(echo "$API_RESPONSE" | jq -r '.tag_name // empty')
|
||||
else
|
||||
# Fallback: parse JSON manually with sed, being very specific about the tag_name field
|
||||
VERSION=$(echo "$API_RESPONSE" | sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -1)
|
||||
fi
|
||||
|
||||
# Validate the version looks correct (should contain version numbers)
|
||||
if [[ -z "$VERSION" ]] || [[ "$VERSION" == "null" ]] || [[ ! "$VERSION" =~ ^[0-9] ]]; then
|
||||
echo "Error: Failed to get latest version or got invalid version: '$VERSION'"
|
||||
echo "API Response (first 50 lines):"
|
||||
echo "$API_RESPONSE" | head -50
|
||||
exit 1
|
||||
fi
|
||||
echo "Latest version: $VERSION"
|
||||
else
|
||||
VERSION="${{ inputs.version }}"
|
||||
# Remove 'v' prefix if user provided it, since SwiftLint tags don't use it
|
||||
VERSION="${VERSION#v}"
|
||||
echo "Using specified version: $VERSION"
|
||||
fi
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Download and install SwiftLint
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
|
||||
PLATFORM="${{ steps.os.outputs.platform }}"
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
ARCH="${{ steps.os.outputs.arch }}"
|
||||
ARCHIVE_NAME="${{ steps.os.outputs.archive_name }}"
|
||||
|
||||
if [[ "$PLATFORM" == "linux" ]]; then
|
||||
ARCHIVE_NAME="${ARCHIVE_NAME%.zip}_${ARCH}.zip"
|
||||
fi
|
||||
|
||||
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
|
||||
ARCHIVE_NAME_FALLBACK="${ARCHIVE_NAME%.zip}.zip"
|
||||
DOWNLOAD_URL="https://github.com/realm/SwiftLint/releases/download/${VERSION}/${ARCHIVE_NAME_FALLBACK}"
|
||||
echo "Trying fallback URL: $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
|
||||
fi
|
||||
|
||||
echo "Extracting..."
|
||||
EXTRACT_DIR=$(mktemp -d)
|
||||
unzip -q -o swiftlint.zip -d "$EXTRACT_DIR"
|
||||
|
||||
if [[ -f "$EXTRACT_DIR/swiftlint" ]]; then
|
||||
BINARY_PATH="$EXTRACT_DIR/swiftlint"
|
||||
elif [[ -f "$EXTRACT_DIR/swiftlint_linux/swiftlint" ]]; then
|
||||
BINARY_PATH="$EXTRACT_DIR/swiftlint_linux/swiftlint"
|
||||
elif [[ -f "$EXTRACT_DIR/portable_swiftlint/swiftlint" ]]; then
|
||||
BINARY_PATH="$EXTRACT_DIR/portable_swiftlint/swiftlint"
|
||||
else
|
||||
echo "Error: Could not find swiftlint binary"
|
||||
ls -la "$EXTRACT_DIR"
|
||||
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 "$EXTRACT_DIR" 2>/dev/null || true
|
||||
@@ -14,7 +14,6 @@ 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:
|
||||
@@ -24,7 +23,8 @@ jobs:
|
||||
- run: pnpm install
|
||||
- run: pnpm prune && pnpm dedupe
|
||||
- run: pnpm run lint:fix
|
||||
- run: pnpm run lint:swift --fix
|
||||
- run: docker run -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:latest --fix
|
||||
working-directory: ./apps/stage-pocket
|
||||
|
||||
# - name: AutoCorrect
|
||||
# uses: huacnlee/autocorrect-action@main
|
||||
|
||||
@@ -15,7 +15,6 @@ 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:
|
||||
@@ -24,7 +23,8 @@ jobs:
|
||||
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm run lint
|
||||
- run: pnpm run lint:swift
|
||||
- run: docker run -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:latest
|
||||
working-directory: ./apps/stage-pocket
|
||||
|
||||
build-test:
|
||||
name: Build Test (${{ matrix.app_name }})
|
||||
|
||||
Generated
+5
-3
@@ -11748,11 +11748,13 @@ packages:
|
||||
|
||||
glob@10.5.0:
|
||||
resolution: {integrity: sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==}
|
||||
deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
hasBin: true
|
||||
|
||||
glob@11.1.0:
|
||||
resolution: {integrity: sha512-vuNwKSaKiqm7g0THUBu2x7ckSs3XJLXE+2ssL7/MfTGPLLcrJQ/4Uq1CjPTtO5cCIiRxqvN6Twy1qOwhL0Xjcw==}
|
||||
engines: {node: 20 || >=22}
|
||||
deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
hasBin: true
|
||||
|
||||
glob@13.0.0:
|
||||
@@ -11761,7 +11763,7 @@ packages:
|
||||
|
||||
glob@7.2.3:
|
||||
resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==}
|
||||
deprecated: Glob versions prior to v9 are no longer supported
|
||||
deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
|
||||
global-agent@3.0.0:
|
||||
resolution: {integrity: sha512-PT6XReJ+D07JvGoxQMkT6qji/jVNfX/h364XHZOWeRzy64sSFr+xJ5OX7LI3b4MPQzdL4H8Y8M0xzPpsVMwA8Q==}
|
||||
@@ -15120,12 +15122,12 @@ packages:
|
||||
tar@6.2.1:
|
||||
resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==}
|
||||
engines: {node: '>=10'}
|
||||
deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exhorbitant rates) by contacting i@izs.me
|
||||
deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
|
||||
tar@7.5.2:
|
||||
resolution: {integrity: sha512-7NyxrTE4Anh8km8iEy7o0QYPs+0JKBTj5ZaqHg6B39erLg0qYXN3BijtShwbsNSvQ+LN75+KV+C4QR/f6Gwnpg==}
|
||||
engines: {node: '>=18'}
|
||||
deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exhorbitant rates) by contacting i@izs.me
|
||||
deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
|
||||
taze@19.9.2:
|
||||
resolution: {integrity: sha512-If8bq7lSckIMPfXV+C9jjEfdsQnRryh/foKfpX/ah6zI0TrQfUGWSGCaaD32Bqy5/KGRmLZie3EwMSr3Au21XQ==}
|
||||
|
||||
Reference in New Issue
Block a user