From 753826d4e94aaf0ca70125188373273b1aa9f8a1 Mon Sep 17 00:00:00 2001 From: sangeeths03 Date: Tue, 22 Apr 2025 11:45:22 +0530 Subject: [PATCH] Update swiftlintcrash.yml --- .github/workflows/swiftlintcrash.yml | 51 +++++++++++++++++++--------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/.github/workflows/swiftlintcrash.yml b/.github/workflows/swiftlintcrash.yml index c2cbb5ee..939a674a 100644 --- a/.github/workflows/swiftlintcrash.yml +++ b/.github/workflows/swiftlintcrash.yml @@ -1,34 +1,53 @@ -name: Reproduce SwiftLint Crash +name: Reproduce SwiftLint Crash (0.59.0) on: workflow_dispatch: # manual trigger jobs: - swiftlint-crash-check: + swiftlint-crash-test: runs-on: macos-15 - name: SwiftLint Crash Repro on macOS 15 + name: SwiftLint 0.59.0 Crash Check on macOS 15 steps: - - name: Checkout code + - name: Checkout Code uses: actions/checkout@v3 - - name: Set up project structure + - name: Setup test files with invalid .swiftlint.yml run: | mkdir -p subdir - echo "opt_in_rules:\n - closure_body_length\n\nopt_in_rules:\n - closure_body_length" > subdir/.swiftlint.yml + echo -e "opt_in_rules:\n - closure_body_length\n\nopt_in_rules:\n - closure_body_length" > subdir/.swiftlint.yml echo "let a = 1" > subdir/a.swift - - name: Install SwiftLint (Latest via Homebrew) - run: | - brew update - brew install swiftlint + - name: Install dependencies + run: brew install swift - - name: Run SwiftLint in subdir (check for crash) + - name: Build SwiftLint 0.59.0 from source run: | - echo "Running SwiftLint..." + git clone https://github.com/realm/SwiftLint.git + cd SwiftLint + git checkout 0.59.0 + swift build -c release + sudo cp .build/release/swiftlint /usr/local/bin/swiftlint + + - name: Print SwiftLint Version + run: swiftlint --version + + - name: Run SwiftLint with crash detection + run: | + echo "๐Ÿงช Running SwiftLint..." cd subdir - swiftlint || echo "SwiftLint crashed or failed" + set +e + swiftlint > ../swiftlint-output.txt 2>&1 + EXIT_CODE=$? + cat ../swiftlint-output.txt - - name: Output result - if: ${{ failure() }} - run: echo "โŒ SwiftLint crashed with current config." + echo "::group::๐Ÿ” SwiftLint Result Analysis" + if grep -q "Could not read configuration" ../swiftlint-output.txt; then + echo "::error ::๐Ÿ’ฅ SwiftLint crashed due to malformed config" + echo "Crash detected in SwiftLint 0.59.0" + elif [ $EXIT_CODE -ne 0 ]; then + echo "::warning ::โš ๏ธ SwiftLint exited with lint violations" + else + echo "โœ… SwiftLint ran successfully without crash or violations" + fi + echo "::endgroup::"